diff --git a/ogWebconsole/src/app/components/ogboot/pxe-boot-files/pxe-boot-files.component.html b/ogWebconsole/src/app/components/ogboot/pxe-boot-files/pxe-boot-files.component.html
index 94c1bb5..6f7b636 100644
--- a/ogWebconsole/src/app/components/ogboot/pxe-boot-files/pxe-boot-files.component.html
+++ b/ogWebconsole/src/app/components/ogboot/pxe-boot-files/pxe-boot-files.component.html
@@ -63,14 +63,19 @@
Plantilla
-
-
-
- {{ option.name }}
+
+
+ Seleccione una plantilla
+
+ Ninguna
+
+ {{ template.name }}
+
+
diff --git a/ogWebconsole/src/app/components/ogboot/pxe-boot-files/pxe-boot-files.component.ts b/ogWebconsole/src/app/components/ogboot/pxe-boot-files/pxe-boot-files.component.ts
index 8ce81b1..5fefbe3 100644
--- a/ogWebconsole/src/app/components/ogboot/pxe-boot-files/pxe-boot-files.component.ts
+++ b/ogWebconsole/src/app/components/ogboot/pxe-boot-files/pxe-boot-files.component.ts
@@ -15,22 +15,15 @@ export class PxeBootFilesComponent implements OnInit {
availableOrganizationalUnits: any[] = [];
selectedUnitChildren: any[] = [];
dataSource: any[] = [];
-
taskForm: FormGroup;
-
loadingUnits: boolean = false;
-
ogLiveOptions: any[] = [];
-
globalOgLive: string | null = null;
-
length: number = 0;
itemsPerPage: number = 10;
page: number = 0;
pageSizeOptions: number[] = [5, 10, 20, 40, 100];
-
filters: any = {};
-
displayedColumns: string[] = ['id', 'name', 'ogLive'];
constructor(
@@ -80,22 +73,41 @@ export class PxeBootFilesComponent implements OnInit {
onOrganizationalUnitChange(): void {
const selectedUnitId = this.taskForm.get('organizationalUnit')?.value;
const selectedUnit = this.availableOrganizationalUnits.find(unit => unit['@id'] === selectedUnitId);
- if (selectedUnit && selectedUnit.children) {
- this.selectedUnitChildren = selectedUnit.children.filter((child: any) => child.type === 'classroom');
+
+ if (selectedUnit) {
+ this.selectedUnitChildren = this.getAllClassrooms(selectedUnit);
} else {
this.selectedUnitChildren = [];
}
}
+
+ getAllClassrooms(unit: any): any[] {
+ let classrooms: any[] = [];
+ if (unit.type === 'classroom') {
+ classrooms.push(unit);
+ }
+ if (unit.children) {
+ for (const child of unit.children) {
+ classrooms = classrooms.concat(this.getAllClassrooms(child));
+ }
+ }
+ return classrooms;
+ }
+
onChildChange(): void {
const selectedChildId = this.taskForm.get('selectedChild')?.value;
const selectedChild = this.selectedUnitChildren.find(child => child['@id'] === selectedChildId);
if (selectedChild && selectedChild.clients) {
- this.dataSource = selectedChild.clients;
+ this.dataSource = selectedChild.clients.map((client: { template: { [x: string]: any; }; }) => ({
+ ...client,
+ ogLive: client.template ? client.template['@id'] : null
+ }));
} else {
this.dataSource = [];
}
}
+
applyToAll(): void {
this.dataSource = this.dataSource.map(client => ({
@@ -124,7 +136,6 @@ export class PxeBootFilesComponent implements OnInit {
clients: clients
};
- console.log('Payload:', url);
this.http.post(url, payload).subscribe({
next: () => {
this.toastService.success(`Clientes guardados correctamente para la plantilla ${templateId}`);