users can now be deleted in the security screen

This commit is contained in:
Dragos 2021-05-13 11:55:32 +03:00
parent 907e274721
commit 129be42fdd
4 changed files with 36 additions and 2 deletions

Binary file not shown.

Binary file not shown.

View File

@ -207,7 +207,7 @@
</li> </li>
<li class="dropdown-divider"></li> <li class="dropdown-divider"></li>
<li role="menuitem"> <li role="menuitem">
<button class="dropdown-item"> <button class="dropdown-item" (click)="deleteUser(user)">
<fa-icon [fixedWidth]="true" icon="trash"></fa-icon> <fa-icon [fixedWidth]="true" icon="trash"></fa-icon>
{{ 'security.deleteUser' | translate }} {{ 'security.deleteUser' | translate }}
</button> </button>

View File

@ -167,6 +167,40 @@ export class SecurityComponent implements OnInit, OnDestroy
}); });
} }
// ----------------------------------------------------------------------------------------------------------------
deleteUser(user: User)
{
const modalConfig = {
ignoreBackdropClick: true,
keyboard: false,
animated: true,
initialState: {
prompt: `Are you sure you wish to permanently delete the "${user.login}" user?`,
confirmButtonText: 'Yes, delete this user',
declineButtonText: 'No, keep it',
confirmByDefault: false
}
};
const modalRef = this.modalService.show(ConfirmationDialogComponent, modalConfig);
modalRef.content.confirm.pipe(
first(),
switchMap(() => this.securityService.removeUser(user))
)
.subscribe(() =>
{
const index = this.users.findIndex(p => p.id === user.id);
if (index >= 0)
this.users.splice(index, 1);
this.toastr.info(`The "${user.login}" user has been succesfuly removed`);
}, err =>
{
const errorDetails = err.error?.message ? `(${err.error.message})` : '';
this.toastr.error(`Faild to remove the "${user.login}" role (${errorDetails})`);
});
}
// ---------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------
showRoleEditor(role?: Role) showRoleEditor(role?: Role)
{ {