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

View File

@ -13,7 +13,7 @@
<ng-container matColumnDef="actions"> <ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef> Acciones </th> <th mat-header-cell *matHeaderCellDef> Acciones </th>
<td mat-cell *matCellDef="let role"> <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> </td>
</ng-container> </ng-container>

View File

@ -18,6 +18,15 @@
</mat-select> </mat-select>
</mat-form-field> </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> </form>
</div> </div>
<div mat-dialog-actions> <div mat-dialog-actions>

View File

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