From b0ede36d3bbda3e7295ab199b5a8b965384531eb Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Mon, 17 Feb 2025 14:42:49 +0100 Subject: [PATCH] refs #1523. Hierarchy networkSettings. Resolve conflicts --- .../task-logs/task-logs.component.html | 5 ++- .../partition-assistant.component.ts | 4 +- .../create-client.component.html | 4 +- .../create-client/create-client.component.ts | 35 +++++++++++++--- .../manage-organizational-unit.component.html | 22 ++++++---- ...nage-organizational-unit.component.spec.ts | 6 ++- .../manage-organizational-unit.component.ts | 41 +++++++++++++------ ogWebconsole/src/locale/en.json | 1 + ogWebconsole/src/locale/es.json | 1 + 9 files changed, 86 insertions(+), 33 deletions(-) diff --git a/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.html b/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.html index b166ed4..d49b789 100644 --- a/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.html +++ b/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.html @@ -64,7 +64,7 @@ - +
@@ -80,6 +80,7 @@ }"> {{ trace.status === 'failed' ? 'Fallido' : + trace.status === 'in-progress' ? 'En ejecuci贸n' : trace.status === 'success' ? 'Finalizado con 茅xito' : trace.status === 'pending' ? 'Pendiente de ejecutar' : trace.status @@ -114,4 +115,4 @@ -
\ No newline at end of file + diff --git a/ogWebconsole/src/app/components/groups/components/client-main-view/partition-assistant/partition-assistant.component.ts b/ogWebconsole/src/app/components/groups/components/client-main-view/partition-assistant/partition-assistant.component.ts index 94c85da..79251b1 100644 --- a/ogWebconsole/src/app/components/groups/components/client-main-view/partition-assistant/partition-assistant.component.ts +++ b/ogWebconsole/src/app/components/groups/components/client-main-view/partition-assistant/partition-assistant.component.ts @@ -265,14 +265,14 @@ export class PartitionAssistantComponent { if (totalPartitionSize > this.selectedDisk.totalDiskSize) { this.errorMessage = 'El tama帽o total de las particiones en el disco seleccionado excede el tama帽o total del disco.'; + this.loading = false; return; - } else { - this.errorMessage = ''; } const modifiedPartitions = this.selectedDisk.partitions.filter((partition: { removed: any; format: any; }) => !partition.removed || partition.format); if (modifiedPartitions.length === 0) { + this.loading = false; this.errorMessage = 'No hay cambios para guardar en el disco seleccionado.'; return; } diff --git a/ogWebconsole/src/app/components/groups/shared/clients/create-client/create-client.component.html b/ogWebconsole/src/app/components/groups/shared/clients/create-client/create-client.component.html index 1b7ee4f..5bebae5 100644 --- a/ogWebconsole/src/app/components/groups/shared/clients/create-client/create-client.component.html +++ b/ogWebconsole/src/app/components/groups/shared/clients/create-client/create-client.component.html @@ -5,11 +5,11 @@
Padre - + {{ getSelectedParentName() }} - +
{{ unit.name }}
{{ unit.path }}
diff --git a/ogWebconsole/src/app/components/groups/shared/clients/create-client/create-client.component.ts b/ogWebconsole/src/app/components/groups/shared/clients/create-client/create-client.component.ts index 514893b..c807b1c 100644 --- a/ogWebconsole/src/app/components/groups/shared/clients/create-client/create-client.component.ts +++ b/ogWebconsole/src/app/components/groups/shared/clients/create-client/create-client.component.ts @@ -43,13 +43,13 @@ export class CreateClientComponent implements OnInit { ) {} ngOnInit(): void { - this.initForm(); this.loadParentUnits(); this.loadHardwareProfiles(); this.loadOgLives(); this.loadPxeTemplates(); this.loadRepositories(); this.loadMenus() + this.initForm(); } initForm(): void { @@ -65,9 +65,7 @@ export class CreateClientComponent implements OnInit { mac: ['', Validators.required], ip: ['', Validators.required], template: [null], - hardwareProfile: [ - this.data.organizationalUnit?.networkSettings?.hardwareProfile?.['@id'] || null - ], + hardwareProfile: [null], ogLive: [null], repository: [null], menu: [null] @@ -84,8 +82,19 @@ export class CreateClientComponent implements OnInit { this.parentUnitsWithPaths = this.parentUnits.map(unit => ({ id: unit['@id'], name: unit.name, - path: this.dataService.getOrganizationalUnitPath(unit, this.parentUnits) + path: this.dataService.getOrganizationalUnitPath(unit, this.parentUnits), + repository: unit.networkSettings?.repository?.['@id'], + hardwareProfile: unit.networkSettings?.hardwareProfile?.['@id'], + ogLive: unit.networkSettings?.ogLive?.['@id'], + menu: unit.networkSettings?.menu?.['@id'] })); + + // 馃殌 Ahora que los datos est谩n listos, aplicamos la configuraci贸n inicial + const initialUnitId = this.clientForm.get('organizationalUnit')?.value; + if (initialUnitId) { + this.setOrganizationalUnitDefaults(initialUnitId); + } + this.loading = false; }, error => { @@ -165,6 +174,22 @@ export class CreateClientComponent implements OnInit { ); } + onParentChange(event: any): void { + this.setOrganizationalUnitDefaults(event.value); + } + + setOrganizationalUnitDefaults(unitId: string): void { + const selectedUnit: any = this.parentUnitsWithPaths.find(unit => unit.id === unitId); + if (selectedUnit) { + this.clientForm.patchValue({ + repository: selectedUnit.repository || null, + hardwareProfile: selectedUnit.hardwareProfile || null, + ogLive: selectedUnit.ogLive || null, + menu: selectedUnit.menu || null + }); + } + } + onSubmit(): void { if (this.clientForm.valid) { const formData = this.clientForm.value; diff --git a/ogWebconsole/src/app/components/groups/shared/organizational-units/manage-organizational-unit/manage-organizational-unit.component.html b/ogWebconsole/src/app/components/groups/shared/organizational-units/manage-organizational-unit/manage-organizational-unit.component.html index d9dfd38..5ced9bc 100644 --- a/ogWebconsole/src/app/components/groups/shared/organizational-units/manage-organizational-unit/manage-organizational-unit.component.html +++ b/ogWebconsole/src/app/components/groups/shared/organizational-units/manage-organizational-unit/manage-organizational-unit.component.html @@ -27,10 +27,15 @@
+ Descripci贸n + + + {{ 'excludeParentChanges' | translate }} +
@@ -132,10 +137,14 @@ - - Men煤 - - + + Menu + + + {{ menu.name }} + + + Perfil de Hardware @@ -144,9 +153,6 @@ Formato de URL incorrecto -
- Validaci贸n -
@@ -163,4 +169,4 @@ - \ No newline at end of file + diff --git a/ogWebconsole/src/app/components/groups/shared/organizational-units/manage-organizational-unit/manage-organizational-unit.component.spec.ts b/ogWebconsole/src/app/components/groups/shared/organizational-units/manage-organizational-unit/manage-organizational-unit.component.spec.ts index 882d8ac..32b24e0 100644 --- a/ogWebconsole/src/app/components/groups/shared/organizational-units/manage-organizational-unit/manage-organizational-unit.component.spec.ts +++ b/ogWebconsole/src/app/components/groups/shared/organizational-units/manage-organizational-unit/manage-organizational-unit.component.spec.ts @@ -2,13 +2,14 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ManageOrganizationalUnitComponent } from './manage-organizational-unit.component'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { ReactiveFormsModule } from '@angular/forms'; +import {FormsModule, ReactiveFormsModule} from '@angular/forms'; import { ToastrModule } from 'ngx-toastr'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; import { MatSelectModule } from '@angular/material/select'; import { MatSlideToggleModule } from '@angular/material/slide-toggle'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import {TranslateModule} from "@ngx-translate/core"; describe('ManageOrganizationalUnitComponent', () => { let component: ManageOrganizationalUnitComponent; @@ -25,6 +26,7 @@ describe('ManageOrganizationalUnitComponent', () => { MatInputModule, MatSelectModule, MatSlideToggleModule, + TranslateModule.forRoot(), BrowserAnimationsModule ], providers: [ @@ -42,4 +44,4 @@ describe('ManageOrganizationalUnitComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); -}); \ No newline at end of file +}); diff --git a/ogWebconsole/src/app/components/groups/shared/organizational-units/manage-organizational-unit/manage-organizational-unit.component.ts b/ogWebconsole/src/app/components/groups/shared/organizational-units/manage-organizational-unit/manage-organizational-unit.component.ts index 2a2915b..f094da8 100644 --- a/ogWebconsole/src/app/components/groups/shared/organizational-units/manage-organizational-unit/manage-organizational-unit.component.ts +++ b/ogWebconsole/src/app/components/groups/shared/organizational-units/manage-organizational-unit/manage-organizational-unit.component.ts @@ -29,6 +29,7 @@ export class ManageOrganizationalUnitComponent implements OnInit { isEditMode: boolean; currentCalendar: any = []; ogLives: any[] = []; + menus: any[] = []; repositories: any[] = []; parentUnitsWithPaths: { id: string, name: string, path: string }[] = []; protected p2pModeOptions = [ @@ -57,7 +58,8 @@ export class ManageOrganizationalUnitComponent implements OnInit { name: [null, Validators.required], parent: [data?.parent ? data.parent['@id'] : null], description: [null], - type: [null, Validators.required] + type: [null, Validators.required], + excludeParentChanges: [false], }); this.additionalInfoFormGroup = this._formBuilder.group({ @@ -79,8 +81,7 @@ export class ManageOrganizationalUnitComponent implements OnInit { mcastPort: [null], mcastMode: [null], menu: [null], - hardwareProfile: [null], - validation: [false] + hardwareProfile: [null] }); this.classroomInfoFormGroup = this._formBuilder.group({ @@ -102,6 +103,7 @@ export class ManageOrganizationalUnitComponent implements OnInit { this.loadCalendars(); this.loadOgLives(); this.loadRepositories(); + this.loadMenus() } get filteredTypes(): string[] { @@ -139,6 +141,20 @@ export class ManageOrganizationalUnitComponent implements OnInit { ); } + loadMenus(): void { + const url = `${this.baseUrl}/menus?page=1&itemsPerPage=10000`; + + this.http.get(url).subscribe( + response => { + this.menus = response['hydra:member']; + }, + error => { + console.error('Error fetching menus:', error); + } + ); + } + + loadOgLives() { this.dataService.getOgLives().subscribe( (data: any[]) => { @@ -191,14 +207,15 @@ export class ManageOrganizationalUnitComponent implements OnInit { loadData(uuid: string) { const url = `${this.baseUrl}/organizational-units/${uuid}`; - + this.http.get(url).subscribe( data => { this.generalFormGroup.patchValue({ name: data.name, parent: data.parent ? data.parent['@id'] : '', description: data.description, - type: data.type + type: data.type, + excludeParentChanges: data.excludeParentChanges }); this.additionalInfoFormGroup.patchValue({ comments: data.comments @@ -218,8 +235,7 @@ export class ManageOrganizationalUnitComponent implements OnInit { menu: data.networkSettings.menu ? data.networkSettings.menu['@id'] : null, hardwareProfile: data.networkSettings.hardwareProfile ? data.networkSettings.hardwareProfile['@id'] : null, ogLive: data.networkSettings.ogLive ? data.networkSettings.ogLive['@id'] : null, - repository: data.networkSettings.repository ? data.networkSettings.repository['@id'] : null, - validation: data.networkSettings.validation + repository: data.networkSettings.repository ? data.networkSettings.repository['@id'] : null }); this.classroomInfoFormGroup.patchValue({ location: data.location, @@ -229,7 +245,7 @@ export class ManageOrganizationalUnitComponent implements OnInit { remoteCalendar: data.remoteCalendar ? data.remoteCalendar['@id'] : null }); }, - + error => { console.error('Error fetching data for edit:', error); this.toastService.error('Error fetching data'); @@ -243,6 +259,7 @@ export class ManageOrganizationalUnitComponent implements OnInit { const parentValue = this.generalFormGroup.value.parent; const formData = { name: this.generalFormGroup.value.name, + excludeParentChanges: this.generalFormGroup.value.excludeParentChanges, parent: parentValue || null, description: this.generalFormGroup.value.description, comments: this.additionalInfoFormGroup.value.comments, @@ -254,11 +271,11 @@ export class ManageOrganizationalUnitComponent implements OnInit { board: this.classroomInfoFormGroup.value.board, capacity: this.classroomInfoFormGroup.value.capacity, }; - + if (this.isEditMode) { const putUrl = `${this.baseUrl}/organizational-units/${this.data.uuid}`; const headers = new HttpHeaders({ 'Content-Type': 'application/json' }); - + this.http.put(putUrl, formData, { headers }).subscribe( response => { this.unitAdded.emit(); @@ -273,7 +290,7 @@ export class ManageOrganizationalUnitComponent implements OnInit { } else { const postUrl = `${this.baseUrl}/organizational-units`; const headers = new HttpHeaders({ 'Content-Type': 'application/json' }); - + this.http.post(postUrl, formData, { headers }).subscribe( response => { this.unitAdded.emit(response); @@ -292,4 +309,4 @@ export class ManageOrganizationalUnitComponent implements OnInit { onNoClick(): void { this.dialogRef.close(); } -} \ No newline at end of file +} diff --git a/ogWebconsole/src/locale/en.json b/ogWebconsole/src/locale/en.json index d3a179c..1b4d204 100644 --- a/ogWebconsole/src/locale/en.json +++ b/ogWebconsole/src/locale/en.json @@ -182,6 +182,7 @@ "toggleNodeAriaLabel": "Toggle node", "closeButton": "Close", "inputDetails": "Input details", + "excludeParentChanges": "Exclude parent changes", "orgUnitPropertiesTitle": "Organizational unit properties", "generalDataTab": "General data", "propertyHeader": "Property", diff --git a/ogWebconsole/src/locale/es.json b/ogWebconsole/src/locale/es.json index 6a58707..1a1e13f 100644 --- a/ogWebconsole/src/locale/es.json +++ b/ogWebconsole/src/locale/es.json @@ -266,6 +266,7 @@ "roomMapOption": "Plano de aula", "clientDetailsTitle": "Datos de cliente", "commandsButton": "Comandos", + "excludeParentChanges": "Excluir cambios de las unidades organizativas superiores", "networkPropertiesTab": "Propiedades de red", "disksPartitionsTitle": "Discos/Particiones", "diskTitle": "Disco",