X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=src%2Fapp%2Futilities%2Fusers-action%2FUsersActionComponent.ts;h=a7b4c2480ad9178833fa81ae742ebe29d886e443;hb=refs%2Fchanges%2F14%2F14414%2F3;hp=1d8e8952abc6d0dbf54042e1940dbdd1b334807d;hpb=3b4814aa2d3dec621dadb52f058ba95a3dc3a86a;p=osm%2FNG-UI.git diff --git a/src/app/utilities/users-action/UsersActionComponent.ts b/src/app/utilities/users-action/UsersActionComponent.ts index 1d8e895..a7b4c24 100644 --- a/src/app/utilities/users-action/UsersActionComponent.ts +++ b/src/app/utilities/users-action/UsersActionComponent.ts @@ -25,8 +25,9 @@ import { AddEditUserComponent } from 'AddEditUserComponent'; import { MODALCLOSERESPONSEDATA } from 'CommonModel'; import { DeleteComponent } from 'DeleteComponent'; import { ProjectRoleComponent } from 'ProjectRoleComponent'; -import { SharedService } from 'SharedService'; +import { SharedService, isNullOrUndefined } from 'SharedService'; import { UserData } from 'UserModel'; +import { WarningComponent } from 'WarningComponent'; /** * Creating component * @Component takes UsersActionComponent.html as template url @@ -46,6 +47,15 @@ export class UsersActionComponent { /** handle translate @public */ public translateService: TranslateService; + /** Admin Visibility Check @public */ + public isAdminShow: boolean; + + /** User Visibility Check @public */ + public isUserShow: boolean; + + /** User Status Check @public */ + public isUserStatus: string; + /** Instance of the modal service @private */ private modalService: NgbModal; @@ -59,18 +69,33 @@ export class UsersActionComponent { this.translateService = this.injector.get(TranslateService); } + /** + * Lifecyle Hooks the trigger before component is instantiate + */ + public ngOnInit(): void { + this.isAdminShow = sessionStorage.getItem('admin_show') === 'true' ? true : false; + this.isUserShow = sessionStorage.getItem('user_show') === 'true' ? true : false; + if (!isNullOrUndefined(this.value.user_status)) { + this.isUserStatus = this.value.user_status; + } + } + /** Delete User Account @public */ public deleteUser(): void { + // eslint-disable-next-line security/detect-non-literal-fs-filename const modalRef: NgbModalRef = this.modalService.open(DeleteComponent, { backdrop: 'static' }); modalRef.result.then((result: MODALCLOSERESPONSEDATA) => { if (result) { this.sharedService.callData(); } - }).catch(); + }).catch((): void => { + // Catch Navigation Error + }); } /** Edit User Account @public */ public editUserModal(editType: string): void { + // eslint-disable-next-line security/detect-non-literal-fs-filename const modalRef: NgbModalRef = this.modalService.open(AddEditUserComponent, { backdrop: 'static' }); modalRef.componentInstance.userID = this.value.identifier; if (editType === 'editPassword') { @@ -84,11 +109,14 @@ export class UsersActionComponent { if (result) { this.sharedService.callData(); } - }).catch(); + }).catch((): void => { + // Catch Navigation Error + }); } /** Edit User Account @public */ public projectRolesModal(): void { + // eslint-disable-next-line security/detect-non-literal-fs-filename const modalRef: NgbModalRef = this.modalService.open(ProjectRoleComponent, { backdrop: 'static' }); modalRef.componentInstance.userID = this.value.identifier; modalRef.componentInstance.userTitle = this.translateService.instant('PAGE.USERS.EDITPROJECTROLEMAPPING'); @@ -96,6 +124,38 @@ export class UsersActionComponent { if (result) { this.sharedService.callData(); } - }).catch(); + }).catch((): void => { + // Catch Navigation Error + }); + } + + /** To Unlock or Renew User @public */ + public unlockRenewUser(editType: string): void { + // eslint-disable-next-line security/detect-non-literal-fs-filename + const modalRef: NgbModalRef = this.modalService.open(WarningComponent, { backdrop: 'static' }); + sessionStorage.setItem('renew', 'true'); + const id: string = sessionStorage.getItem('user_id'); + if (editType === 'unlock') { + modalRef.componentInstance.heading = this.translateService.instant('Unlock User'); + modalRef.componentInstance.confirmationMessage = this.translateService.instant('Are you sure want to unlock this user'); + modalRef.componentInstance.submitMessage = this.translateService.instant('Unlock'); + modalRef.componentInstance.action = Boolean(true); + modalRef.componentInstance.editType = editType; + modalRef.componentInstance.id = this.value.identifier; + } else { + modalRef.componentInstance.heading = this.translateService.instant('Renew User'); + modalRef.componentInstance.confirmationMessage = this.translateService.instant('Are you sure want to renew this user'); + modalRef.componentInstance.submitMessage = this.translateService.instant('Renew'); + modalRef.componentInstance.action = Boolean(true); + modalRef.componentInstance.editType = editType; + modalRef.componentInstance.id = this.value.identifier; + } + modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => { + if (result) { + this.sharedService.callData(); + } + }).catch((): void => { + // Catch Navigation Error + }); } }