Merge branch 'devel' of ssh://ognproject.evlt.uma.es:21987/opengnsys/oggui into devel
testing/ogGui-multibranch/pipeline/head There was a failure building this commit Details
oggui-debian-package/pipeline/head This commit looks good Details

pull/97/head
Manuel Aranda Rosales 2026-07-09 10:14:43 +02:00
commit 97965a346f
7 changed files with 56 additions and 12 deletions

View File

@ -15,30 +15,48 @@
<mat-form-field appearance="fill" class="full-width">
<mat-label>{{ 'labelRole' | translate }}</mat-label>
<mat-select formControlName="role" required>
<mat-option *ngFor="let group of userGroups" [value]="group['@id']">
{{ group.name }}
</mat-option>
@for (group of userGroups; track group['@id']) {
<mat-option [value]="group['@id']">
{{ group.name }}
</mat-option>
}
</mat-select>
</mat-form-field>
<mat-form-field appearance="fill" class="full-width">
<mat-label>{{ 'labelOrganizationalUnit' | translate }}</mat-label>
<mat-select multiple formControlName="organizationalUnits">
<mat-option *ngFor="let unit of organizationalUnits" [value]="unit['@id']">
{{ unit.name }}
</mat-option>
@for (unit of organizationalUnits; track unit['@id']) {
<mat-option [value]="unit['@id']">
{{ unit.name }}
</mat-option>
}
</mat-select>
</mat-form-field>
<mat-form-field appearance="fill" class="full-width">
<mat-label>{{ 'cardView' | translate }}</mat-label>
<mat-select formControlName="groupsView" required>
<mat-option *ngFor="let option of views" [value]="option.value">
{{ option.name }}
</mat-option>
@for (option of views; track option.value) {
<mat-option [value]="option.value">
{{ option.name }}
</mat-option>
}
</mat-select>
</mat-form-field>
<mat-form-field appearance="fill" class="full-width">
<mat-label>{{ 'userLanguage' | translate }}</mat-label>
<mat-select formControlName="language">
@for (lang of availableLanguages; track lang.code) {
<mat-option [value]="lang.code">
{{ lang.label }}
</mat-option>
}
</mat-select>
<mat-hint>{{ 'userLanguageHint' | translate }}</mat-hint>
</mat-form-field>
<mat-form-field appearance="fill" class="full-width">
<mat-label>{{ 'clientsPerPage' | translate }}</mat-label>
<input matInput formControlName="clientsPerPage" type="number" min="1" [placeholder]="'default20' | translate">

View File

@ -36,6 +36,8 @@ export class AddUserModalComponent implements OnInit {
{ value: 'list', name: 'Listado' },
];
readonly availableLanguages: { code: string; label: string }[];
constructor(
public dialogRef: MatDialogRef<AddUserModalComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
@ -46,12 +48,15 @@ export class AddUserModalComponent implements OnInit {
private configService: ConfigService
) {
this.baseUrl = this.configService.apiUrl;
const langs = this.configService.languages;
this.availableLanguages = Object.keys(langs).map(code => ({ code, label: langs[code] }));
this.userForm = this.fb.group({
username: ['', Validators.required],
password: ['', Validators.required],
role: ['', Validators.required],
groupsView: ['card', Validators.required],
clientsPerPage: [null, [Validators.min(1)]],
language: ['es'],
organizationalUnits: [[]]
});
@ -87,7 +92,8 @@ export class AddUserModalComponent implements OnInit {
role: response.userGroups.length > 0 ? response.userGroups[0]['@id'] : null,
organizationalUnits: organizationalUnitIds,
groupsView: response.groupsView,
clientsPerPage: response.clientsPerPage ?? null
clientsPerPage: response.clientsPerPage ?? null,
language: response.language ?? 'es'
});
this.userId = response['@id'];
@ -114,7 +120,8 @@ export class AddUserModalComponent implements OnInit {
enabled: true,
userGroups: [this.userForm.value.role],
groupsView: this.userForm.value.groupsView,
clientsPerPage: this.userForm.value.clientsPerPage || null
clientsPerPage: this.userForm.value.clientsPerPage || null,
language: this.userForm.value.language || null
};
if (!this.userId && this.userForm.value.password) {

View File

@ -34,7 +34,14 @@ export class HeaderComponent implements OnInit {
ngOnInit(): void {
this.breakpointObserver.observe(['(max-width: 576px)']).subscribe((result) => {
this.isSmallScreen = result.matches;
})
});
// Aplicar idioma guardado: el del JWT (servidor) tiene prioridad sobre localStorage
const jwtLang = this.auth.language;
const localLang = localStorage.getItem('language');
const langToApply = jwtLang || localLang || 'es';
this.translate.use(langToApply);
localStorage.setItem('language', langToApply);
}
get availableLanguages() {

View File

@ -18,6 +18,7 @@ interface JwtPayload {
uuid: string;
groupsView: string;
clientsPerPage: number | null;
language: string | null;
}
@Injectable({ providedIn: 'root' })
@ -103,6 +104,11 @@ export class AuthService {
return this.tokenPayload?.clientsPerPage ?? null;
}
/** Idioma preferido del usuario */
get language(): string | null {
return this.tokenPayload?.language ?? null;
}
/**
* Devuelve el rol principal del usuario según prioridad.
*/

View File

@ -238,6 +238,8 @@
"clientSelectStepText": "Selecciona un client per veure les traces associades.",
"clientsPerPage": "Clients per pàgina",
"clientsPerPageHint": "Nombre de clients mostrats per pàgina al llistat",
"userLanguage": "Idioma preferit",
"userLanguageHint": "Idioma de la interfície per a aquest usuari",
"clientSuccessfullyRemovedFromThe": "Client eliminat de la xarxa correctament",
"clientsViewStepText": "Visualització dels clients de la unitat organitzativa seleccionada",
"clientUpdatedSuccessfully": "Client actualitzat correctament",

View File

@ -238,6 +238,8 @@
"clientSelectStepText": "Select a client to see the associated traces.",
"clientsPerPage": "Clients per page",
"clientsPerPageHint": "Number of clients shown per page in the list",
"userLanguage": "Preferred language",
"userLanguageHint": "Interface language for this user",
"clientSuccessfullyRemovedFromThe": "Client successfully removed from the network",
"clientsViewStepText": "Display of the selected organizational unit's clients",
"clientUpdatedSuccessfully": "Client updated successfully",

View File

@ -238,6 +238,8 @@
"clientSelectStepText": "Selecciona un cliente para ver las trazas asociadas.",
"clientsPerPage": "Clientes por página",
"clientsPerPageHint": "Número de clientes mostrados por página en el listado",
"userLanguage": "Idioma preferido",
"userLanguageHint": "Idioma de la interfaz para este usuario",
"clientSuccessfullyRemovedFromThe": "Cliente eliminado de la red con éxito",
"clientsViewStepText": "Visualización de los clientes de la unidad organizativa seleccionada",
"clientUpdatedSuccessfully": "Cliente actualizado con éxito",