refs #2972. Integration remove leases ogDhcp
testing/ogGui-multibranch/pipeline/head There was a failure building this commit
Details
testing/ogGui-multibranch/pipeline/head There was a failure building this commit
Details
parent
fccbb26dac
commit
299ced8b27
|
|
@ -38,6 +38,7 @@ export class ExecuteCommandComponent implements OnInit {
|
|||
{ translationKey: 'executeCommands.hardwareInventory', slug: 'hardware-inventory', disabled: false },
|
||||
{ translationKey: 'executeCommands.runScript', slug: 'run-script', disabled: false },
|
||||
{ translationKey: 'executeCommands.refresh', slug: 'refresh', disabled: false },
|
||||
{ translationKey: 'executeCommands.deleteLease', slug: 'delete-lease', disabled: false },
|
||||
];
|
||||
|
||||
client: any = {};
|
||||
|
|
@ -81,7 +82,8 @@ export class ExecuteCommandComponent implements OnInit {
|
|||
'hardware-inventory',
|
||||
'remove-cache-image',
|
||||
'partition',
|
||||
'refresh'
|
||||
'refresh',
|
||||
'delete-lease'
|
||||
],
|
||||
'ou-minimal': [
|
||||
'power-on',
|
||||
|
|
@ -184,6 +186,10 @@ export class ExecuteCommandComponent implements OnInit {
|
|||
if (action === 'refresh') {
|
||||
this.refreshClient();
|
||||
}
|
||||
|
||||
if (action === 'delete-lease') {
|
||||
this.deleteClientLease();
|
||||
}
|
||||
}
|
||||
|
||||
rebootClient(): void {
|
||||
|
|
@ -395,4 +401,26 @@ export class ExecuteCommandComponent implements OnInit {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
deleteClientLease(): void {
|
||||
if (this.clientData.length === 0) {
|
||||
this.toastService.error('No hay clientes seleccionados');
|
||||
return;
|
||||
}
|
||||
|
||||
const requests = this.clientData.map((client: any) =>
|
||||
this.http.delete(`${this.baseUrl}/clients/${client.uuid}/delete-lease`).toPromise()
|
||||
);
|
||||
|
||||
Promise.allSettled(requests).then(results => {
|
||||
const errors = results.filter(r => r.status === 'rejected');
|
||||
if (errors.length === 0) {
|
||||
this.toastService.success('Lease(s) DHCP eliminada(s) correctamente');
|
||||
} else if (errors.length < results.length) {
|
||||
this.toastService.warning(`${results.length - errors.length} lease(s) eliminada(s), ${errors.length} con error`);
|
||||
} else {
|
||||
this.toastService.error('Error al eliminar las leases DHCP');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@
|
|||
</button>
|
||||
<button mat-icon-button color="primary"
|
||||
(click)="addClientsToSubnet(subnet)"><mat-icon>computer</mat-icon></button>
|
||||
<button mat-icon-button color="primary" (click)="deleteSubnetLeases(subnet)"
|
||||
matTooltip="Borrar leases de la subred"><mat-icon>delete_sweep</mat-icon></button>
|
||||
<button mat-icon-button color="warn" (click)="toggleAction(subnet, 'delete')"><mat-icon>delete</mat-icon></button>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
|
|
|||
|
|
@ -296,6 +296,26 @@ export class OgDhcpSubnetsComponent implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
deleteSubnetLeases(subnet: Subnet) {
|
||||
const dialogRef = this.dialog.open(DeleteModalComponent, {
|
||||
width: '300px',
|
||||
data: { name: `leases de ${subnet.name}` }
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe(result => {
|
||||
if (result) {
|
||||
this.http.delete(`${this.baseUrl}/og-dhcp/server/${subnet.uuid}/delete-leases`, {}).subscribe({
|
||||
next: () => {
|
||||
this.toastService.success('Leases de la subred eliminadas correctamente');
|
||||
},
|
||||
error: (error) => {
|
||||
this.toastService.error(error.error?.['hydra:description'] || 'Error al eliminar leases de la subred');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
addClientsToSubnet(subnet: Subnet) {
|
||||
const dialogRef = this.dialog.open(AddClientsToSubnetComponent, {
|
||||
width: '800px',
|
||||
|
|
|
|||
|
|
@ -78,6 +78,10 @@
|
|||
<ng-container matColumnDef="actions">
|
||||
<th mat-header-cell *matHeaderCellDef i18n="@@columnActions" style="text-align: center;">Acciones</th>
|
||||
<td mat-cell *matCellDef="let client" style="text-align: center;">
|
||||
<button mat-icon-button color="primary" (click)="deleteClientLease(client)"
|
||||
matTooltip="Borrar lease del cliente">
|
||||
<mat-icon>delete_sweep</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button color="warn" (click)="deleteClient(client)">
|
||||
<mat-icon i18n="@@deleteElementTooltip">delete</mat-icon>
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -75,6 +75,26 @@ export class ShowClientsComponent implements OnInit {
|
|||
);
|
||||
}
|
||||
|
||||
deleteClientLease(client: any): void {
|
||||
const dialogRef = this.dialog.open(DeleteModalComponent, {
|
||||
width: '300px',
|
||||
data: { name: `lease de ${client.name}` }
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe(result => {
|
||||
if (result) {
|
||||
this.http.delete(`${this.baseUrl}/og-dhcp/server/${this.data.subnetUuid}/delete-lease/${client.uuid}`, {}).subscribe({
|
||||
next: () => {
|
||||
this.toastService.success('Lease del cliente eliminada correctamente');
|
||||
},
|
||||
error: (error) => {
|
||||
this.toastService.error(error.error?.['hydra:description'] || 'Error al eliminar lease del cliente');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
deleteClient(client: any): void {
|
||||
const dialogRef = this.dialog.open(DeleteModalComponent, {
|
||||
width: '300px',
|
||||
|
|
|
|||
|
|
@ -592,7 +592,8 @@
|
|||
"softwareInventory": "Software Inventory",
|
||||
"hardwareInventory": "Hardware Inventory",
|
||||
"runScript": "Run Script",
|
||||
"refresh": "Refresh"
|
||||
"refresh": "Refresh",
|
||||
"deleteLease": "Delete DHCP Lease"
|
||||
},
|
||||
"changeOU": "Change Organizational Unit",
|
||||
"moveClientsTooltip": "Move clients to another organizational unit",
|
||||
|
|
|
|||
|
|
@ -593,7 +593,8 @@
|
|||
"softwareInventory": "Inventario Software",
|
||||
"hardwareInventory": "Inventario Hardware",
|
||||
"runScript": "Ejecutar script",
|
||||
"refresh": "Refrescar"
|
||||
"refresh": "Refrescar",
|
||||
"deleteLease": "Borrar lease DHCP"
|
||||
},
|
||||
"changeOU": "Mover",
|
||||
"moveClientsTooltip": "Mover clientes a otra unidad organizativa",
|
||||
|
|
|
|||
Loading…
Reference in New Issue