Improve subnet synchronization with loading state and error handling
testing/ogGui-multibranch/pipeline/head Build queued... Details

pull/19/head
Lucas Lara García 2025-04-02 14:05:53 +02:00
parent 4d32540784
commit 5baf4d8e3d
1 changed files with 15 additions and 5 deletions

View File

@ -91,15 +91,25 @@ export class OgDhcpSubnetsComponent implements OnInit {
}
syncSubnets() {
this.http.post(`${this.apiUrl}/sync`, {})
.subscribe(response => {
this.loading = true;
const timeoutId = setTimeout(() => {
this.loading = false;
this.toastService.error('Error al sincronizar: tiempo de espera agotado');
}, 3500);
this.http.post(`${this.apiUrl}/sync`, {}).subscribe({
next: (response) => {
clearTimeout(timeoutId);
this.toastService.success('Sincronización con componente DHCP exitosa');
this.loadSubnets()
this.loadSubnets();
this.loading = false;
}, error => {
},
error: (error) => {
clearTimeout(timeoutId);
this.loading = false;
this.toastService.error('Error al sincronizar');
});
}
});
}
toggleAction(subnet: any, action: string): void {