integrated the API to save permissions for a specific user #21

Merged
naeem.ullah merged 1 commits from aconnect-UX/1717 into dev-pending-09-12-2025 4 weeks ago

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

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

Loading…
Cancel
Save