From 57f3d2f6ed922a64d5bf4af9699ff3afd745ad6d Mon Sep 17 00:00:00 2001 From: ajithmuthukumar-bc Date: Thu, 19 Jan 2023 23:42:04 +0530 Subject: [PATCH 01/13] code-climate-issue-fixes --- ...e-user-add-single-user-detail.component.ts | 2 +- .../user-contact-edit.component.html | 8 ++-- .../user-contact-edit.component.ts | 4 +- .../user-profile/user-profile-component.ts | 37 +++++++++++-------- .../wrapper/wrapper-org--group-service.ts | 2 +- 5 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/app/pages/manage-user/manage-user-add-single-user-detail/manage-user-add-single-user-detail.component.ts b/src/app/pages/manage-user/manage-user-add-single-user-detail/manage-user-add-single-user-detail.component.ts index a28ca961f..1b12ecafc 100644 --- a/src/app/pages/manage-user/manage-user-add-single-user-detail/manage-user-add-single-user-detail.component.ts +++ b/src/app/pages/manage-user/manage-user-add-single-user-detail/manage-user-add-single-user-detail.component.ts @@ -347,7 +347,7 @@ export class ManageUserAddSingleUserDetailComponent async getApprovalRequriedRoles() { this.approveRequiredRole = await this.organisationGroupService - .getOrganisationApprovalRequiredRoles(this.organisationId) + .getOrganisationApprovalRequiredRoles() .toPromise(); } diff --git a/src/app/pages/user-contact/user-contact-edit/user-contact-edit.component.html b/src/app/pages/user-contact/user-contact-edit/user-contact-edit.component.html index 15b21778c..780f277f4 100644 --- a/src/app/pages/user-contact/user-contact-edit/user-contact-edit.component.html +++ b/src/app/pages/user-contact/user-contact-edit/user-contact-edit.component.html @@ -21,7 +21,7 @@

{{ 'ADD_ANOTHER_CON

{{ 'EDIT_CONTACT_DETAILS' | translate }}

-
+
Enter at least one of the following contact details - Error: Enter at least one contact detail from either email address, telephone number, mobile number, fax number or web diff --git a/src/app/pages/user-contact/user-contact-edit/user-contact-edit.component.ts b/src/app/pages/user-contact/user-contact-edit/user-contact-edit.component.ts index 482550b7a..b41be85f8 100644 --- a/src/app/pages/user-contact/user-contact-edit/user-contact-edit.component.ts +++ b/src/app/pages/user-contact/user-contact-edit/user-contact-edit.component.ts @@ -268,7 +268,7 @@ export class UserContactEditComponent this.formGroup.controls['email'].setErrors({ incorrect: true }); } if (this.formValid(form)) { - if (!this.validator) { + if (!this.validators) { this.contactData.contactPointName = form.get('name')?.value; this.contactData.contacts = this.contactHelper.getContactListFromForm(form); @@ -384,7 +384,7 @@ export class UserContactEditComponent }); } - public get validator() { + public get validators() { if ( this.formGroup.get('email')?.value || this.formGroup.get('phone')?.value || diff --git a/src/app/pages/user-profile/user-profile-component.ts b/src/app/pages/user-profile/user-profile-component.ts index 899a5ccac..b34ca01f6 100644 --- a/src/app/pages/user-profile/user-profile-component.ts +++ b/src/app/pages/user-profile/user-profile-component.ts @@ -325,7 +325,7 @@ export class UserProfileComponent extends FormBaseComponent implements OnInit { async getApprovalRequriedRoles() { this.approveRequiredRole = await this.orgGroupService - .getOrganisationApprovalRequiredRoles(this.organisationId) + .getOrganisationApprovalRequiredRoles() .toPromise(); } @@ -459,16 +459,14 @@ export class UserProfileComponent extends FormBaseComponent implements OnInit { selectedRoleIds.push(role.roleId) } else { let filterAlreadyExistRole = this.pendingRoleDetails.find((element: { roleKey: any; }) => element.roleKey == role.roleKey) - if (this.pendingRoleDetails.length != 0) { - if (filterAlreadyExistRole.roleKey != role.roleKey) { - this.selectedApproveRequiredRole.push(role.roleId) - } - } else { + if (this.pendingRoleDetails.length == 0) { if(!role.enabled){ this.selectedApproveRequiredRole.push(role.roleId) } else { selectedRoleIds.push(role.roleId) } + } else if(filterAlreadyExistRole.roleKey != role.roleKey) { + this.selectedApproveRequiredRole.push(role.roleId) } } } else { @@ -517,24 +515,33 @@ export class UserProfileComponent extends FormBaseComponent implements OnInit { if (this.selectedApproveRequiredRole.length != 0 && !isValidDomain) { this.userService.createPendingApproveRole(selectedRolesDetails).subscribe({ next: (roleInfo: UserEditResponseInfo) => { - if (this.pendingRoledeleteDetails.length != 0) { - this.deleteApprovePendingRole() - } else { - this.updateUser() - } + this.checkDeleteStatusForPendingRole() }, error: (err: any) => { console.log(err) }, }); } else { + this.checkDeleteStatus() + } + } + + private checkDeleteStatusForPendingRole(){ + if (this.pendingRoledeleteDetails.length === 0) { + this.updateUser() + } else { + this.deleteApprovePendingRole() + } + } + + private checkDeleteStatus(){ if (this.pendingRoledeleteDetails.length != 0) { this.deleteApprovePendingRole() } else { this.updateUser() } } - } + private updateUser(): void { this.userService.updateUser(this.userName, this.userRequest).subscribe( @@ -564,9 +571,9 @@ export class UserProfileComponent extends FormBaseComponent implements OnInit { } } if (isChecked == false) { - if (obj.pendingStatus === true) { - let filterRole = this.pendingRoledeleteDetails.find((element: number) => element == obj.roleId) - if (filterRole === undefined) { + if (obj.pendingStatus) { + let pendingRoledObj = this.pendingRoledeleteDetails.find((element: number) => element == obj.roleId) + if (pendingRoledObj === undefined) { this.pendingRoledeleteDetails.push(obj.roleId) } } diff --git a/src/app/services/wrapper/wrapper-org--group-service.ts b/src/app/services/wrapper/wrapper-org--group-service.ts index 44380ecb2..00e1087e7 100644 --- a/src/app/services/wrapper/wrapper-org--group-service.ts +++ b/src/app/services/wrapper/wrapper-org--group-service.ts @@ -138,7 +138,7 @@ export class WrapperOrganisationGroupService { ); } - getOrganisationApprovalRequiredRoles(organisationId: string): Observable { + getOrganisationApprovalRequiredRoles(): Observable { const url = `${this.configURl}/approve/roles`; return this.http.get(url).pipe( map((data: Role[]) => { From 7a9f9735132cd372f80dcb7a840a5bd80355c276 Mon Sep 17 00:00:00 2001 From: ajithmuthukumar-bc Date: Thu, 19 Jan 2023 23:46:45 +0530 Subject: [PATCH 02/13] function name changed --- src/app/pages/user-profile/user-profile-component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/pages/user-profile/user-profile-component.ts b/src/app/pages/user-profile/user-profile-component.ts index b34ca01f6..c68329c4b 100644 --- a/src/app/pages/user-profile/user-profile-component.ts +++ b/src/app/pages/user-profile/user-profile-component.ts @@ -559,9 +559,9 @@ export class UserProfileComponent extends FormBaseComponent implements OnInit { } onUserRoleChecked(obj: any, isChecked: boolean) { if (isChecked == true) { - if (obj.pendingStatus === true) { - let filterRole = this.pendingRoledeleteDetails.find((element: number) => element == obj.roleId) - if (filterRole != undefined) { + if (obj.pendingStatus) { + let pendingRole = this.pendingRoledeleteDetails.find((element: number) => element == obj.roleId) + if (pendingRole != undefined) { this.pendingRoledeleteDetails.forEach((pRole: any, index: any) => { if (pRole === obj.roleId) { this.pendingRoledeleteDetails.splice(index, 1) From d09fadfbeeab8b2ae37c346ad870ae79b22468b5 Mon Sep 17 00:00:00 2001 From: ajithmuthukumar-bc Date: Thu, 19 Jan 2023 23:53:29 +0530 Subject: [PATCH 03/13] testing --- src/app/pages/user-profile/user-profile-component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/pages/user-profile/user-profile-component.ts b/src/app/pages/user-profile/user-profile-component.ts index c68329c4b..5161cffc8 100644 --- a/src/app/pages/user-profile/user-profile-component.ts +++ b/src/app/pages/user-profile/user-profile-component.ts @@ -460,10 +460,10 @@ export class UserProfileComponent extends FormBaseComponent implements OnInit { } else { let filterAlreadyExistRole = this.pendingRoleDetails.find((element: { roleKey: any; }) => element.roleKey == role.roleKey) if (this.pendingRoleDetails.length == 0) { - if(!role.enabled){ - this.selectedApproveRequiredRole.push(role.roleId) - } else { + if(role.enabled === true){ selectedRoleIds.push(role.roleId) + } else { + this.selectedApproveRequiredRole.push(role.roleId) } } else if(filterAlreadyExistRole.roleKey != role.roleKey) { this.selectedApproveRequiredRole.push(role.roleId) From a5616043506afa115ebbc64999f93c46dc0e49bb Mon Sep 17 00:00:00 2001 From: ajithmuthukumar-bc Date: Thu, 19 Jan 2023 23:59:21 +0530 Subject: [PATCH 04/13] conplex removal --- .../user-profile/user-profile-component.ts | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/app/pages/user-profile/user-profile-component.ts b/src/app/pages/user-profile/user-profile-component.ts index 5161cffc8..b98727a8f 100644 --- a/src/app/pages/user-profile/user-profile-component.ts +++ b/src/app/pages/user-profile/user-profile-component.ts @@ -560,14 +560,7 @@ export class UserProfileComponent extends FormBaseComponent implements OnInit { onUserRoleChecked(obj: any, isChecked: boolean) { if (isChecked == true) { if (obj.pendingStatus) { - let pendingRole = this.pendingRoledeleteDetails.find((element: number) => element == obj.roleId) - if (pendingRole != undefined) { - this.pendingRoledeleteDetails.forEach((pRole: any, index: any) => { - if (pRole === obj.roleId) { - this.pendingRoledeleteDetails.splice(index, 1) - } - }) - } + this.removePendingRole(obj) } } if (isChecked == false) { @@ -579,6 +572,17 @@ export class UserProfileComponent extends FormBaseComponent implements OnInit { } } } + + private removePendingRole(obj:any){ + let pendingRole = this.pendingRoledeleteDetails.find((element: number) => element == obj.roleId) + if (pendingRole != undefined) { + this.pendingRoledeleteDetails.forEach((pRole: any, index: any) => { + if (pRole === obj.roleId) { + this.pendingRoledeleteDetails.splice(index, 1) + } + }) + } + } private deleteApprovePendingRole(): void { const deleteRoleIds = this.pendingRoledeleteDetails.join(); From 19a632b1992bf57f622e6841768429c8b709931b Mon Sep 17 00:00:00 2001 From: ajithmuthukumar-bc Date: Fri, 20 Jan 2023 00:02:34 +0530 Subject: [PATCH 05/13] complex testing --- src/app/pages/user-profile/user-profile-component.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/app/pages/user-profile/user-profile-component.ts b/src/app/pages/user-profile/user-profile-component.ts index b98727a8f..cc16f76f6 100644 --- a/src/app/pages/user-profile/user-profile-component.ts +++ b/src/app/pages/user-profile/user-profile-component.ts @@ -558,18 +558,14 @@ export class UserProfileComponent extends FormBaseComponent implements OnInit { ); } onUserRoleChecked(obj: any, isChecked: boolean) { - if (isChecked == true) { - if (obj.pendingStatus) { + if (isChecked == true && obj.pendingStatus) { this.removePendingRole(obj) - } } - if (isChecked == false) { - if (obj.pendingStatus) { + if (isChecked == false && obj.pendingStatus) { let pendingRoledObj = this.pendingRoledeleteDetails.find((element: number) => element == obj.roleId) if (pendingRoledObj === undefined) { this.pendingRoledeleteDetails.push(obj.roleId) } - } } } From e271f23dcbfdc793e1f88d49439dcfa6204f6ff6 Mon Sep 17 00:00:00 2001 From: ajithmuthukumar-bc Date: Fri, 20 Jan 2023 00:16:24 +0530 Subject: [PATCH 06/13] complex check --- .../user-profile/user-profile-component.ts | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/app/pages/user-profile/user-profile-component.ts b/src/app/pages/user-profile/user-profile-component.ts index cc16f76f6..3cf86f7c3 100644 --- a/src/app/pages/user-profile/user-profile-component.ts +++ b/src/app/pages/user-profile/user-profile-component.ts @@ -79,7 +79,7 @@ export class UserProfileComponent extends FormBaseComponent implements OnInit { routeStateData: any = {}; hasGroupViewPermission: boolean = false; isOrgAdmin: boolean = false; - + private selectedRoleIds:number[] = []; @ViewChildren('input') inputs!: QueryList; constructor( @@ -447,7 +447,7 @@ export class UserProfileComponent extends FormBaseComponent implements OnInit { } getSelectedRoleIds(form: FormGroup) { - let selectedRoleIds: number[] = []; + this.selectedRoleIds = []; this.selectedApproveRequiredRole = [] const superAdminDomain = this.organisationDetails.detail.domainName.toLowerCase() const userDomain = this.userName?.split("@")[1].toLowerCase() @@ -456,27 +456,35 @@ export class UserProfileComponent extends FormBaseComponent implements OnInit { if (superAdminDomain != userDomain) { let filterRole = this.approveRequiredRole.find((element: { roleKey: any; }) => element.roleKey == role.roleKey) if (filterRole === undefined) { - selectedRoleIds.push(role.roleId) + this.selectedRoleIds.push(role.roleId) } else { - let filterAlreadyExistRole = this.pendingRoleDetails.find((element: { roleKey: any; }) => element.roleKey == role.roleKey) - if (this.pendingRoleDetails.length == 0) { - if(role.enabled === true){ - selectedRoleIds.push(role.roleId) - } else { - this.selectedApproveRequiredRole.push(role.roleId) - } - } else if(filterAlreadyExistRole.roleKey != role.roleKey) { - this.selectedApproveRequiredRole.push(role.roleId) - } + this.checkPendingRoleDetails(role) } } else { - selectedRoleIds.push(role.roleId) + this.selectedRoleIds.push(role.roleId) } } }); - return selectedRoleIds; + return this.selectedRoleIds; } + private checkPendingRoleDetails(role:any){ + let filterAlreadyExistRole = this.pendingRoleDetails.find((element: { roleKey: any; }) => element.roleKey == role.roleKey) + if (this.pendingRoleDetails.length == 0) { + this.updateSelectedRoleIds(role) + } else if(filterAlreadyExistRole.roleKey != role.roleKey) { + this.selectedApproveRequiredRole.push(role.roleId) + } + } + + private updateSelectedRoleIds(role:any){ + if(role.enabled === true){ + this.selectedRoleIds.push(role.roleId) + } else { + this.selectedApproveRequiredRole.push(role.roleId) + } + } + /** * checking approve required roles are availble */ From 9411d6666957f84ebc602b4035fd2b9dd7a99a05 Mon Sep 17 00:00:00 2001 From: ajithmuthukumar-bc Date: Fri, 20 Jan 2023 00:19:58 +0530 Subject: [PATCH 07/13] complsity --- .../view-verified-org/view-verified-org.component.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/app/pages/manage-buyer-and-both-requests/view-verified-org/view-verified-org.component.ts b/src/app/pages/manage-buyer-and-both-requests/view-verified-org/view-verified-org.component.ts index a2d09c6e2..cc7187cfb 100644 --- a/src/app/pages/manage-buyer-and-both-requests/view-verified-org/view-verified-org.component.ts +++ b/src/app/pages/manage-buyer-and-both-requests/view-verified-org/view-verified-org.component.ts @@ -286,8 +286,7 @@ export class ViewVerifiedOrgComponent implements OnInit { ).subscribe({ next: async (orgListResponse: OrganisationAuditListResponse) => { this.getSchemeData() - if (orgListResponse != null) { - if (orgListResponse.organisationAuditList.length != 0) { + if (orgListResponse != null && orgListResponse.organisationAuditList.length != 0) { let orgDetails:any = orgListResponse.organisationAuditList.find((element) => element.organisationId === this.routeDetails.event.organisationId) if (orgDetails != undefined) { orgDetails.lastRoute ="view-verified" @@ -296,7 +295,6 @@ export class ViewVerifiedOrgComponent implements OnInit { ); } - } } }, error: (error: any) => { From aef2463513e0a9e735e79dbe9ca2a354f7a6a9d3 Mon Sep 17 00:00:00 2001 From: ajithmuthukumar-bc Date: Fri, 20 Jan 2023 00:26:06 +0530 Subject: [PATCH 08/13] dublication check --- .../view-verified-org.component.ts | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/app/pages/manage-buyer-and-both-requests/view-verified-org/view-verified-org.component.ts b/src/app/pages/manage-buyer-and-both-requests/view-verified-org/view-verified-org.component.ts index cc7187cfb..fc7435041 100644 --- a/src/app/pages/manage-buyer-and-both-requests/view-verified-org/view-verified-org.component.ts +++ b/src/app/pages/manage-buyer-and-both-requests/view-verified-org/view-verified-org.component.ts @@ -287,14 +287,7 @@ export class ViewVerifiedOrgComponent implements OnInit { next: async (orgListResponse: OrganisationAuditListResponse) => { this.getSchemeData() if (orgListResponse != null && orgListResponse.organisationAuditList.length != 0) { - let orgDetails:any = orgListResponse.organisationAuditList.find((element) => element.organisationId === this.routeDetails.event.organisationId) - if (orgDetails != undefined) { - orgDetails.lastRoute ="view-verified" - this.router.navigateByUrl( - 'pending-verification?data=' + btoa(JSON.stringify(orgDetails)) - ); - } - + this.verficatingOrgnisation(orgListResponse) } }, error: (error: any) => { @@ -303,6 +296,17 @@ export class ViewVerifiedOrgComponent implements OnInit { }); } + private verficatingOrgnisation(orgListResponse: OrganisationAuditListResponse){ + let orgDetails:any = orgListResponse.organisationAuditList.find((element) => element.organisationId === this.routeDetails.event.organisationId) + if (orgDetails != undefined) { + orgDetails.lastRoute ="view-verified" + this.router.navigateByUrl( + 'pending-verification?data=' + btoa(JSON.stringify(orgDetails)) + ); + } + } + + getVerifiedOrg() { this.wrapperBuyerAndBothService.getVerifiedOrg( this.organisationId, From dc24ebf2f60f889627bcefe5bf85b84485ec6b12 Mon Sep 17 00:00:00 2001 From: ajithmuthukumar-bc Date: Fri, 20 Jan 2023 00:37:18 +0530 Subject: [PATCH 09/13] dublicate --- .../view-pending-verification.component.ts | 22 ++++++++++--------- ...e-user-add-single-user-detail.component.ts | 20 ++++++++++------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/app/pages/manage-buyer-and-both-requests/view-pending-verification/view-pending-verification.component.ts b/src/app/pages/manage-buyer-and-both-requests/view-pending-verification/view-pending-verification.component.ts index 20132ff6a..4ff99465c 100644 --- a/src/app/pages/manage-buyer-and-both-requests/view-pending-verification/view-pending-verification.component.ts +++ b/src/app/pages/manage-buyer-and-both-requests/view-pending-verification/view-pending-verification.component.ts @@ -269,18 +269,10 @@ export class ViewPendingVerificationComponent implements OnInit { 10 ).subscribe({ next: async (orgListResponse: OrganisationAuditListResponse) => { - if (orgListResponse != null) { - if(orgListResponse.organisationAuditList.length != 0){ - let orgDetails = orgListResponse.organisationAuditList.find((element)=> element.organisationId === this.routeDetails.organisationId ) - if(orgDetails === undefined){ - this.getVerifiedOrg() - } else { - this.routeDetails = orgDetails - this.getSchemesDetails() - } + if (orgListResponse != null && orgListResponse.organisationAuditList.length != 0) { + this.checkPendingOrganisation(orgListResponse) } else { this.getVerifiedOrg() - } } }, error: (error: any) => { @@ -289,6 +281,16 @@ export class ViewPendingVerificationComponent implements OnInit { }); } + private checkPendingOrganisation(orgListResponse: OrganisationAuditListResponse){ + let orgDetails = orgListResponse.organisationAuditList.find((element)=> element.organisationId === this.routeDetails.organisationId ) + if(orgDetails === undefined){ + this.getVerifiedOrg() + } else { + this.routeDetails = orgDetails + this.getSchemesDetails() + } + } + getVerifiedOrg() { this.wrapperBuyerAndBothService.getVerifiedOrg( this.organisationId, diff --git a/src/app/pages/manage-user/manage-user-add-single-user-detail/manage-user-add-single-user-detail.component.ts b/src/app/pages/manage-user/manage-user-add-single-user-detail/manage-user-add-single-user-detail.component.ts index 1b12ecafc..1fb4beb82 100644 --- a/src/app/pages/manage-user/manage-user-add-single-user-detail/manage-user-add-single-user-detail.component.ts +++ b/src/app/pages/manage-user/manage-user-add-single-user-detail/manage-user-add-single-user-detail.component.ts @@ -767,14 +767,7 @@ export class ManageUserAddSingleUserDetailComponent this.isAutoDisableMFA = true; } if (obj.pendingStatus === true) { - let filterRole = this.pendingRoledeleteDetails.find((element: number) => element == obj.roleId) - if (filterRole != undefined) { - this.pendingRoledeleteDetails.forEach((pRole:any,index:any)=>{ - if(pRole === obj.roleId){ - this.pendingRoledeleteDetails.splice(index,1) - } - }) - } + this.setCheckedApprovedRequiredRole(obj) } } else if (isChecked == false) { @@ -790,6 +783,17 @@ export class ManageUserAddSingleUserDetailComponent } } } + + private setCheckedApprovedRequiredRole(obj:any){ + let filterRole = this.pendingRoledeleteDetails.find((element: number) => element == obj.roleId) + if (filterRole != undefined) { + this.pendingRoledeleteDetails.forEach((pRole:any,index:any)=>{ + if(pRole === obj.roleId){ + this.pendingRoledeleteDetails.splice(index,1) + } + }) + } + } public ResetAdditionalSecurity(): void { if (this.MFA_Enabled) { From 939c25b1010ecd63ab9dbdc56bd81b1e0d012988 Mon Sep 17 00:00:00 2001 From: ajithmuthukumar-bc Date: Fri, 20 Jan 2023 00:59:52 +0530 Subject: [PATCH 10/13] complex issue --- ...e-user-add-single-user-detail.component.ts | 184 ++++++++++-------- 1 file changed, 103 insertions(+), 81 deletions(-) diff --git a/src/app/pages/manage-user/manage-user-add-single-user-detail/manage-user-add-single-user-detail.component.ts b/src/app/pages/manage-user/manage-user-add-single-user-detail/manage-user-add-single-user-detail.component.ts index 1fb4beb82..ca336598e 100644 --- a/src/app/pages/manage-user/manage-user-add-single-user-detail/manage-user-add-single-user-detail.component.ts +++ b/src/app/pages/manage-user/manage-user-add-single-user-detail/manage-user-add-single-user-detail.component.ts @@ -58,7 +58,7 @@ export class ManageUserAddSingleUserDetailComponent public idpStatus = environment.appSetting.hideIDP public approveRequiredRole: Role[]; public organisationDetails: any = {} - public pendingRoleDetails: any = [] + public pendingRoleDetails: any = [] public selectedApproveRequiredRole: any = [] public pendingRoledeleteDetails: any = [] public detailsData: any = [ @@ -70,6 +70,7 @@ export class ManageUserAddSingleUserDetailComponent public emailHaserror: boolean = false; public MFA_Enabled: any = false; ciiOrganisationId: string; + private selectedRoleIds: number[] = [] @ViewChildren('input') inputs!: QueryList; isInvalidDomain: boolean = false @@ -312,27 +313,27 @@ export class ManageUserAddSingleUserDetailComponent this.userProfileResponseInfo.detail.rolePermissionInfo.some( (rp) => rp.roleId == role.roleId ); - if(!this.isEdit){ - this.formGroup.addControl( - 'orgRoleControl_' + role.roleId, - this.formBuilder.control(userRole ? true : '') - ); - } else { - let PendinguserRole = this.pendingRoleDetails.some( - (pendingRole: any) => pendingRole.roleKey == role.roleKey - ); - this.formGroup.addControl( - 'orgRoleControl_' + role.roleId, - this.formBuilder.control(userRole ? true : PendinguserRole ? true : '') - ); - if(userRole == true){ - role.enabled = true - } - let filterRole = this.pendingRoleDetails.find((element: { roleKey: any; }) => element.roleKey == role.roleKey) - if (filterRole != undefined) { - role.pendingStatus = true - } + if (!this.isEdit) { + this.formGroup.addControl( + 'orgRoleControl_' + role.roleId, + this.formBuilder.control(userRole ? true : '') + ); + } else { + let PendinguserRole = this.pendingRoleDetails.some( + (pendingRole: any) => pendingRole.roleKey == role.roleKey + ); + this.formGroup.addControl( + 'orgRoleControl_' + role.roleId, + this.formBuilder.control(userRole ? true : PendinguserRole ? true : '') + ); + if (userRole == true) { + role.enabled = true } + let filterRole = this.pendingRoleDetails.find((element: { roleKey: any; }) => element.roleKey == role.roleKey) + if (filterRole != undefined) { + role.pendingStatus = true + } + } //Edit mode Determin Login user whether Admin/Normal user. if ( role.roleKey == 'ORG_ADMINISTRATOR' && @@ -450,38 +451,53 @@ export class ManageUserAddSingleUserDetailComponent getSelectedRoleIds(form: FormGroup) { - let selectedRoleIds: number[] = []; + this.selectedRoleIds = [] this.selectedApproveRequiredRole = [] const superAdminDomain = this.organisationDetails.detail.domainName.toLowerCase() const userDomain = this.formGroup.get('userName')?.value.split("@")[1].toLowerCase() this.orgRoles.map((role) => { if (form.get('orgRoleControl_' + role.roleId)?.value === true) { - if(superAdminDomain != userDomain){ - let filterRole = this.approveRequiredRole.find((element: { roleKey: any; }) => element.roleKey == role.roleKey) - if (filterRole === undefined) { - selectedRoleIds.push(role.roleId) - } else { - if(this.pendingRoleDetails.length != 0){ - let filterAlreadyExistRole = this.pendingRoleDetails.find((element: { roleKey: any; }) => element.roleKey == role.roleKey) - if(filterAlreadyExistRole.roleKey != role.roleKey){ - this.selectedApproveRequiredRole.push(role.roleId) - } - } else { - if(!role.enabled){ - this.selectedApproveRequiredRole.push(role.roleId) - } else { - selectedRoleIds.push(role.roleId) - } - } - } + if (superAdminDomain != userDomain) { + this.invalidDomainConfig(role) } else { - selectedRoleIds.push(role.roleId) + this.selectedRoleIds.push(role.roleId) } } }); - return selectedRoleIds; + return this.selectedRoleIds; + } + + private invalidDomainConfig(role: any) { + let filterRole = this.approveRequiredRole.find((element: { roleKey: any; }) => element.roleKey == role.roleKey) + if (filterRole === undefined) { + this.selectedRoleIds.push(role.roleId) + } else { + this.pendingRolecheck(role) + } + } + + private pendingRolecheck(role: any) { + if (this.pendingRoleDetails.length != 0) { + this.whenPendingRoleHavingLength(role) + } else { + this.whenPendingRoleNoLength(role) + } } + private whenPendingRoleHavingLength(role: any) { + let filterAlreadyExistRole = this.pendingRoleDetails.find((element: { roleKey: any; }) => element.roleKey == role.roleKey) + if (filterAlreadyExistRole.roleKey != role.roleKey) { + this.selectedApproveRequiredRole.push(role.roleId) + } + } + + private whenPendingRoleNoLength(role: any) { + if (!role.enabled) { + this.selectedApproveRequiredRole.push(role.roleId) + } else { + this.selectedRoleIds.push(role.roleId) + } + } private submitPendingApproveRole(): void { let selectedRolesDetails = { @@ -491,24 +507,26 @@ export class ManageUserAddSingleUserDetailComponent } } if (this.selectedApproveRequiredRole.length != 0 && this.isInvalidDomain) { - this.wrapperUserService.createPendingApproveRole(selectedRolesDetails).subscribe({ - next: (roleInfo: UserEditResponseInfo) => { - if (this.pendingRoledeleteDetails.length != 0) { - this.deleteApprovePendingRole() - } - }, - error: (err: any) => { - console.log(err) - }, - }); - } else { - if (this.pendingRoledeleteDetails.length != 0) { - this.deleteApprovePendingRole() - } + this.UpdatePendingApproveRole(selectedRolesDetails) + } else if (this.pendingRoledeleteDetails.length != 0) { + this.deleteApprovePendingRole() } } + private UpdatePendingApproveRole(selectedRolesDetails: any) { + this.wrapperUserService.createPendingApproveRole(selectedRolesDetails).subscribe({ + next: (roleInfo: UserEditResponseInfo) => { + if (this.pendingRoledeleteDetails.length != 0) { + this.deleteApprovePendingRole() + } + }, + error: (err: any) => { + console.log(err) + }, + }); + } + saveChanges(actionMode: string, form: FormGroup) { if (actionMode === "update") { this.updateUser(form); @@ -527,16 +545,16 @@ export class ManageUserAddSingleUserDetailComponent this.isInvalidDomain = true let matchRoles: any = [] const selectedRole: any = this.selectedApproveRequiredRole - this.orgRoles.forEach((allRole:Role)=>{ - this.approveRequiredRole.forEach((aRole:Role)=>{ - if(allRole.roleKey === aRole.roleKey){ - selectedRole.forEach((sRole: number)=>{ - if(allRole.roleId === sRole){ + this.orgRoles.forEach((allRole: Role) => { + this.approveRequiredRole.forEach((aRole: Role) => { + if (allRole.roleKey === aRole.roleKey) { + selectedRole.forEach((sRole: number) => { + if (allRole.roleId === sRole) { matchRoles.push(aRole) } }) } - }) + }) }) localStorage.setItem('user_approved_role', JSON.stringify(matchRoles)); } @@ -749,9 +767,9 @@ export class ManageUserAddSingleUserDetailComponent let data = { isEdit: false, groupId: groupId, - accessFrom:"users", - userEditStatus:this.isEdit, - isUserAccess:true + accessFrom: "users", + userEditStatus: this.isEdit, + isUserAccess: true }; this.router.navigateByUrl( 'manage-groups/view?data=' + JSON.stringify(data), @@ -762,10 +780,7 @@ export class ManageUserAddSingleUserDetailComponent onUserRoleChecked(obj: any, isChecked: boolean) { var roleKey = obj.roleKey; if (isChecked == true) { - if (roleKey == 'ORG_ADMINISTRATOR') { - this.formGroup.controls['mfaEnabled'].setValue(true); - this.isAutoDisableMFA = true; - } + this.setMfaStatus(roleKey) if (obj.pendingStatus === true) { this.setCheckedApprovedRequiredRole(obj) } @@ -779,21 +794,28 @@ export class ManageUserAddSingleUserDetailComponent let filterRole = this.pendingRoledeleteDetails.find((element: number) => element == obj.roleId) if (filterRole === undefined) { this.pendingRoledeleteDetails.push(obj.roleId) - } + } } } } - - private setCheckedApprovedRequiredRole(obj:any){ - let filterRole = this.pendingRoledeleteDetails.find((element: number) => element == obj.roleId) - if (filterRole != undefined) { - this.pendingRoledeleteDetails.forEach((pRole:any,index:any)=>{ - if(pRole === obj.roleId){ - this.pendingRoledeleteDetails.splice(index,1) - } - }) - } - } + + private setMfaStatus(roleKey: any) { + if (roleKey == 'ORG_ADMINISTRATOR') { + this.formGroup.controls['mfaEnabled'].setValue(true); + this.isAutoDisableMFA = true; + } + } + + private setCheckedApprovedRequiredRole(obj: any) { + let filterRole = this.pendingRoledeleteDetails.find((element: number) => element == obj.roleId) + if (filterRole != undefined) { + this.pendingRoledeleteDetails.forEach((pRole: any, index: any) => { + if (pRole === obj.roleId) { + this.pendingRoledeleteDetails.splice(index, 1) + } + }) + } + } public ResetAdditionalSecurity(): void { if (this.MFA_Enabled) { From a6fa3d12a301e7f7af928893123463536442cc18 Mon Sep 17 00:00:00 2001 From: ajithmuthukumar-bc Date: Fri, 20 Jan 2023 01:08:54 +0530 Subject: [PATCH 11/13] complex --- ...e-user-add-single-user-detail.component.ts | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/app/pages/manage-user/manage-user-add-single-user-detail/manage-user-add-single-user-detail.component.ts b/src/app/pages/manage-user/manage-user-add-single-user-detail/manage-user-add-single-user-detail.component.ts index ca336598e..748e71774 100644 --- a/src/app/pages/manage-user/manage-user-add-single-user-detail/manage-user-add-single-user-detail.component.ts +++ b/src/app/pages/manage-user/manage-user-add-single-user-detail/manage-user-add-single-user-detail.component.ts @@ -780,33 +780,25 @@ export class ManageUserAddSingleUserDetailComponent onUserRoleChecked(obj: any, isChecked: boolean) { var roleKey = obj.roleKey; if (isChecked == true) { - this.setMfaStatus(roleKey) + this.setMfaStatus(roleKey,true) if (obj.pendingStatus === true) { - this.setCheckedApprovedRequiredRole(obj) + this.removePendingRole(obj) } } else if (isChecked == false) { - if (roleKey == 'ORG_ADMINISTRATOR') { - this.formGroup.controls['mfaEnabled'].setValue(false); - this.isAutoDisableMFA = false; - } - if (obj.pendingStatus === true) { - let filterRole = this.pendingRoledeleteDetails.find((element: number) => element == obj.roleId) - if (filterRole === undefined) { - this.pendingRoledeleteDetails.push(obj.roleId) - } - } + this.setMfaStatus(roleKey,false) + this.addPendingRole(obj) } } - private setMfaStatus(roleKey: any) { + private setMfaStatus(roleKey: any,status:boolean) { if (roleKey == 'ORG_ADMINISTRATOR') { - this.formGroup.controls['mfaEnabled'].setValue(true); - this.isAutoDisableMFA = true; + this.formGroup.controls['mfaEnabled'].setValue(status); + this.isAutoDisableMFA = status; } } - private setCheckedApprovedRequiredRole(obj: any) { + private removePendingRole(obj: any) { let filterRole = this.pendingRoledeleteDetails.find((element: number) => element == obj.roleId) if (filterRole != undefined) { this.pendingRoledeleteDetails.forEach((pRole: any, index: any) => { @@ -817,6 +809,15 @@ export class ManageUserAddSingleUserDetailComponent } } + private addPendingRole(obj:any){ + if (obj.pendingStatus === true) { + let filterRole = this.pendingRoledeleteDetails.find((element: number) => element == obj.roleId) + if (filterRole === undefined) { + this.pendingRoledeleteDetails.push(obj.roleId) + } + } + } + public ResetAdditionalSecurity(): void { if (this.MFA_Enabled) { let data = { From a657ca64f33727b926387f52aee9133eb6ae35b9 Mon Sep 17 00:00:00 2001 From: ajithmuthukumar-bc Date: Fri, 20 Jan 2023 01:13:53 +0530 Subject: [PATCH 12/13] api complex --- src/app/services/wrapper/wrapper-org--group-service.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/app/services/wrapper/wrapper-org--group-service.ts b/src/app/services/wrapper/wrapper-org--group-service.ts index 00e1087e7..7128fbeb2 100644 --- a/src/app/services/wrapper/wrapper-org--group-service.ts +++ b/src/app/services/wrapper/wrapper-org--group-service.ts @@ -140,11 +140,9 @@ export class WrapperOrganisationGroupService { getOrganisationApprovalRequiredRoles(): Observable { const url = `${this.configURl}/approve/roles`; - return this.http.get(url).pipe( - map((data: Role[]) => { - return data - }), catchError(error => { - return throwError(error); + return this.http.get(url).pipe(map((data: Role[]) => {return data } ), + catchError(err => { + return throwError(err); }) ); } From 3c79639ea9268e666f91683d299ecf66c01ec369 Mon Sep 17 00:00:00 2001 From: ajithmuthukumar-bc Date: Fri, 20 Jan 2023 01:21:51 +0530 Subject: [PATCH 13/13] changes function name --- src/app/pages/user-profile/user-profile-component.html | 2 +- src/app/pages/user-profile/user-profile-component.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/pages/user-profile/user-profile-component.html b/src/app/pages/user-profile/user-profile-component.html index f9836dea2..6d3e445a1 100644 --- a/src/app/pages/user-profile/user-profile-component.html +++ b/src/app/pages/user-profile/user-profile-component.html @@ -28,7 +28,7 @@

'ERROR_LAST_NAME' | translate }}
  • - {{ 'ENTER_NAME_WITHOUT_NUM_SPECIAL' | translate }} + {{ 'ENTER_NAME_WITHOUT_NUM_SPECIAL' | translate }}
  • diff --git a/src/app/pages/user-profile/user-profile-component.ts b/src/app/pages/user-profile/user-profile-component.ts index 3cf86f7c3..2eb34c412 100644 --- a/src/app/pages/user-profile/user-profile-component.ts +++ b/src/app/pages/user-profile/user-profile-component.ts @@ -601,7 +601,7 @@ export class UserProfileComponent extends FormBaseComponent implements OnInit { } - public customFocum(): void { + public focusUserProfileInput(): void { if ( this.formGroup.controls['firstName'].invalid && this.formGroup.controls['lastName'].invalid