diff --git a/ogWebconsole/src/app/app.module.ts b/ogWebconsole/src/app/app.module.ts
index 9e965d8..6133f67 100644
--- a/ogWebconsole/src/app/app.module.ts
+++ b/ogWebconsole/src/app/app.module.ts
@@ -81,8 +81,8 @@ import { CreatePxeBootFileComponent } from './components/ogboot/pxe-boot-files/c
import { NgxChartsModule } from '@swimlane/ngx-charts';
import { OgdhcpComponent } from './components/ogdhcp/ogdhcp.component';
import { OgDhcpSubnetsComponent } from './components/ogdhcp/og-dhcp-subnets/og-dhcp-subnets.component';
-import { CreateSubnetComponent } from './components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component';
-
+import { CreateSubnetComponent } from './components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet.component';
+import { AddClientsToSubnetComponent } from './components/ogdhcp/og-dhcp-subnets/add-clients-to-subnet/add-clients-to-subnet.component';
@NgModule({
declarations: [
AppComponent,
@@ -123,7 +123,8 @@ import { CreateSubnetComponent } from './components/ogdhcp/og-dhcp-subnets/creat
CreatePxeBootFileComponent,
OgdhcpComponent,
OgDhcpSubnetsComponent,
- CreateSubnetComponent
+ CreateSubnetComponent,
+ AddClientsToSubnetComponent
],
bootstrap: [AppComponent],
imports: [BrowserModule,
diff --git a/ogWebconsole/src/app/components/groups/groups.component.ts b/ogWebconsole/src/app/components/groups/groups.component.ts
index b717117..981fd9f 100644
--- a/ogWebconsole/src/app/components/groups/groups.component.ts
+++ b/ogWebconsole/src/app/components/groups/groups.component.ts
@@ -251,8 +251,6 @@ export class GroupsComponent implements OnInit {
onEditClick(event: MouseEvent, type: any, uuid: string): void {
event.stopPropagation();
- console.log('Tipo del elemento a editar:', type);
- console.log('UUID del elemento a editar:', uuid);
if (type != "client") {
const dialogRef = this.dialog.open(EditOrganizationalUnitComponent, { data: { uuid }, width: '700px'});
} else {
diff --git a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/add-clients-to-subnet/add-clients-to-subnet.component.css b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/add-clients-to-subnet/add-clients-to-subnet.component.css
new file mode 100644
index 0000000..897597c
--- /dev/null
+++ b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/add-clients-to-subnet/add-clients-to-subnet.component.css
@@ -0,0 +1,17 @@
+.loading-container {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ height: 100px;
+ }
+
+ mat-form-field {
+ width: 100%;
+ }
+
+ mat-dialog-actions {
+ display: flex;
+ justify-content: flex-end;
+ }
+
\ No newline at end of file
diff --git a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/add-clients-to-subnet/add-clients-to-subnet.component.html b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/add-clients-to-subnet/add-clients-to-subnet.component.html
new file mode 100644
index 0000000..47ba9d5
--- /dev/null
+++ b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/add-clients-to-subnet/add-clients-to-subnet.component.html
@@ -0,0 +1,21 @@
+
Select Clients
+
+
+
+
+
Cargando clientes...
+
+
+ Select Clients
+
+
+ {{ client.name }} (IP: {{ client.ip }}, MAC: {{ client.mac }})
+
+
+
+
+
+
+
+
+
diff --git a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/add-clients-to-subnet/add-clients-to-subnet.component.spec.ts b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/add-clients-to-subnet/add-clients-to-subnet.component.spec.ts
new file mode 100644
index 0000000..f503290
--- /dev/null
+++ b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/add-clients-to-subnet/add-clients-to-subnet.component.spec.ts
@@ -0,0 +1,23 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { AddClientsToSubnetComponent } from './add-clients-to-subnet.component';
+
+describe('AddClientsToSubnetComponent', () => {
+ let component: AddClientsToSubnetComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [AddClientsToSubnetComponent]
+ })
+ .compileComponents();
+
+ fixture = TestBed.createComponent(AddClientsToSubnetComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/add-clients-to-subnet/add-clients-to-subnet.component.ts b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/add-clients-to-subnet/add-clients-to-subnet.component.ts
new file mode 100644
index 0000000..7cb5901
--- /dev/null
+++ b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/add-clients-to-subnet/add-clients-to-subnet.component.ts
@@ -0,0 +1,45 @@
+import { Component, OnInit } from '@angular/core';
+import { HttpClient } from '@angular/common/http';
+import { MatDialogRef } from '@angular/material/dialog';
+
+@Component({
+ selector: 'app-add-clients-to-subnet',
+ templateUrl: './add-clients-to-subnet.component.html',
+ styleUrls: ['./add-clients-to-subnet.component.css']
+})
+export class AddClientsToSubnetComponent implements OnInit {
+ clients: any[] = [];
+ selectedClients: any[] = [];
+ loading: boolean = true; // Variable para controlar el estado de carga
+
+ constructor(
+ private http: HttpClient,
+ public dialogRef: MatDialogRef
+ ) {}
+
+ ngOnInit(): void {
+ // Comienza la carga
+ this.loading = true;
+
+ // Hacer la llamada HTTP directamente en el componente
+ this.http.get('http://127.0.0.1:8080/clients?page=1&itemsPerPage=30').subscribe(
+ response => {
+ this.clients = response['hydra:member']; // Asignamos los clientes obtenidos a la variable clients
+ this.loading = false; // Los datos se han cargado, desactivar el spinner
+ },
+ error => {
+ console.error('Error fetching clients:', error);
+ this.loading = false; // También detener el spinner en caso de error
+ }
+ );
+ }
+
+ save() {
+ console.log('Selected clients:', this.selectedClients);
+ this.dialogRef.close(this.selectedClients); // Cierra el modal y pasa los clientes seleccionados
+ }
+
+ close() {
+ this.dialogRef.close();
+ }
+}
diff --git a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.css b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet.component.css
similarity index 100%
rename from ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.css
rename to ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet.component.css
diff --git a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet.component.html b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet.component.html
new file mode 100644
index 0000000..c3ff12a
--- /dev/null
+++ b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet.component.html
@@ -0,0 +1,27 @@
+Añadir configuración de red
+
+
+ Nombre
+
+
+
+ Netmask
+
+
+
+ Dirección IP
+
+
+
+ Next Server
+
+
+
+ Boot File Name
+
+
+
+
+
+
+
diff --git a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.spec.ts b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet.component.spec.ts
similarity index 100%
rename from ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.spec.ts
rename to ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet.component.spec.ts
diff --git a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet.component.ts b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet.component.ts
new file mode 100644
index 0000000..8853c6f
--- /dev/null
+++ b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet.component.ts
@@ -0,0 +1,55 @@
+import { HttpClient } from '@angular/common/http';
+import { Component, Inject, OnInit } from '@angular/core';
+import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
+import { ToastrService } from 'ngx-toastr';
+
+@Component({
+ selector: 'app-create-subnet',
+ templateUrl: './create-subnet.component.html',
+ styleUrls: ['./create-subnet.component.css']
+})
+export class CreateSubnetComponent implements OnInit {
+ name: string = '';
+ netmask: string = '';
+ ipAddress: string = '';
+ nextServer: string = '';
+ bootFileName: string = '';
+
+ constructor(
+ private toastService: ToastrService,
+ private http: HttpClient,
+ public dialogRef: MatDialogRef,
+ @Inject(MAT_DIALOG_DATA) public data: any
+ ) { }
+
+ ngOnInit(): void {
+
+ }
+
+ onNoClick(): void {
+ this.dialogRef.close();
+ }
+
+ addNetworkConfig(): void {
+ const payload = {
+ name: this.name,
+ netmask: this.netmask,
+ ipAddress: this.ipAddress,
+ nextServer: this.nextServer,
+ bootFileName: this.bootFileName
+ };
+
+ this.http.post('http://127.0.0.1:8080/subnets', payload)
+ .subscribe({
+ next: (response) => {
+ console.log('Success:', response);
+ this.toastService.success('Configuración de red añadida exitosamente');
+ this.dialogRef.close();
+ },
+ error: (error) => {
+ console.error('Error:', error);
+ this.toastService.error('Error al añadir la configuración de red');
+ }
+ });
+ }
+}
diff --git a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.html b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.html
deleted file mode 100644
index 2fcc08a..0000000
--- a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.html
+++ /dev/null
@@ -1,70 +0,0 @@
-{{ isEditMode ? 'Editar' : 'Añadir' }} configuración de red
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.ts b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.ts
deleted file mode 100644
index 55713c4..0000000
--- a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.ts
+++ /dev/null
@@ -1,137 +0,0 @@
-import { HttpClient } from '@angular/common/http';
-import { Component, Inject, OnInit } from '@angular/core';
-import { FormGroup, FormBuilder, Validators } from '@angular/forms';
-import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
-import { ToastrService } from 'ngx-toastr';
-
-@Component({
- selector: 'app-create-subnet',
- templateUrl: './create-subnet.component.html',
- styleUrls: ['./create-subnet.component.css']
-})
-export class CreateSubnetComponent implements OnInit {
- aulasForm: FormGroup;
- subnetForm: FormGroup;
-
- aulas: any[] = []; // Lista de aulas
- selectedAulas: any[] = []; // Aulas seleccionadas
- nextServerOptions: string[] = []; // Opciones de Next Server
- bootFileNameOptions: string[] = []; // Opciones de Boot File Name
- isEditMode: boolean = false;
-
- constructor(
- private fb: FormBuilder, // FormBuilder para manejar los formularios
- private toastService: ToastrService,
- private http: HttpClient,
- public dialogRef: MatDialogRef,
- @Inject(MAT_DIALOG_DATA) public data: any
- ) {
- // Inicializar los formularios
- this.aulasForm = this.fb.group({
- selectedAulas: [[], Validators.required]
- });
-
- this.subnetForm = this.fb.group({
- name: ['', Validators.required],
- netmask: ['', Validators.required],
- ipAddress: ['', Validators.required],
- nextServer: ['', Validators.required],
- bootFileName: ['', Validators.required]
- });
- }
-
- ngOnInit(): void {
- this.loadAulas(); // Cargar las aulas al iniciar el componente
-
- if (this.data && this.data.subnet) {
- this.isEditMode = true;
- this.subnetForm.patchValue({
- name: this.data.subnet.name,
- netmask: this.data.subnet.netmask,
- ipAddress: this.data.subnet.ipAddress,
- nextServer: this.data.subnet.nextServer,
- bootFileName: this.data.subnet.bootFileName
- });
- this.selectedAulas = this.data.subnet.selectedAulas || [];
- this.updateServerAndBootFileOptions();
- }
- }
-
- loadAulas(): void {
- this.http.get('http://127.0.0.1:8001/organizational-units?page=1&itemsPerPage=30')
- .subscribe(response => {
- this.aulas = response['hydra:member'];
- }, error => {
- console.error('Error loading aulas:', error);
- this.toastService.error('Error al cargar las aulas');
- });
- }
-
- onAulasSelectionChange(event: any): void {
- this.selectedAulas = event.value;
- this.updateServerAndBootFileOptions();
- }
-
- updateServerAndBootFileOptions(): void {
- // Vaciar las opciones previas
- this.nextServerOptions = [];
- this.bootFileNameOptions = [];
-
- // Agregar las opciones de "nextServer" y "bootFileName" basadas en las aulas seleccionadas
- this.selectedAulas.forEach(aula => {
- if (aula.networkSettings) {
- if (aula.networkSettings.nextServer && !this.nextServerOptions.includes(aula.networkSettings.nextServer)) {
- this.nextServerOptions.push(aula.networkSettings.nextServer);
- }
- if (aula.networkSettings.bootFileName && !this.bootFileNameOptions.includes(aula.networkSettings.bootFileName)) {
- this.bootFileNameOptions.push(aula.networkSettings.bootFileName);
- }
- }
- });
- }
-
- onNoClick(): void {
- this.dialogRef.close();
- }
-
- submitForm(): void {
- if (this.aulasForm.invalid || this.subnetForm.invalid) {
- this.toastService.error('Por favor, complete los formularios.');
- return;
- }
-
- const payload = {
- ...this.subnetForm.value,
- /* selectedAulas: this.selectedAulas.map(aula => aula.uuid) */// Enviar solo los UUID de las aulas seleccionadas
- };
-
- if (this.isEditMode) {
- this.http.patch(`http://127.0.0.1:8001/subnets/${this.data.subnet.uuid}`, payload)
- .subscribe({
- next: (response) => {
- console.log('Success:', response);
- this.toastService.success('Configuración de red actualizada exitosamente');
- this.dialogRef.close();
- },
- error: (error) => {
- console.error('Error:', error);
- this.toastService.error('Error al actualizar la configuración de red');
- }
- });
- } else {
-
- this.http.post('http://127.0.0.1:8001/subnets', payload)
- .subscribe({
- next: (response) => {
- console.log('Success:', response);
- this.toastService.success('Configuración de red añadida exitosamente');
- this.dialogRef.close();
- },
- error: (error) => {
- console.error('Error:', error);
- this.toastService.error('Error al añadir la configuración de red');
- }
- });
- }
- }
-}
diff --git a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/og-dhcp-subnets.component.css b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/og-dhcp-subnets.component.css
index 1ae51cc..9b093f0 100644
--- a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/og-dhcp-subnets.component.css
+++ b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/og-dhcp-subnets.component.css
@@ -106,4 +106,3 @@ table {
.example-button-row .mat-mdc-button-base {
margin: 8px 8px 8px 0;
}
-
diff --git a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/og-dhcp-subnets.component.html b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/og-dhcp-subnets.component.html
index 100f665..10a1408 100644
--- a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/og-dhcp-subnets.component.html
+++ b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/og-dhcp-subnets.component.html
@@ -1,73 +1,90 @@
-
-