Eliminar roles

pull/3/head
Alvaro Puente Mella 2024-06-03 10:44:30 +02:00
parent 4a86f36112
commit ef9852e931
4 changed files with 17 additions and 4 deletions

View File

@ -18,7 +18,6 @@ const routes: Routes = [
{ path: 'admin', component: AdminComponent },
{ path: 'users', component: UsersComponent },
{ path: 'user-groups', component: RolesComponent },
// otras rutas que usan el MainLayoutComponent
],
},
{
@ -26,7 +25,6 @@ const routes: Routes = [
component: AuthLayoutComponent,
children: [
{ path: 'login', component: LoginComponent },
// otras rutas de autenticación
],
},
{ path: '**', component: PageNotFoundComponent },

View File

@ -13,7 +13,7 @@
<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef> Acciones </th>
<td mat-cell *matCellDef="let role">
<button mat-button color="warn" [disabled]="role.id === 1" (click)="deleteRole(role)">Eliminar</button>
<button mat-button color="warn" [disabled]="role.name=== 'Super Admin' " (click)="deleteRole(role)">Eliminar</button>
</td>
</ng-container>

View File

@ -17,6 +17,15 @@
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field class="form-field">
<mat-label>Organizational Units</mat-label>
<mat-select multiple formControlName="organizationalUnit">
<mat-option *ngFor="let unit of organizationalUnits" [value]="unit['@id']">
{{unit.name}}
</mat-option>
</mat-select>
</mat-form-field>
</form>
</div>

View File

@ -17,6 +17,7 @@ interface UserGroup {
export class EditUserModalComponent implements OnInit {@Output() userEdited = new EventEmitter<void>();
userForm: FormGroup;
userGroups: UserGroup[] = [];
organizationalUnits: any[] = [];
constructor(
public dialogRef: MatDialogRef<EditUserModalComponent>,
@ -24,10 +25,12 @@ export class EditUserModalComponent implements OnInit {@Output() userEdited = ne
private fb: FormBuilder,
private userService: UserService // Inyecta el servicio
) {
console.log(this.data)
this.userForm = this.fb.group({
username: [this.data.user.username],
password: [''],
role: this.data.user.allowedOrganizationalUnits, // Control para el permiso seleccionado
role: this.data.user.allowedOrganizationalUnits,
organizationalUnit: [[this.data.user.allowedOrganizationalUnits], Validators.required]
});
}
@ -35,6 +38,9 @@ export class EditUserModalComponent implements OnInit {@Output() userEdited = ne
this.userService.getUserGroups().subscribe((data) => {
this.userGroups = data['hydra:member'];
});
this.userService.getOrganizationalUnits().subscribe((data) => {
this.organizationalUnits = data['hydra:member'];
});
}
onNoClick(): void {