userprivileges.component.html 3.81 KiB
<div style="padding-bottom: 15px;" class="background-section">
<h4 style="font-size:15px; font-weight: bold" >{{'USER_PRIVILEGES.HEADER' | translate}}</h4>
<div class="panel-body">
<div style="margin-bottom: 3rem" *ngIf="isModeAllowed(ComponentMode.CREATE) && user != null && user.username !== authService.getUsername()"> <!-- user should not be able to change his roles -->
<form *ngIf="user" [formGroup]="newPrivilegeForm" (submit)="add()" class="form-inline row">
<div *ngIf="domainId" class="form-group col-lg-3" >
<label style="margin-right:10px" for="domainId" >{{'USER_PRIVILEGES.DOMAIN' | translate}}:</label>
<select class="form-control" [formGroup]="newPrivilegeForm"
id="domainId" name="domainId" formControlName="domainId" style="min-width: 170px"
(ngModelChange)="clearSelectedRole()">
<option *ngFor="let domain of domains" [value]="domain.id">{{domain.name}}</option>
</select>
</div>
<div class="form-group col-lg-3">
<label style="margin-right:10px" for="role" >{{'USER_PRIVILEGES.ROLE' | translate}}:</label>
<select
class="form-control" [formGroup]="newPrivilegeForm" id="role"
name="role" formControlName="role" style="min-width: 170px">
<option *ngFor="let r of getAllowedRoles()" [value]="r">
{{"ENUM.USER_ROLES." + Role[r].toUpperCase() | translate}}
</option>
</select>
</div>
<div class="col-lg-3">
<button type="submit" class="btn btn-primary">{{'USER_PRIVILEGES.ADD_BUTTON' | translate}}</button>
</div>
</form>
</div>
<div *ngIf="isOnlyGuestInGlobalDomain()">
{{'USER_PRIVILEGES.NO_ROLES_INFO' | translate}}
</div>
<div *ngIf="(isModeAllowed(ComponentMode.VIEW) || isInMode(ComponentMode.PROFILVIEW)) && !isOnlyGuestInGlobalDomain()">
<table class="table table-hover table-condensed" aria-describedby="User privilages in domain table">
<thead>
<tr>
<th scope="col">{{'USER_PRIVILEGES.DOMAIN' | translate}}</th>
<th scope="col">{{'USER_PRIVILEGES.ROLE' | translate}}</th>
<th scope="col"> </th>
</tr>
</thead>
<tbody *ngIf="(domainId == domainService.getGlobalDomainId() && authService.hasRole('ROLE_SYSTEM_ADMIN')) || isInMode(ComponentMode.PROFILVIEW)">
<ng-template ngFor let-userrole [ngForOf]="user?.roles">
<tr *ngIf="userrole.domainId != domainService.getGlobalDomainId() || userrole.role != 'ROLE_GUEST'">
<td>{{userrole.domainName}}</td>
<td>{{"ENUM.USER_ROLES." + userrole.role.toUpperCase() | translate}}</td>
<td *ngIf="!isInMode(ComponentMode.PROFILVIEW) && authService.hasRole('ROLE_SYSTEM_ADMIN') && user?.username !== authService.getUsername()" class="text-right">
<button type="button" class="btn btn-danger-text"
(click)="remove(user.id, userrole.role, userrole.domainId)">
<i class="pi pi-trash" style="font-size: 15px;"></i>
<!-- {{'USER_PRIVILEGES.REMOVE_BUTTON' | translate}}-->
</button>
</td>
</tr>
</ng-template>
</tbody>
<tbody *ngIf="domainId != domainService.getGlobalDomainId() && ((authService.hasDomainRole(domainId, 'ROLE_DOMAIN_ADMIN') || authService.hasRole('ROLE_SYSTEM_ADMIN'))) && !isInMode(ComponentMode.PROFILVIEW)">
<ng-template ngFor let-userrole [ngForOf]="user?.roles">
<tr *ngIf="domainId == userrole.domainId">
<td>{{userrole.domainName}}</td>
<td>{{"ENUM.USER_ROLES." + userrole.role.toUpperCase() | translate}}</td>
<td class="text-right">
<button *ngIf="authService.hasRole('ROLE_SYSTEM_ADMIN') && domainId===domainService.getGlobalDomainId()" type="button" class="btn btn-danger"
(click)="remove(user.id, userrole.role, userrole.domainId)">{{'USER_PRIVILEGES.REMOVE_BUTTON' | translate}}</button>
</td>
</tr>
</ng-template>
</tbody>
</table>
</div>
</div>
</div>