integrated the API to save permissions for a specific user

aconnect-UX/1717
atif118-mfsys 1 month ago
parent 1867e11502
commit 7ba6a8b65f

@ -130,8 +130,8 @@ export class UserPermissionsComponent {
const params = new HttpParams().set('userId', this.permission.get('userCode')?.value); const params = new HttpParams().set('userId', this.permission.get('userCode')?.value);
this.httpService.requestGET(URIKey.USER_GET_PERMISSIONS, params).subscribe((response: any) => { this.httpService.requestGET(URIKey.USER_GET_PERMISSIONS, params).subscribe((response: any) => {
if (!(response instanceof HttpErrorResponse)) { if (!(response instanceof HttpErrorResponse)) {
if (response.permission) { if (response.permissions) {
this.updatePermissions(JSON.parse(response.permission), this.permissions); this.updatePermissions(JSON.parse(response.permissions), this.permissions);
} }
else { else {
this.defaultPermissions().subscribe((data: PermissionNode[]) => { this.defaultPermissions().subscribe((data: PermissionNode[]) => {
@ -144,17 +144,18 @@ export class UserPermissionsComponent {
savePermissions() { savePermissions() {
let payload = { let payload = {
porOrgacode: this.credentialService.getPorOrgacode(), // porOrgacode: this.credentialService.getPorOrgacode(),
userId: this.permission.get('userCode')?.value, userId: this.permission.get('userCode')?.value,
permission: JSON.stringify(this.permissions) permissions: JSON.stringify(this.permissions)
} }
// this.httpService.requestPATCH(URIKey.USER_SAVE_PERMISSION, payload).subscribe((response: any) => { this.httpService.requestPUT(URIKey.USER_SAVE_PERMISSION, payload).subscribe((response: any) => {
// if (!(response instanceof HttpErrorResponse)) { if (!(response instanceof HttpErrorResponse)) {
// this.i18nService.success(SuccessMessages.SAVED_SUCESSFULLY, []); this.i18nService.success(SuccessMessages.SAVED_SUCESSFULLY, []);
// this.permission.reset(); this.permission.reset();
// this.showPermissions = false; this.permission.get('userCode')?.setValue("");
// } this.showPermissions = false;
// }) }
})
} }
updatePermissions(savedPermissions: PermissionNode[], existingPermissions: PermissionNode[]): void { updatePermissions(savedPermissions: PermissionNode[], existingPermissions: PermissionNode[]): void {

@ -46,6 +46,11 @@
"Id" : "ENTITY_USER_GET_PERMISSIONS", "Id" : "ENTITY_USER_GET_PERMISSIONS",
"URI": "/user/getPermissions", "URI": "/user/getPermissions",
"UUID": "USER_GET_PERMISSIONS" "UUID": "USER_GET_PERMISSIONS"
},
{
"Id" : "ENTITY_USER_SAVE_PERMISSION",
"URI": "/user/updatePermissions",
"UUID": "USER_SAVE_PERMISSION"
} }
] ]
} }

Loading…
Cancel
Save