From d0d31a2aa70c02bba90b84bef4134fcf48a77ef0 Mon Sep 17 00:00:00 2001 From: Nandini Achutha Date: Mon, 10 Jun 2024 13:07:43 +0530 Subject: [PATCH 1/4] Added sort for all users listing & error message if its null --- .../user-cards/user-card.component.ts | 14 +++++-- .../routes/users-view/users-view.component.ts | 40 +++++++++---------- .../routes/users/services/users.service.ts | 3 ++ 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/project/ws/app/src/lib/routes/home/components/user-cards/user-card.component.ts b/project/ws/app/src/lib/routes/home/components/user-cards/user-card.component.ts index a4e534099..d18abb01b 100644 --- a/project/ws/app/src/lib/routes/home/components/user-cards/user-card.component.ts +++ b/project/ws/app/src/lib/routes/home/components/user-cards/user-card.component.ts @@ -109,9 +109,9 @@ export class UserCardComponent implements OnInit, OnChanges { today = new Date() constructor(private usersSvc: UsersService, private roleservice: RolesService, - private dialog: MatDialog, private approvalSvc: ApprovalsService, - private route: ActivatedRoute, private snackBar: MatSnackBar, - private events: EventService, private datePipe: DatePipe) { + private dialog: MatDialog, private approvalSvc: ApprovalsService, + private route: ActivatedRoute, private snackBar: MatSnackBar, + private events: EventService, private datePipe: DatePipe) { this.updateUserDataForm = new FormGroup({ designation: new FormControl('', []), group: new FormControl('', [Validators.required]), @@ -680,7 +680,13 @@ export class UserCardComponent implements OnInit, OnChanges { }, // tslint:disable-next-line: align (err: { error: any }) => { - this.openSnackbar(err.error.params.errmsg) + if (err.error.params.errmsg && err.error.params.errmsg !== 'null') { + this.openSnackbar(err.error.params.errmsg) + panel.close() + } else { + this.openSnackbar('Error in updating user') + panel.close() + } }) } } diff --git a/project/ws/app/src/lib/routes/home/routes/users-view/users-view.component.ts b/project/ws/app/src/lib/routes/home/routes/users-view/users-view.component.ts index bfa2cdcae..c61e03726 100644 --- a/project/ws/app/src/lib/routes/home/routes/users-view/users-view.component.ts +++ b/project/ws/app/src/lib/routes/home/routes/users-view/users-view.component.ts @@ -204,11 +204,11 @@ export class UsersViewComponent implements OnInit, OnDestroy { this.activeUsersData = allusersData.content this.activeUsersData = this.activeUsersData.filter((wf: any) => wf.profileDetails.profileStatus !== 'NOT-MY-USER') this.activeUsersDataCount = allusersData.count - const i = this.activeUsersData.findIndex((wf: any) => wf.userId === this.currentUser) - if (i > -1) { - this.activeUsersData.splice(i, 1) - allusersData.count = allusersData.count - 1 - } + // const i = this.activeUsersData.findIndex((wf: any) => wf.userId === this.currentUser) + // if (i > -1) { + // this.activeUsersData.splice(i, 1) + // allusersData.count = allusersData.count - 1 + // } if (this.notmyuserUsersDataCount && allusersData.count > this.notmyuserUsersDataCount) { this.activeUsersDataCount = allusersData.count - this.notmyuserUsersDataCount @@ -227,13 +227,13 @@ export class UsersViewComponent implements OnInit, OnDestroy { this.verifiedUsersData = allusersData.content this.verifiedUsersDataCount = data.result.response.count - if (this.currentUserStatus === 'VERIFIED') { - const i = this.verifiedUsersData.findIndex((wf: any) => wf.userId === this.currentUser) - if (i > -1) { - this.verifiedUsersData.splice(i, 1) - this.verifiedUsersDataCount = this.verifiedUsersDataCount ? this.verifiedUsersDataCount - 1 : this.verifiedUsersDataCount - } - } + // if (this.currentUserStatus === 'VERIFIED') { + // const i = this.verifiedUsersData.findIndex((wf: any) => wf.userId === this.currentUser) + // if (i > -1) { + // this.verifiedUsersData.splice(i, 1) + // this.verifiedUsersDataCount = this.verifiedUsersDataCount ? this.verifiedUsersDataCount - 1 : this.verifiedUsersDataCount + // } + // } }) } @@ -249,14 +249,14 @@ export class UsersViewComponent implements OnInit, OnDestroy { this.nonverifiedUsersData = allusersData.content this.nonverifiedUsersDataCount = data.result.response.count - if (this.currentUserStatus === 'NOT-VERIFIED') { - const i = this.nonverifiedUsersData.findIndex((wf: any) => wf.userId === this.currentUser) - if (i > -1) { - this.nonverifiedUsersData.splice(i, 1) - this.nonverifiedUsersDataCount = this.nonverifiedUsersDataCount ? - this.nonverifiedUsersDataCount - 1 : this.nonverifiedUsersDataCount - } - } + // if (this.currentUserStatus === 'NOT-VERIFIED') { + // const i = this.nonverifiedUsersData.findIndex((wf: any) => wf.userId === this.currentUser) + // if (i > -1) { + // this.nonverifiedUsersData.splice(i, 1) + // this.nonverifiedUsersDataCount = this.nonverifiedUsersDataCount ? + // this.nonverifiedUsersDataCount - 1 : this.nonverifiedUsersDataCount + // } + // } }) } diff --git a/project/ws/app/src/lib/routes/users/services/users.service.ts b/project/ws/app/src/lib/routes/users/services/users.service.ts index 084002809..8dabc0ad2 100644 --- a/project/ws/app/src/lib/routes/users/services/users.service.ts +++ b/project/ws/app/src/lib/routes/users/services/users.service.ts @@ -127,6 +127,9 @@ export class UsersService { limit: pageLimit, offset: offsetNum, query: searchText, + sort_by: { + firstName: 'asc', + }, }, } return this.http.post(`${API_END_POINTS.GET_ALL_USERS}`, reqBody) From 87c72a02e055073937f27823cc76a9131d8ffb05 Mon Sep 17 00:00:00 2001 From: Nandini Achutha Date: Mon, 10 Jun 2024 15:36:41 +0530 Subject: [PATCH 2/4] Fixed 4722 --- .../components/user-cards/user-card.component.html | 4 ++-- .../single-user-creation.component.ts | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/project/ws/app/src/lib/routes/home/components/user-cards/user-card.component.html b/project/ws/app/src/lib/routes/home/components/user-cards/user-card.component.html index c050a6068..5114feb53 100644 --- a/project/ws/app/src/lib/routes/home/components/user-cards/user-card.component.html +++ b/project/ws/app/src/lib/routes/home/components/user-cards/user-card.component.html @@ -306,8 +306,8 @@ + [matChipInputSeparatorKeyCodes]="separatorKeysCodes" (matChipInputTokenEnd)="addActivity($event)" + maxlength="100" />
diff --git a/project/ws/app/src/lib/routes/home/routes/users-view/single-user-creation/single-user-creation.component.ts b/project/ws/app/src/lib/routes/home/routes/users-view/single-user-creation/single-user-creation.component.ts index a124fcceb..38bf046bd 100644 --- a/project/ws/app/src/lib/routes/home/routes/users-view/single-user-creation/single-user-creation.component.ts +++ b/project/ws/app/src/lib/routes/home/routes/users-view/single-user-creation/single-user-creation.component.ts @@ -137,7 +137,7 @@ export class SingleUserCreationComponent implements OnInit, AfterViewInit, OnDes .subscribe((_res: any) => { this.masterData['designation'] = _res.responseData this.masterData['designationBackup'] = _res.responseData - }, (_err: HttpErrorResponse) => { + }, (_err: HttpErrorResponse) => { if (!_err.ok) { this.matSnackBar.open('Unable to fetch designation details, please try again later!') } @@ -150,7 +150,7 @@ export class SingleUserCreationComponent implements OnInit, AfterViewInit, OnDes .subscribe((res: any) => { this.masterData['language'] = res.languages this.masterData['languageBackup'] = res.languages - }, (_err: HttpErrorResponse) => { + }, (_err: HttpErrorResponse) => { if (!_err.ok) { this.matSnackBar.open('Unable to fetch master language details, please try again later!') } @@ -162,7 +162,7 @@ export class SingleUserCreationComponent implements OnInit, AfterViewInit, OnDes .pipe(takeUntil(this.destroySubject$)) .subscribe((res: any) => { this.masterData['group'] = res.result.response - }, (_err: HttpErrorResponse) => { + }, (_err: HttpErrorResponse) => { if (!_err.ok) { this.matSnackBar.open('Unable to fetch group data, please try again later!') } @@ -180,7 +180,7 @@ export class SingleUserCreationComponent implements OnInit, AfterViewInit, OnDes this.masterData['mdoRoles'] = mdoArray.roles } } - }, (_err: HttpErrorResponse) => { + }, (_err: HttpErrorResponse) => { if (!_err.ok) { this.matSnackBar.open('Unable to fetch roles list, please try again later!') } @@ -220,7 +220,7 @@ export class SingleUserCreationComponent implements OnInit, AfterViewInit, OnDes handleValidTags(event: any): any { const charCode = event.charCode // tslint:disable-next-line - return ((charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123) || charCode == 8 || charCode == 32 || (charCode >= 48 && charCode <= 57)) + return ((charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123) || charCode == 8 || charCode == 32) } handleRemoveTag(tag: any): void { @@ -268,7 +268,7 @@ export class SingleUserCreationComponent implements OnInit, AfterViewInit, OnDes .subscribe((_res: any) => { this.matSnackBar.open('User created successfully!') this.handleFormClear() - }, (_err: HttpErrorResponse) => { + }, (_err: HttpErrorResponse) => { if (!_err.ok) { this.matSnackBar.open(_.get(_err, 'error.params.errmsg') || 'Unable to create user, please try again later!') } From d7d0b1f893cc1e3dfb68e4143ae566d59cc72609 Mon Sep 17 00:00:00 2001 From: Nandini Achutha Date: Mon, 10 Jun 2024 16:51:07 +0530 Subject: [PATCH 3/4] Fixed lint issue --- .../home/components/user-cards/user-card.component.ts | 6 +++--- .../single-user-creation.component.ts | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/project/ws/app/src/lib/routes/home/components/user-cards/user-card.component.ts b/project/ws/app/src/lib/routes/home/components/user-cards/user-card.component.ts index d18abb01b..a08eb61f7 100644 --- a/project/ws/app/src/lib/routes/home/components/user-cards/user-card.component.ts +++ b/project/ws/app/src/lib/routes/home/components/user-cards/user-card.component.ts @@ -109,9 +109,9 @@ export class UserCardComponent implements OnInit, OnChanges { today = new Date() constructor(private usersSvc: UsersService, private roleservice: RolesService, - private dialog: MatDialog, private approvalSvc: ApprovalsService, - private route: ActivatedRoute, private snackBar: MatSnackBar, - private events: EventService, private datePipe: DatePipe) { + private dialog: MatDialog, private approvalSvc: ApprovalsService, + private route: ActivatedRoute, private snackBar: MatSnackBar, + private events: EventService, private datePipe: DatePipe) { this.updateUserDataForm = new FormGroup({ designation: new FormControl('', []), group: new FormControl('', [Validators.required]), diff --git a/project/ws/app/src/lib/routes/home/routes/users-view/single-user-creation/single-user-creation.component.ts b/project/ws/app/src/lib/routes/home/routes/users-view/single-user-creation/single-user-creation.component.ts index 38bf046bd..ecba4112c 100644 --- a/project/ws/app/src/lib/routes/home/routes/users-view/single-user-creation/single-user-creation.component.ts +++ b/project/ws/app/src/lib/routes/home/routes/users-view/single-user-creation/single-user-creation.component.ts @@ -137,7 +137,7 @@ export class SingleUserCreationComponent implements OnInit, AfterViewInit, OnDes .subscribe((_res: any) => { this.masterData['designation'] = _res.responseData this.masterData['designationBackup'] = _res.responseData - }, (_err: HttpErrorResponse) => { + }, (_err: HttpErrorResponse) => { if (!_err.ok) { this.matSnackBar.open('Unable to fetch designation details, please try again later!') } @@ -150,7 +150,7 @@ export class SingleUserCreationComponent implements OnInit, AfterViewInit, OnDes .subscribe((res: any) => { this.masterData['language'] = res.languages this.masterData['languageBackup'] = res.languages - }, (_err: HttpErrorResponse) => { + }, (_err: HttpErrorResponse) => { if (!_err.ok) { this.matSnackBar.open('Unable to fetch master language details, please try again later!') } @@ -162,7 +162,7 @@ export class SingleUserCreationComponent implements OnInit, AfterViewInit, OnDes .pipe(takeUntil(this.destroySubject$)) .subscribe((res: any) => { this.masterData['group'] = res.result.response - }, (_err: HttpErrorResponse) => { + }, (_err: HttpErrorResponse) => { if (!_err.ok) { this.matSnackBar.open('Unable to fetch group data, please try again later!') } @@ -180,7 +180,7 @@ export class SingleUserCreationComponent implements OnInit, AfterViewInit, OnDes this.masterData['mdoRoles'] = mdoArray.roles } } - }, (_err: HttpErrorResponse) => { + }, (_err: HttpErrorResponse) => { if (!_err.ok) { this.matSnackBar.open('Unable to fetch roles list, please try again later!') } @@ -268,7 +268,7 @@ export class SingleUserCreationComponent implements OnInit, AfterViewInit, OnDes .subscribe((_res: any) => { this.matSnackBar.open('User created successfully!') this.handleFormClear() - }, (_err: HttpErrorResponse) => { + }, (_err: HttpErrorResponse) => { if (!_err.ok) { this.matSnackBar.open(_.get(_err, 'error.params.errmsg') || 'Unable to create user, please try again later!') } From d13ec0839317fb0635a86beff16c7c2820b6caa7 Mon Sep 17 00:00:00 2001 From: Nandini Achutha Date: Mon, 10 Jun 2024 17:18:28 +0530 Subject: [PATCH 4/4] Fixed 4706 --- .../single-user-creation/single-user-creation.component.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/project/ws/app/src/lib/routes/home/routes/users-view/single-user-creation/single-user-creation.component.ts b/project/ws/app/src/lib/routes/home/routes/users-view/single-user-creation/single-user-creation.component.ts index ecba4112c..7248f5547 100644 --- a/project/ws/app/src/lib/routes/home/routes/users-view/single-user-creation/single-user-creation.component.ts +++ b/project/ws/app/src/lib/routes/home/routes/users-view/single-user-creation/single-user-creation.component.ts @@ -26,7 +26,7 @@ export const MY_FORMATS = { }, } -const EMAIL_PATTERN = /^[a-zA-Z0-9](\.?[a-zA-Z0-9_]+)*@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/ +// const EMAIL_PATTERN = /^[a-zA-Z0-9](\.?[a-zA-Z0-9_]+)*@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/ const MOBILE_PATTERN = /^[0]?[6789]\d{9}$/ const PIN_CODE_PATTERN = /^[1-9][0-9]{5}$/ @@ -49,8 +49,9 @@ export class SingleUserCreationComponent implements OnInit, AfterViewInit, OnDes rolesArr: string[] = [] fullProfile: any namePatern = `^[a-zA-Z\\s\\']{1,50}$` + emailRegix = `^[\\w\-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$` userCreationForm = this.formBuilder.group({ - email: new FormControl('', [Validators.required, Validators.pattern(EMAIL_PATTERN)]), + email: new FormControl('', [Validators.required, Validators.pattern(this.emailRegix)]), firstName: new FormControl('', [Validators.required, Validators.pattern(this.namePatern)]), phone: new FormControl('', [Validators.required, Validators.pattern(MOBILE_PATTERN), Validators.minLength(10)]), channel: new FormControl(''),