From e943da71112c3c3344e8558e5949ea0e54b5f1dd Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Fri, 22 Nov 2024 12:26:29 +0100 Subject: [PATCH] Big updates dhcp subnets --- .../add-clients-to-subnet.component.css | 37 ++++++++------- .../add-clients-to-subnet.component.html | 13 ++--- .../add-clients-to-subnet.component.ts | 47 ++++--------------- .../og-dhcp-subnets.component.css | 23 ++++----- .../og-dhcp-subnets.component.html | 28 ++--------- .../og-dhcp-subnets.component.ts | 13 +++-- 6 files changed, 51 insertions(+), 110 deletions(-) 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 index 897597c..2239479 100644 --- 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 @@ -1,17 +1,22 @@ .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 + 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; +} + +.checkbox-group { + display: flex; + flex-direction: column; + gap: 10px; +} 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 index 44ec007..87ed097 100644 --- 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 @@ -2,23 +2,16 @@ - Unidad Organizativa - + Seleccione aula + {{ unit.name }} - - Subunidad Organizativa - - {{ child.name }} - - -
- {{ client.name }} 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 index 33dbecd..6b7bd34 100644 --- 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 @@ -12,7 +12,6 @@ import { ToastrService } from 'ngx-toastr'; export class AddClientsToSubnetComponent implements OnInit { baseUrl: string = import.meta.env.NG_APP_BASE_API_URL; units: any[] = []; - childUnits: any[] = []; clients: any[] = []; selectedClients: string[] = []; loading: boolean = true; @@ -32,38 +31,22 @@ export class AddClientsToSubnetComponent implements OnInit { } loadUnits() { - this.http.get(`${this.baseUrl}/organizational-units?page=1&itemsPerPage=50`).subscribe( + this.http.get(`${this.baseUrl}/organizational-units?type=classroom&page=1&itemsPerPage=50`).subscribe( response => { - this.units = response['hydra:member'].filter((unit: { type: string; }) => unit.type === 'organizational-unit'); + this.units = response['hydra:member']; this.loading = false; }, error => console.error('Error fetching organizational units:', error) ); } - onUnitChange(unitId: string): void { - const unit = this.units.find(unit => unit.uuid === unitId); - this.childUnits = unit ? this.getAllChildren(unit) : []; - this.clients = []; - this.childUnitControl.setValue(null); - this.selectedClients = []; - } - - getAllChildren(unit: any): any[] { - let allChildren = []; - if (unit.children && unit.children.length > 0) { - for (const child of unit.children) { - allChildren.push(child); - allChildren = allChildren.concat(this.getAllChildren(child)); - } - } - return allChildren; - } - - onChildUnitChange(childUnitId: string): void { - const childUnit = this.childUnits.find(unit => unit.uuid === childUnitId); - this.clients = childUnit && childUnit.clients ? childUnit.clients : []; - this.selectedClients = []; + loadChildUnits(unitId: string) { + this.http.get(`${this.baseUrl}/clients?parent.id${unitId}`).subscribe( + response => { + this.clients = response['hydra:member']; + }, + error => console.error('Error fetching child units:', error) + ); } toggleClientSelection(clientId: string): void { @@ -75,18 +58,6 @@ export class AddClientsToSubnetComponent implements OnInit { } } - toggleSelectAll(): void { - if (this.areAllClientsSelected()) { - this.selectedClients = []; - } else { - this.selectedClients = this.clients.map(client => client.uuid); - } - } - - areAllClientsSelected(): boolean { - return this.selectedClients.length === this.clients.length; - } - save() { this.selectedClients.forEach(clientId => { const postData = { client: `/clients/${clientId}` }; 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 27f82b3..f01f981 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 @@ -38,7 +38,6 @@ table { } .header-container { - margin-top: 16px; display: flex; justify-content: space-between; align-items: center; @@ -58,20 +57,14 @@ table { margin-bottom: 30px; } -.example-headers-align .mat-expansion-panel-header-description { - justify-content: space-between; - align-items: center; +mat-spinner { + margin: 0 auto; + align-self: center; } -.example-headers-align .mat-mdc-form-field + .mat-mdc-form-field { - margin-left: 8px; -} - -.example-button-row { - display: table-cell; - max-width: 600px; -} - -.example-button-row .mat-mdc-button-base { - margin: 8px 8px 8px 0; +.subnets-button-row { + display: flex; + justify-content: flex-end; + margin-bottom: 20px; + gap: 10px; } 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 3641600..903ebd5 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,23 +1,10 @@ - - - - Información en servidor ogDHCP - -
- -
-
- -
-
-
-

Administrar Subredes

+
@@ -52,8 +39,8 @@
- - + +
diff --git a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/og-dhcp-subnets.component.ts b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/og-dhcp-subnets.component.ts index 3d49acd..dfec859 100644 --- a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/og-dhcp-subnets.component.ts +++ b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/og-dhcp-subnets.component.ts @@ -35,7 +35,7 @@ export interface Subnet { }) export class OgDhcpSubnetsComponent { baseUrl: string = import.meta.env.NG_APP_BASE_API_URL; - displayedColumns: string[] = ['id', 'name', 'netmask', 'ipAddress', 'nextServer', 'bootFileName', 'synchronized', 'serverId', 'clients', 'actions']; + displayedColumns: string[] = ['id', 'name', 'netmask', 'ipAddress', 'synchronized', 'serverId', 'clients', 'actions']; dataSource = new MatTableDataSource([]); length = 0; itemsPerPage: number = 10; @@ -43,6 +43,7 @@ export class OgDhcpSubnetsComponent { filters: { [key: string]: string } = {}; pageSizeOptions: number[] = [5, 10, 20]; alertMessage: string | null = null; + loading:boolean = false; @ViewChild(MatPaginator) paginator: MatPaginator | undefined; @@ -51,8 +52,6 @@ export class OgDhcpSubnetsComponent { { columnDef: 'name', header: 'Name', cell: (subnet: Subnet) => subnet.name }, { columnDef: 'netmask', header: 'Netmask', cell: (subnet: Subnet) => subnet.netmask }, { columnDef: 'ipAddress', header: 'IP Address', cell: (subnet: Subnet) => subnet.ipAddress }, - { columnDef: 'nextServer', header: 'Next Server', cell: (subnet: Subnet) => subnet.nextServer }, - { columnDef: 'bootFileName', header: 'Boot File Name', cell: (subnet: Subnet) => subnet.bootFileName }, { columnDef: 'synchronized', header: 'Sincronizado', cell: (subnet: Subnet) => `${subnet.synchronized}` }, { columnDef: 'serverId', header: 'Id Servidor DHCP', cell: (subnet: Subnet) => subnet.serverId }, { columnDef: 'clients', header: 'Lista de clientes', cell: (subnet: Subnet) => `${subnet.clients}` }, @@ -64,8 +63,11 @@ export class OgDhcpSubnetsComponent { private joyrideService: JoyrideService) { } ngOnInit() { + this.loading = true; this.loadSubnets(); this.loadAlert() + this.syncSubnets() + this.loading = false; } loadSubnets() { @@ -87,7 +89,7 @@ export class OgDhcpSubnetsComponent { syncSubnets() { this.http.post(`${this.apiUrl}/sync`, {}) .subscribe(response => { - this.toastService.success('Sincronización completada'); + this.toastService.success('Sincronización con componente DHCP exitosa'); this.loadSubnets() }, error => { console.error('Error al sincronizar', error); @@ -224,9 +226,6 @@ export class OgDhcpSubnetsComponent { iniciarTour(): void { this.joyrideService.startTour({ steps: [ - 'serverInfoStep', - 'syncDbStep', - 'viewInfoStep', 'titleStep', 'addSubnetStep', 'searchNameStep',
{{ column.header }} @@ -84,15 +71,8 @@ + - - - - - -