From b81db7923729c5743772f5231e8d042683ccf542 Mon Sep 17 00:00:00 2001 From: Lucas Lara Date: Fri, 31 Jan 2025 14:09:14 +0100 Subject: [PATCH] refs #1419 and #1420. Fix OU's path in clients' and OUs' form. Remove stepper from forms. --- .../groups/services/data.service.ts | 10 + .../create-client.component.html | 7 +- .../create-client/create-client.component.ts | 11 + .../create-multiple-client.component.html | 6 +- .../create-multiple-client.component.ts | 16 +- .../edit-client/edit-client.component.html | 8 +- .../edit-client/edit-client.component.ts | 16 +- .../create-organizational-unit.component.html | 320 ++++++++---------- .../create-organizational-unit.component.ts | 16 +- .../edit-organizational-unit.component.html | 298 ++++++++-------- .../edit-organizational-unit.component.ts | 18 +- 11 files changed, 380 insertions(+), 346 deletions(-) diff --git a/ogWebconsole/src/app/components/groups/services/data.service.ts b/ogWebconsole/src/app/components/groups/services/data.service.ts index 997c149..34b0bc3 100644 --- a/ogWebconsole/src/app/components/groups/services/data.service.ts +++ b/ogWebconsole/src/app/components/groups/services/data.service.ts @@ -231,5 +231,15 @@ export class DataService { ); } + getOrganizationalUnitPath(unit: UnidadOrganizativa, units: UnidadOrganizativa[]): string { + const path: string[] = []; + let currentUnit: UnidadOrganizativa | undefined = unit; + while (currentUnit) { + path.unshift(currentUnit.name); + currentUnit = units.find(u => u['@id'] === currentUnit?.parent?.['@id']); + } + + return path.join(' / '); + } } 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 84e406d..3ef6251 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 @@ -6,9 +6,12 @@ Padre - + + {{ getSelectedParentName() }} + +
{{ unit.name }}
-
{{ unit.path }}
+
{{ 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 eb6a5a4..514893b 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 @@ -15,6 +15,7 @@ export class CreateClientComponent implements OnInit { baseUrl: string = import.meta.env.NG_APP_BASE_API_URL; clientForm!: FormGroup; parentUnits: any[] = []; + parentUnitsWithPaths: { id: string, name: string, path: string }[] = []; hardwareProfiles: any[] = []; ogLives: any[] = []; menus: any[] = []; @@ -80,6 +81,11 @@ export class CreateClientComponent implements OnInit { this.http.get(url).subscribe( response => { this.parentUnits = response['hydra:member']; + this.parentUnitsWithPaths = this.parentUnits.map(unit => ({ + id: unit['@id'], + name: unit.name, + path: this.dataService.getOrganizationalUnitPath(unit, this.parentUnits) + })); this.loading = false; }, error => { @@ -89,6 +95,11 @@ export class CreateClientComponent implements OnInit { ); } + getSelectedParentName(): string | undefined { + const parentId = this.clientForm.get('organizationalUnit')?.value; + return this.parentUnitsWithPaths.find(unit => unit.id === parentId)?.name; + } + loadHardwareProfiles(): void { this.dataService.getHardwareProfiles().subscribe( (data: any[]) => { diff --git a/ogWebconsole/src/app/components/groups/shared/clients/create-multiple-client/create-multiple-client.component.html b/ogWebconsole/src/app/components/groups/shared/clients/create-multiple-client/create-multiple-client.component.html index b0f956f..1b34d9c 100644 --- a/ogWebconsole/src/app/components/groups/shared/clients/create-multiple-client/create-multiple-client.component.html +++ b/ogWebconsole/src/app/components/groups/shared/clients/create-multiple-client/create-multiple-client.component.html @@ -7,8 +7,12 @@ {{ 'organizationalUnitLabel' | translate }} - + + {{ getSelectedParentName() }} + +
{{ unit.name }}
+
{{ unit.path }}
diff --git a/ogWebconsole/src/app/components/groups/shared/clients/create-multiple-client/create-multiple-client.component.ts b/ogWebconsole/src/app/components/groups/shared/clients/create-multiple-client/create-multiple-client.component.ts index 9720054..2e1617e 100644 --- a/ogWebconsole/src/app/components/groups/shared/clients/create-multiple-client/create-multiple-client.component.ts +++ b/ogWebconsole/src/app/components/groups/shared/clients/create-multiple-client/create-multiple-client.component.ts @@ -4,6 +4,7 @@ import {HttpClient} from "@angular/common/http"; import {MatSnackBar} from "@angular/material/snack-bar"; import {ToastrService} from "ngx-toastr"; import {MAT_DIALOG_DATA} from "@angular/material/dialog"; +import { DataService } from '../../../services/data.service'; @Component({ selector: 'app-create-multiple-client', @@ -13,6 +14,7 @@ import {MAT_DIALOG_DATA} from "@angular/material/dialog"; export class CreateMultipleClientComponent implements OnInit{ baseUrl: string = import.meta.env.NG_APP_BASE_API_URL; parentUnits: any[] = []; + parentUnitsWithPaths: { id: string, name: string, path: string }[] = []; uploadedClients: any[] = []; loading: boolean = false; displayedColumns: string[] = ['name', 'ip', 'mac']; @@ -25,7 +27,8 @@ export class CreateMultipleClientComponent implements OnInit{ @Inject(MAT_DIALOG_DATA) private data: any, private http: HttpClient, private snackBar: MatSnackBar, - private toastService: ToastrService + private toastService: ToastrService, + private dataService: DataService ) {} ngOnInit(): void { @@ -43,6 +46,11 @@ export class CreateMultipleClientComponent implements OnInit{ this.http.get(url).subscribe( response => { this.parentUnits = response['hydra:member']; + this.parentUnitsWithPaths = this.parentUnits.map(unit => ({ + id: unit['@id'], + name: unit.name, + path: this.dataService.getOrganizationalUnitPath(unit, this.parentUnits) + })); this.loading = false; }, error => { @@ -52,8 +60,12 @@ export class CreateMultipleClientComponent implements OnInit{ ); } + getSelectedParentName(): string | undefined { + const parentId = this.organizationalUnit; + return this.parentUnitsWithPaths.find(unit => unit.id === parentId)?.name; + } + setOrganizationalUnit(organizationalUnit: any): void { - console.log('Organizational unit selected:', organizationalUnit.value); this.organizationalUnit = organizationalUnit.value; } diff --git a/ogWebconsole/src/app/components/groups/shared/clients/edit-client/edit-client.component.html b/ogWebconsole/src/app/components/groups/shared/clients/edit-client/edit-client.component.html index 663e8e0..7fb4fcc 100644 --- a/ogWebconsole/src/app/components/groups/shared/clients/edit-client/edit-client.component.html +++ b/ogWebconsole/src/app/components/groups/shared/clients/edit-client/edit-client.component.html @@ -6,8 +6,12 @@ {{ 'organizationalUnitLabel' | translate }} - - {{ unit.name }} + + {{ getSelectedParentName() }} + + +
{{ unit.name }}
+
{{ unit.path }}
diff --git a/ogWebconsole/src/app/components/groups/shared/clients/edit-client/edit-client.component.ts b/ogWebconsole/src/app/components/groups/shared/clients/edit-client/edit-client.component.ts index 1b05c2c..e53dd47 100644 --- a/ogWebconsole/src/app/components/groups/shared/clients/edit-client/edit-client.component.ts +++ b/ogWebconsole/src/app/components/groups/shared/clients/edit-client/edit-client.component.ts @@ -15,6 +15,7 @@ export class EditClientComponent { baseUrl: string = import.meta.env.NG_APP_BASE_API_URL; clientForm!: FormGroup; parentUnits: any[] = []; + parentUnitsWithPaths: { id: string, name: string, path: string }[] = []; hardwareProfiles: any[] = []; repositories: any[] = []; ogLives: any[] = []; @@ -68,19 +69,32 @@ export class EditClientComponent { }); } - loadParentUnits() { + loadParentUnits(): void { + this.loading = true; const url = `${this.baseUrl}/organizational-units?page=1&itemsPerPage=10000`; this.http.get(url).subscribe( response => { this.parentUnits = response['hydra:member']; + this.parentUnitsWithPaths = this.parentUnits.map(unit => ({ + id: unit['@id'], + name: unit.name, + path: this.dataService.getOrganizationalUnitPath(unit, this.parentUnits) + })); + this.loading = false; }, error => { console.error('Error fetching parent units:', error); + this.loading = false; } ); } + getSelectedParentName(): string | undefined { + const parentId = this.clientForm.get('organizationalUnit')?.value; + return this.parentUnitsWithPaths.find(unit => unit.id === parentId)?.name; + } + loadHardwareProfiles(): void { this.dataService.getHardwareProfiles().subscribe( (data: any[]) => { diff --git a/ogWebconsole/src/app/components/groups/shared/organizational-units/create-organizational-unit/create-organizational-unit.component.html b/ogWebconsole/src/app/components/groups/shared/organizational-units/create-organizational-unit/create-organizational-unit.component.html index 8375fd9..675c34c 100644 --- a/ogWebconsole/src/app/components/groups/shared/organizational-units/create-organizational-unit/create-organizational-unit.component.html +++ b/ogWebconsole/src/app/components/groups/shared/organizational-units/create-organizational-unit/create-organizational-unit.component.html @@ -1,180 +1,158 @@

{{ 'addOrgUnitTitle' | translate }}

-
- - - -
- {{ 'generalStepLabel' | translate }} - - {{ 'typeLabel' | translate }} - - - {{ typeTranslations[type] }} - - - - - {{ 'nameLabel' | translate }} - - - - {{ 'createOrgUnitparentLabel' | translate }} - - {{ 'noParentOption' | translate }} - {{ unit.name }} - - - - {{ 'descriptionLabel' | translate }} - - -
- -
-
-
+ +
+ + {{ 'typeLabel' | translate }} + + + {{ typeTranslations[type] }} + + + + + {{ 'nameLabel' | translate }} + + + + {{ 'createOrgUnitparentLabel' | translate }} + + + {{ getSelectedParentName() }} + + +
{{ unit.name }}
+
{{ unit.path }}
+
+
+
+ + {{ 'descriptionLabel' | translate }} + + +
- - -
- {{ 'classroomInfoStepLabel' | translate }} - - {{ 'locationLabel' | translate }} - - - {{ 'projectorToggle' | translate }} - {{ 'boardToggle' | translate }} - - {{ 'capacityLabel' | translate }} - - - - {{ 'associatedCalendarLabel' | translate }} - - - {{ calendar.name }} - - - + + + + {{ 'locationLabel' | translate }} + + + {{ 'projectorToggle' | translate }} + {{ 'boardToggle' | translate }} + + {{ 'capacityLabel' | translate }} + + + + {{ 'associatedCalendarLabel' | translate }} + + + {{ calendar.name }} + + + +
-
- - -
- -
+ +
+ + {{ 'commentsLabel' | translate }} + + +
- - -
- {{ 'additionalInfoStepLabel' | translate }} - - {{ 'commentsLabel' | translate }} - - -
- - -
-
-
+ +
+ + {{ 'ogLiveLabel' | translate }} + + + {{ oglive.filename }} + + + + + {{ 'repositoryLabel' | translate }} + + + {{ repository.name }} + + + + + {{ 'nextServerLabel' | translate }} + + + + {{ 'bootFileNameLabel' | translate }} + + - - - - {{ 'networkSettingsStepLabel' | translate }} - - {{ 'ogLiveLabel' | translate }} - - - {{ oglive.filename }} - - - - - {{ 'repositoryLabel' | translate }} - - - {{ repository.name }} - - - - - {{ 'nextServerLabel' | translate }} - - - - {{ 'bootFileNameLabel' | translate }} - - - - - {{ 'proxyUrlLabel' | translate }} - - - - {{ 'dnsIpLabel' | translate }} - - - - {{ 'netmaskLabel' | translate }} - - - - {{ 'routerLabel' | translate }} - - - - {{ 'ntpIpLabel' | translate }} - - - - {{ 'p2pModeLabel' | translate }} - - - {{ option.name }} - - - - - {{ 'p2pTimeLabel' | translate }} - - - - {{ 'mcastIpLabel' | translate }} - - - - {{ 'mcastSpeedLabel' | translate }} - - - - {{ 'mcastPortLabel' | translate }} - - - - {{ 'mcastModeLabel' | translate }} - - - {{ option.name }} - - - - - {{ 'menuUrlLabel' | translate }} - - - - {{ 'hardwareProfileLabel' | translate }} - - {{ unit.description }} - - {{ 'urlFormatError' | translate }} - - -
-
+ + {{ 'proxyUrlLabel' | translate }} + + + + {{ 'dnsIpLabel' | translate }} + + + + {{ 'netmaskLabel' | translate }} + + + + {{ 'routerLabel' | translate }} + + + + {{ 'ntpIpLabel' | translate }} + + + + {{ 'p2pModeLabel' | translate }} + + + {{ option.name }} + + + + + {{ 'p2pTimeLabel' | translate }} + + + + {{ 'mcastIpLabel' | translate }} + + + + {{ 'mcastSpeedLabel' | translate }} + + + + {{ 'mcastPortLabel' | translate }} + + + + {{ 'mcastModeLabel' | translate }} + + + {{ option.name }} + + + + + {{ 'menuUrlLabel' | translate }} + + + + {{ 'hardwareProfileLabel' | translate }} + + {{ unit.description }} + + {{ 'urlFormatError' | translate }} + +
diff --git a/ogWebconsole/src/app/components/groups/shared/organizational-units/create-organizational-unit/create-organizational-unit.component.ts b/ogWebconsole/src/app/components/groups/shared/organizational-units/create-organizational-unit/create-organizational-unit.component.ts index c9b45c1..ec2a96f 100644 --- a/ogWebconsole/src/app/components/groups/shared/organizational-units/create-organizational-unit/create-organizational-unit.component.ts +++ b/ogWebconsole/src/app/components/groups/shared/organizational-units/create-organizational-unit/create-organizational-unit.component.ts @@ -39,7 +39,7 @@ export class CreateOrganizationalUnitComponent implements OnInit { ogLives: any[] = []; repositories: any[] = []; selectedCalendarUuid: string | null = null; - + parentUnitsWithPaths: { id: string, name: string, path: string }[] = []; @Output() unitAdded = new EventEmitter<{ uuid: string; name: string }>(); @@ -104,11 +104,23 @@ export class CreateOrganizationalUnitComponent implements OnInit { loadParentUnits() { const url = `${this.baseUrl}/organizational-units?page=1&itemsPerPage=1000`; this.http.get(url).subscribe( - response => this.parentUnits = response['hydra:member'], + response => { + this.parentUnits = response['hydra:member']; + this.parentUnitsWithPaths = this.parentUnits.map(unit => ({ + id: unit['@id'], + name: unit.name, + path: this.dataService.getOrganizationalUnitPath(unit, this.parentUnits) + })); + }, error => console.error('Error fetching parent units:', error) ); } + getSelectedParentName(): string | undefined { + const parentId = this.generalFormGroup.get('parent')?.value; + return this.parentUnitsWithPaths.find(unit => unit.id === parentId)?.name; + } + loadHardwareProfiles(): void { this.dataService.getHardwareProfiles().subscribe( (data: any[]) => this.hardwareProfiles = data, diff --git a/ogWebconsole/src/app/components/groups/shared/organizational-units/edit-organizational-unit/edit-organizational-unit.component.html b/ogWebconsole/src/app/components/groups/shared/organizational-units/edit-organizational-unit/edit-organizational-unit.component.html index 1ffc68a..4e7c86c 100644 --- a/ogWebconsole/src/app/components/groups/shared/organizational-units/edit-organizational-unit/edit-organizational-unit.component.html +++ b/ogWebconsole/src/app/components/groups/shared/organizational-units/edit-organizational-unit/edit-organizational-unit.component.html @@ -1,168 +1,146 @@

{{ 'editOrgUnitTitle' | translate }}

- - - -
- {{ 'generalStepLabel' | translate }} - - {{ 'typeLabel' | translate }} - - {{ typeTranslations[type] }} - - - - {{ 'nameLabel' | translate }} - - - - {{ 'editOrgUnitParentLabel' | translate }} - - {{ unit.name }} - - - - {{ 'descriptionLabel' | translate }} - - -
- -
-
-
+ +
+ + {{ 'typeLabel' | translate }} + + + {{ typeTranslations[type] }} + + + + + {{ 'nameLabel' | translate }} + + + + {{ 'editOrgUnitParentLabel' | translate }} + + + {{ getSelectedParentName() }} + + +
{{ unit.name }}
+
{{ unit.path }}
+
+
+
+ + {{ 'descriptionLabel' | translate }} + + +
- - -
- {{ 'classroomInfoStepLabel' | translate }} - - {{ 'locationLabel' | translate }} - - - {{ 'projectorToggle' | translate }} - {{ 'boardToggle' | translate }} - - {{ 'capacityLabel' | translate }} - - + + + + {{ 'locationLabel' | translate }} + + + {{ 'projectorToggle' | translate }} + {{ 'boardToggle' | translate }} + + {{ 'capacityLabel' | translate }} + + + + {{ 'associatedCalendarLabel' | translate }} + + + {{ calendar.name }} + + + +
- - {{ 'associatedCalendarLabel' | translate }} - - - {{ calendar.name }} - - - + +
+ + {{ 'commentsLabel' | translate }} + + +
-
- - -
- -
- - - -
- {{ 'additionalInfoStepLabel' | translate }} - - {{ 'commentsLabel' | translate }} - - -
- - -
-
-
- - - -
- {{ 'networkSettingsStepLabel' | translate }} - - {{ 'ogLiveLabel' | translate }} - - - {{ oglive.filename }} - - - - - {{ 'repositoryLabel' | translate }} - - - {{ repository.name }} - - - - - {{ 'proxyUrlLabel' | translate }} - - - - {{ 'dnsIpLabel' | translate }} - - - - {{ 'netmaskLabel' | translate }} - - - - {{ 'routerLabel' | translate }} - - - - {{ 'ntpIpLabel' | translate }} - - - - {{ 'p2pModeLabel' | translate }} - - {{ option.name }} - - - - {{ 'p2pTimeLabel' | translate }} - - - - {{ 'mcastIpLabel' | translate }} - - - - {{ 'mcastSpeedLabel' | translate }} - - - - {{ 'mcastPortLabel' | translate }} - - - - {{ 'mcastModeLabel' | translate }} - - {{ option.name }} - - - - {{ 'menuUrlLabel' | translate }} - - - - {{ 'hardwareProfileLabel' | translate }} - - {{ unit.description }} - - {{ 'urlFormatError' | translate }} - - {{ 'validationToggle' | translate }} -
- -
-
-
-
+ +
+ + {{ 'ogLiveLabel' | translate }} + + + {{ oglive.filename }} + + + + + {{ 'repositoryLabel' | translate }} + + + {{ repository.name }} + + + + + {{ 'proxyUrlLabel' | translate }} + + + + {{ 'dnsIpLabel' | translate }} + + + + {{ 'netmaskLabel' | translate }} + + + + {{ 'routerLabel' | translate }} + + + + {{ 'ntpIpLabel' | translate }} + + + + {{ 'p2pModeLabel' | translate }} + + {{ option.name }} + + + + {{ 'p2pTimeLabel' | translate }} + + + + {{ 'mcastIpLabel' | translate }} + + + + {{ 'mcastSpeedLabel' | translate }} + + + + {{ 'mcastPortLabel' | translate }} + + + + {{ 'mcastModeLabel' | translate }} + + {{ option.name }} + + + + {{ 'menuUrlLabel' | translate }} + + + + {{ 'hardwareProfileLabel' | translate }} + + {{ unit.description }} + + {{ 'urlFormatError' | translate }} + + {{ 'validationToggle' | translate }} +
diff --git a/ogWebconsole/src/app/components/groups/shared/organizational-units/edit-organizational-unit/edit-organizational-unit.component.ts b/ogWebconsole/src/app/components/groups/shared/organizational-units/edit-organizational-unit/edit-organizational-unit.component.ts index 859edc6..251e2b1 100644 --- a/ogWebconsole/src/app/components/groups/shared/organizational-units/edit-organizational-unit/edit-organizational-unit.component.ts +++ b/ogWebconsole/src/app/components/groups/shared/organizational-units/edit-organizational-unit/edit-organizational-unit.component.ts @@ -31,6 +31,7 @@ export class EditOrganizationalUnitComponent implements OnInit { currentCalendar: any = []; ogLives: any[] = []; repositories: any[] = []; + parentUnitsWithPaths: { id: string, name: string, path: string }[] = []; protected p2pModeOptions = [ {"name": 'Leecher', "value": "leecher"}, {"name": 'Peer', "value": "peer"}, @@ -109,18 +110,25 @@ export class EditOrganizationalUnitComponent implements OnInit { } loadParentUnits() { - const url = `${this.baseUrl}/organizational-units?page=1&itemsPerPage=10000`; - + const url = `${this.baseUrl}/organizational-units?page=1&itemsPerPage=1000`; this.http.get(url).subscribe( response => { this.parentUnits = response['hydra:member']; + this.parentUnitsWithPaths = this.parentUnits.map(unit => ({ + id: unit['@id'], + name: unit.name, + path: this.dataService.getOrganizationalUnitPath(unit, this.parentUnits) + })); }, - error => { - console.error('Error fetching parent units:', error); - } + error => console.error('Error fetching parent units:', error) ); } + getSelectedParentName(): string | undefined { + const parentId = this.generalFormGroup.get('parent')?.value; + return this.parentUnitsWithPaths.find(unit => unit.id === parentId)?.name; + } + loadHardwareProfiles(): void { this.dataService.getHardwareProfiles().subscribe( (data: any[]) => {