refs #1563. New field groupsView in user
testing/ogGui-multibranch/pipeline/head There was a failure building this commit
Details
testing/ogGui-multibranch/pipeline/head There was a failure building this commit
Details
parent
4ef99a7c98
commit
20452c83eb
|
@ -1,3 +1,5 @@
|
||||||
|
<app-loading [isLoading]="loading"></app-loading>
|
||||||
|
|
||||||
<h1 mat-dialog-title>{{ 'dialogTitleAddUser' | translate }}</h1>
|
<h1 mat-dialog-title>{{ 'dialogTitleAddUser' | translate }}</h1>
|
||||||
<mat-dialog-content class="form-container">
|
<mat-dialog-content class="form-container">
|
||||||
<form [formGroup]="userForm" class="user-form">
|
<form [formGroup]="userForm" class="user-form">
|
||||||
|
|
|
@ -23,6 +23,7 @@ export class AddUserModalComponent implements OnInit {
|
||||||
userGroups: UserGroup[] = [];
|
userGroups: UserGroup[] = [];
|
||||||
organizationalUnits: any[] = [];
|
organizationalUnits: any[] = [];
|
||||||
userId: string | null = null;
|
userId: string | null = null;
|
||||||
|
loading: boolean = false;
|
||||||
|
|
||||||
protected views = [
|
protected views = [
|
||||||
{value: 'card', name: 'Tarjetas'},
|
{value: 'card', name: 'Tarjetas'},
|
||||||
|
@ -50,18 +51,22 @@ export class AddUserModalComponent implements OnInit {
|
||||||
this.dataService.getUserGroups().subscribe((data) => {
|
this.dataService.getUserGroups().subscribe((data) => {
|
||||||
this.userGroups = data['hydra:member'];
|
this.userGroups = data['hydra:member'];
|
||||||
});
|
});
|
||||||
|
|
||||||
this.dataService.getOrganizationalUnits().subscribe((data) => {
|
this.dataService.getOrganizationalUnits().subscribe((data) => {
|
||||||
this.organizationalUnits = data['hydra:member'].filter((item: any) => item.type === 'organizational-unit');
|
this.organizationalUnits = data['hydra:member'].filter((item: any) => item.type === 'organizational-unit');
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.data) {
|
if (this.data) {
|
||||||
this.load()
|
this.load();
|
||||||
|
} else {
|
||||||
|
this.userForm.get('password')?.setValidators([Validators.required]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
load(): void {
|
load(): void {
|
||||||
|
this.loading = true;
|
||||||
this.dataService.getUser(this.data).subscribe({
|
this.dataService.getUser(this.data).subscribe({
|
||||||
next: (response) => {
|
next: (response) => {
|
||||||
|
|
||||||
const organizationalUnitIds = response.allowedOrganizationalUnits.map((unit: any) => unit['@id']);
|
const organizationalUnitIds = response.allowedOrganizationalUnits.map((unit: any) => unit['@id']);
|
||||||
|
|
||||||
this.userForm.patchValue({
|
this.userForm.patchValue({
|
||||||
|
@ -72,9 +77,13 @@ export class AddUserModalComponent implements OnInit {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.userId = response['@id'];
|
this.userId = response['@id'];
|
||||||
|
this.userForm.get('password')?.clearValidators();
|
||||||
|
this.userForm.get('password')?.updateValueAndValidity();
|
||||||
|
this.loading = false;
|
||||||
},
|
},
|
||||||
error: (err) => {
|
error: (err) => {
|
||||||
console.error('Error fetching remote calendar:', err);
|
this.loading = false;
|
||||||
|
console.error('Error fetching user:', err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -93,16 +102,19 @@ export class AddUserModalComponent implements OnInit {
|
||||||
userGroups: [this.userForm.value.role ],
|
userGroups: [this.userForm.value.role ],
|
||||||
groupsView: this.userForm.value.groupsView
|
groupsView: this.userForm.value.groupsView
|
||||||
};
|
};
|
||||||
|
this.loading = true;
|
||||||
|
|
||||||
if (this.userId) {
|
if (this.userId) {
|
||||||
this.http.put(`${this.baseUrl}${this.userId}`, payload).subscribe(
|
this.http.put(`${this.baseUrl}${this.userId}`, payload).subscribe(
|
||||||
(response) => {
|
(response) => {
|
||||||
this.toastService.success('Usuario editado correctamente');
|
this.toastService.success('Usuario editado correctamente');
|
||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
|
this.loading = false
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
this.toastService.error(error['error']['hydra:description']);
|
this.toastService.error(error['error']['hydra:description']);
|
||||||
console.error('Error al editar el rol', error);
|
this.loading = false
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -110,10 +122,11 @@ export class AddUserModalComponent implements OnInit {
|
||||||
(response) => {
|
(response) => {
|
||||||
this.toastService.success('Usuario añadido correctamente');
|
this.toastService.success('Usuario añadido correctamente');
|
||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
|
this.loading = false
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
this.toastService.error(error['error']['hydra:description']);
|
this.toastService.error(error['error']['hydra:description']);
|
||||||
console.error('Error al añadir añadido', error);
|
this.loading = false
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,16 @@
|
||||||
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
|
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
|
||||||
<ng-container *ngFor="let column of columns" [matColumnDef]="column.columnDef">
|
<ng-container *ngFor="let column of columns" [matColumnDef]="column.columnDef">
|
||||||
<th mat-header-cell *matHeaderCellDef> {{ column.header }} </th>
|
<th mat-header-cell *matHeaderCellDef> {{ column.header }} </th>
|
||||||
<td mat-cell *matCellDef="let user"> {{ column.cell(user) }} </td>
|
<td mat-cell *matCellDef="let user">
|
||||||
|
<ng-container *ngIf="column.columnDef === 'groupsView'">
|
||||||
|
<mat-chip>
|
||||||
|
{{ user[column.columnDef] === 'card' ? 'Vista tarjetas' : 'Listado' }}
|
||||||
|
</mat-chip>
|
||||||
|
</ng-container>
|
||||||
|
<ng-container *ngIf="column.columnDef !== 'groupsView'" >
|
||||||
|
{{ column.cell(user) }}
|
||||||
|
</ng-container>
|
||||||
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="actions">
|
<ng-container matColumnDef="actions">
|
||||||
|
|
|
@ -54,7 +54,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
||||||
selectedClients = new MatTableDataSource<Client>([]);
|
selectedClients = new MatTableDataSource<Client>([]);
|
||||||
selection = new SelectionModel<any>(true, []);
|
selection = new SelectionModel<any>(true, []);
|
||||||
cols = 4;
|
cols = 4;
|
||||||
currentView: 'card' | 'list' = 'list';
|
currentView: string = 'list';
|
||||||
savedFilterNames: [string, string][] = [];
|
savedFilterNames: [string, string][] = [];
|
||||||
selectedTreeFilter = '';
|
selectedTreeFilter = '';
|
||||||
syncStatus = false;
|
syncStatus = false;
|
||||||
|
@ -107,6 +107,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
||||||
);
|
);
|
||||||
|
|
||||||
this.treeDataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
|
this.treeDataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
|
||||||
|
this.currentView = localStorage.getItem('groupsView') || 'list';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ import {Component, signal} from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import {ToastrService} from "ngx-toastr";
|
import {ToastrService} from "ngx-toastr";
|
||||||
|
import {jwtDecode} from "jwt-decode";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-login',
|
selector: 'app-login',
|
||||||
|
@ -16,6 +17,7 @@ export class LoginComponent {
|
||||||
};
|
};
|
||||||
errorMessage: string = '';
|
errorMessage: string = '';
|
||||||
isLoading: boolean = false;
|
isLoading: boolean = false;
|
||||||
|
decodedToken: any;
|
||||||
|
|
||||||
baseUrl: string = import.meta.env.NG_APP_BASE_API_URL;
|
baseUrl: string = import.meta.env.NG_APP_BASE_API_URL;
|
||||||
|
|
||||||
|
@ -56,7 +58,11 @@ export class LoginComponent {
|
||||||
localStorage.setItem('loginToken', res.token);
|
localStorage.setItem('loginToken', res.token);
|
||||||
localStorage.setItem('refreshToken', res.refreshToken);
|
localStorage.setItem('refreshToken', res.refreshToken);
|
||||||
localStorage.setItem('username', this.loginObj.username);
|
localStorage.setItem('username', this.loginObj.username);
|
||||||
this.openSnackBar(false, 'Bienvenido ' + this.loginObj.username);
|
|
||||||
|
this.decodedToken = jwtDecode(res.token);
|
||||||
|
localStorage.setItem('groupsView', this.decodedToken.groupsView);
|
||||||
|
|
||||||
|
this.openSnackBar(false, 'Bienvenido ' + this.loginObj.username);
|
||||||
this.router.navigateByUrl('/groups');
|
this.router.navigateByUrl('/groups');
|
||||||
}
|
}
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
|
|
Loading…
Reference in New Issue