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 156f782..84e406d 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 @@ -22,7 +22,7 @@ OgLive - {{ oglive.name }} + {{ oglive.filename }} 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 dbc6f6b..138f0ad 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 @@ -19,12 +19,9 @@ export class CreateClientComponent implements OnInit { ogLives: any[] = []; menus: any[] = []; templates: any[] = []; - uploadedClients: any[] = []; repositories: any[] = []; loading: boolean = false; displayedColumns: string[] = ['name', 'ip']; - isSingleClientForm: boolean = false; - showTextarea: boolean = true; protected netifaceTypes = [ { name: 'Eth0', value: 'eth0' }, { name: 'Eth1', value: 'eth1' }, @@ -158,54 +155,17 @@ export class CreateClientComponent implements OnInit { } onSubmit(): void { - if (this.isSingleClientForm) { - if (this.clientForm.valid) { - const formData = this.clientForm.value; - console.log('Form data:', formData); - this.http.post(`${this.baseUrl}/clients`, formData).subscribe( - response => { - this.toastService.success('Cliente creado exitosamente', 'Éxito'); - this.dialogRef.close(response); - }, - error => { - console.error('Error durante POST:', error); - this.toastService.error('Error al crear el cliente', 'Error'); - } - ); - } - } else { - if (this.uploadedClients.length > 0) { - this.uploadedClients.forEach(client => { - const formData = { - organizationalUnit: this.clientForm.value.organizationalUnit || null, - name: client.name || null, - mac: client.mac || null, - ip: client.ip || null, - template: this.clientForm.value.template || null, - hardwareProfile: this.clientForm.value.hardwareProfile || null, - ogLive: this.clientForm.value.ogLive || null, - repository: this.clientForm.value.repository || null, - serialNumber: null, - netiface: null, - netDriver: null - }; - - this.http.post(`${this.baseUrl}/clients`, formData).subscribe( - response => { - this.toastService.success(`Cliente ${client.name} creado exitosamente`, 'Éxito'); - }, - error => { - console.error(`Error al crear el cliente ${client.name}:`, error); - this.toastService.error(`Error al crear el cliente ${client.name}`, 'Error'); - } - ); - }); - - this.uploadedClients = []; - this.dialogRef.close(); - } else { - this.toastService.error('No hay clientes cargados para añadir', 'Error'); - } + if (this.clientForm.valid) { + const formData = this.clientForm.value; + this.http.post(`${this.baseUrl}/clients`, formData).subscribe( + response => { + this.toastService.success('Cliente creado exitosamente', 'Éxito'); + this.dialogRef.close(response); + }, + error => { + this.toastService.error('Error al crear el cliente', 'Error'); + } + ); } } 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 2c6efb1..fda236e 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 @@ -9,7 +9,7 @@ {{ 'typeLabel' | translate }} - + {{ typeTranslations[type] }} 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 cfbc9ed..5790568 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 @@ -40,6 +40,7 @@ export class CreateOrganizationalUnitComponent implements OnInit { repositories: any[] = []; selectedCalendarUuid: string | null = null; + @Output() unitAdded = new EventEmitter(); constructor( @@ -96,6 +97,10 @@ export class CreateOrganizationalUnitComponent implements OnInit { this.loadRepositories(); } + get filteredTypes(): string[] { + return this.generalFormGroup.get('parent')?.value ? this.types.filter(type => type !== 'organizational-unit') : this.types; + } + loadParentUnits() { const url = `${this.baseUrl}/organizational-units?page=1&itemsPerPage=1000`; this.http.get(url).subscribe( 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 8e0bf3b..e1c72e1 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 @@ -8,7 +8,7 @@ {{ 'typeLabel' | translate }} - {{ type }} + {{ type }} 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 92ab79a..a1a3188 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 @@ -98,6 +98,10 @@ export class EditOrganizationalUnitComponent implements OnInit { this.loadRepositories(); } + get filteredTypes(): string[] { + return this.generalFormGroup.get('parent')?.value ? this.types.filter(type => type !== 'organizational-unit') : this.types; + } + loadParentUnits() { const url = `${this.baseUrl}/organizational-units?page=1&itemsPerPage=10000`;