-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8b2356
commit b59e42b
Showing
2 changed files
with
126 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
200 changes: 105 additions & 95 deletions
200
src/app/pages/manage-user/manage-user-profiles/manage-user-profiles-component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,117 @@ | ||
import { Component } from "@angular/core"; | ||
import { OnInit } from "@angular/core"; | ||
import { Store } from "@ngrx/store"; | ||
import { Component } from '@angular/core'; | ||
import { OnInit } from '@angular/core'; | ||
import { Store } from '@ngrx/store'; | ||
import { ViewportScroller } from '@angular/common'; | ||
import { BaseComponent } from "src/app/components/base/base.component"; | ||
import { UIState } from "src/app/store/ui.states"; | ||
import { FormBuilder, FormGroup, Validators } from "@angular/forms"; | ||
import { slideAnimation } from "src/app/animations/slide.animation"; | ||
import { User, UserGroup, UserListInfo, UserListResponse, UserProfileRequestInfo } from "src/app/models/user"; | ||
import { WrapperUserService } from "src/app/services/wrapper/wrapper-user.service"; | ||
import { WrapperUserContactService } from "src/app/services/wrapper/wrapper-user-contact.service"; | ||
import { ContactPoint, UserContactInfoList } from "src/app/models/contactInfo"; | ||
import { Router } from "@angular/router"; | ||
import { OperationEnum } from "src/app/constants/enum"; | ||
import { ScrollHelper } from "src/app/services/helper/scroll-helper.services"; | ||
import { WrapperOrganisationService } from "src/app/services/wrapper/wrapper-org-service"; | ||
import { environment } from "src/environments/environment"; | ||
import { AuditLoggerService } from "src/app/services/postgres/logger.service"; | ||
import { SessionStorageKey } from "src/app/constants/constant"; | ||
import { BaseComponent } from 'src/app/components/base/base.component'; | ||
import { UIState } from 'src/app/store/ui.states'; | ||
import { slideAnimation } from 'src/app/animations/slide.animation'; | ||
import {UserListInfo,UserListResponse} from 'src/app/models/user'; | ||
import { Router } from '@angular/router'; | ||
import { ScrollHelper } from 'src/app/services/helper/scroll-helper.services'; | ||
import { WrapperOrganisationService } from 'src/app/services/wrapper/wrapper-org-service'; | ||
import { environment } from 'src/environments/environment'; | ||
import { AuditLoggerService } from 'src/app/services/postgres/logger.service'; | ||
import { SessionStorageKey } from 'src/app/constants/constant'; | ||
|
||
@Component({ | ||
selector: 'app-manage-user-profiles', | ||
templateUrl: './manage-user-profiles-component.html', | ||
styleUrls: ['./manage-user-profiles-component.scss'], | ||
animations: [ | ||
slideAnimation({ | ||
close: { 'transform': 'translateX(12.5rem)' }, | ||
open: { left: '-12.5rem' } | ||
}) | ||
] | ||
selector: 'app-manage-user-profiles', | ||
templateUrl: './manage-user-profiles-component.html', | ||
styleUrls: ['./manage-user-profiles-component.scss'], | ||
animations: [ | ||
slideAnimation({ | ||
close: { transform: 'translateX(12.5rem)' }, | ||
open: { left: '-12.5rem' }, | ||
}), | ||
], | ||
}) | ||
|
||
export class ManageUserProfilesComponent extends BaseComponent implements OnInit { | ||
userList: UserListResponse; | ||
organisationId: string; | ||
searchingUserName: string = ""; | ||
currentPage: number = 1; | ||
pageCount: number = 0; | ||
pageSize: number = environment.listPageSize; | ||
usersTableHeaders = ['NAME', 'EMAIL']; | ||
usersColumnsToDisplay = ['name', 'userName']; | ||
searchSumbited:boolean=false; | ||
constructor(private wrapperOrganisationService: WrapperOrganisationService, | ||
protected uiStore: Store<UIState>, private router: Router, protected viewportScroller: ViewportScroller, protected scrollHelper: ScrollHelper, | ||
private auditLogService: AuditLoggerService) { | ||
super(uiStore, viewportScroller, scrollHelper); | ||
this.organisationId = localStorage.getItem('cii_organisation_id') || ''; | ||
this.userList = { | ||
currentPage: this.currentPage, | ||
pageCount: 0, | ||
rowCount: 0, | ||
organisationId: this.organisationId, | ||
userList: [] | ||
} | ||
sessionStorage.removeItem(SessionStorageKey.ManageUserUserName); | ||
sessionStorage.removeItem(SessionStorageKey.OperationSuccessUserName); | ||
} | ||
public userList: UserListResponse; | ||
private organisationId: string; | ||
public searchingUserName: string = ''; | ||
public currentPage: number = 1; | ||
public pageCount: number = 0; | ||
public pageSize: number = environment.listPageSize; | ||
public usersTableHeaders = ['NAME', 'EMAIL']; | ||
public usersColumnsToDisplay = ['name', 'userName']; | ||
public searchSumbited: boolean = false; | ||
|
||
constructor( | ||
private wrapperOrganisationService: WrapperOrganisationService, | ||
protected uiStore: Store<UIState>, | ||
private router: Router, | ||
protected viewportScroller: ViewportScroller, | ||
protected scrollHelper: ScrollHelper, | ||
private auditLogService: AuditLoggerService | ||
) { | ||
super(uiStore, viewportScroller, scrollHelper); | ||
this.organisationId = localStorage.getItem('cii_organisation_id') || ''; | ||
this.userList = { | ||
currentPage: this.currentPage, | ||
pageCount: 0, | ||
rowCount: 0, | ||
organisationId: this.organisationId, | ||
userList: [], | ||
}; | ||
sessionStorage.removeItem(SessionStorageKey.ManageUserUserName); | ||
sessionStorage.removeItem(SessionStorageKey.OperationSuccessUserName); | ||
} | ||
|
||
async ngOnInit() { | ||
await this.auditLogService.createLog({ | ||
eventName: "Access", applicationName: "Manage-user-account", | ||
referenceData: `UI-Log` | ||
}).toPromise(); | ||
this.getOrganisationUsers(); | ||
} | ||
async ngOnInit() { | ||
await this.auditLogService | ||
.createLog({ | ||
eventName: 'Access', | ||
applicationName: 'Manage-user-account', | ||
referenceData: `UI-Log`, | ||
}) | ||
.toPromise(); | ||
this.getOrganisationUsers(); | ||
} | ||
|
||
getOrganisationUsers() { | ||
this.wrapperOrganisationService.getUsers(this.organisationId, this.searchingUserName, this.currentPage, this.pageSize).subscribe({ | ||
next: (userListResponse: UserListResponse) => { | ||
if (userListResponse != null) { | ||
this.userList = userListResponse; | ||
this.pageCount = this.userList.pageCount; | ||
} | ||
}, | ||
error: (error: any) => { | ||
} | ||
}); | ||
} | ||
private getOrganisationUsers(): void { | ||
this.wrapperOrganisationService.getUsers(this.organisationId,this.searchingUserName,this.currentPage,this.pageSize) | ||
.subscribe({ | ||
next: (userListResponse: UserListResponse) => { | ||
if (userListResponse != null) { | ||
this.userList = userListResponse; | ||
this.pageCount = this.userList.pageCount; | ||
} | ||
}, | ||
error: (error: any) => {}, | ||
}); | ||
} | ||
|
||
onAddClick() { | ||
this.router.navigateByUrl("manage-users/add-user-selection"); | ||
} | ||
public onAddClick(): void { | ||
this.router.navigateByUrl('manage-users/add-user/details'); | ||
} | ||
|
||
searchTextChanged(event: any) { | ||
this.searchingUserName = event.target.value; | ||
} | ||
private searchTextChanged(event: any) { | ||
this.searchingUserName = event.target.value; | ||
} | ||
|
||
onSearchClick() { | ||
this.searchSumbited=true | ||
this.currentPage = 1; | ||
this.getOrganisationUsers(); | ||
} | ||
public onSearchClick(): void { | ||
this.searchSumbited = true; | ||
this.currentPage = 1; | ||
this.getOrganisationUsers(); | ||
} | ||
|
||
setPage(pageNumber: any) { | ||
this.currentPage = pageNumber; | ||
this.getOrganisationUsers(); | ||
} | ||
public setPage(pageNumber: any): void { | ||
this.currentPage = pageNumber; | ||
this.getOrganisationUsers(); | ||
} | ||
|
||
onEditRow(dataRow: UserListInfo) { | ||
console.log(dataRow); | ||
let data = { | ||
'isEdit': true, | ||
'rowData':dataRow.userName | ||
}; | ||
sessionStorage.setItem(SessionStorageKey.ManageUserUserName, dataRow.userName); | ||
this.router.navigateByUrl('manage-users/add-user/details?data=' + btoa(JSON.stringify(data))); | ||
} | ||
} | ||
public onEditRow(dataRow: UserListInfo): void { | ||
console.log(dataRow); | ||
let data = { | ||
isEdit: true, | ||
rowData: dataRow.userName, | ||
}; | ||
sessionStorage.setItem( | ||
SessionStorageKey.ManageUserUserName, | ||
dataRow.userName | ||
); | ||
this.router.navigateByUrl( | ||
'manage-users/add-user/details?data=' + btoa(JSON.stringify(data)) | ||
); | ||
} | ||
} |