diff --git a/ogWebconsole/src/app/components/global-status/global-status.component.ts b/ogWebconsole/src/app/components/global-status/global-status.component.ts index 0b0206c..8115ba7 100644 --- a/ogWebconsole/src/app/components/global-status/global-status.component.ts +++ b/ogWebconsole/src/app/components/global-status/global-status.component.ts @@ -2,6 +2,7 @@ import { HttpClient } from '@angular/common/http'; import { Component, OnInit } from '@angular/core'; import { ConfigService } from '@services/config.service'; import { MatTabChangeEvent } from '@angular/material/tabs'; +import {ToastrService} from "ngx-toastr"; @Component({ selector: 'app-global-status', @@ -40,6 +41,7 @@ export class GlobalStatusComponent implements OnInit { constructor( private configService: ConfigService, + private toastService: ToastrService, private http: HttpClient ) { this.baseUrl = this.configService.apiUrl; @@ -50,6 +52,56 @@ export class GlobalStatusComponent implements OnInit { ngOnInit(): void { this.loadOgBootStatus(); + this.syncSubnets() + this.syncTemplates() + this.syncOgLives() + } + + syncSubnets() { + const timeoutId = setTimeout(() => { + this.toastService.error('Error al sincronizar las subredes: tiempo de espera agotado'); + }, 3500); + + this.http.post(`${this.baseUrl}/subnets/sync`, {}).subscribe({ + next: (response) => { + clearTimeout(timeoutId); + this.toastService.success('Sincronización con componente DHCP exitosa'); + }, + error: (error) => { + clearTimeout(timeoutId); + this.toastService.error('Error al sincronizar las subredes DHCP'); + } + }); + } + + syncTemplates() { + const timeoutId = setTimeout(() => { + this.toastService.error('Error al sincronizar las plantillas Pxe: tiempo de espera agotado'); + }, 3500); + + this.http.post(`${this.baseUrl}/pxe-templates/sync`, {}) + .subscribe(response => { + clearTimeout(timeoutId); + this.toastService.success('Sincronización de las plantillas Pxe completada'); + }, error => { + clearTimeout(timeoutId); + this.toastService.error('Error al sincronizar las plantillas Pxe'); + }); + } + + syncOgLives(): void { + const timeoutId = setTimeout(() => { + this.toastService.error('Error al sincronizar las imagenes ogLive : tiempo de espera agotado'); + }, 3500); + + this.http.post(`${this.baseUrl}/og-lives/sync`, {}) + .subscribe(response => { + clearTimeout(timeoutId); + this.toastService.success('Sincronización con los ogLives completada'); + }, error => { + clearTimeout(timeoutId); + this.toastService.error('Error al sincronizar imágenes ogLive'); + }); } [key: string]: any; @@ -193,4 +245,4 @@ export class GlobalStatusComponent implements OnInit { } } } -} \ No newline at end of file +} diff --git a/ogWebconsole/src/app/components/groups/groups.component.ts b/ogWebconsole/src/app/components/groups/groups.component.ts index a4b9c43..20e52bf 100644 --- a/ogWebconsole/src/app/components/groups/groups.component.ts +++ b/ogWebconsole/src/app/components/groups/groups.component.ts @@ -421,7 +421,7 @@ export class GroupsComponent implements OnInit, OnDestroy { width: '900px', }); dialogRef.afterClosed().subscribe((newUnit) => { - if (newUnit?.uuid) { + if (newUnit) { this.refreshData(newUnit.uuid); } }); diff --git a/ogWebconsole/src/app/components/ogboot/pxe-images/pxe-images.component.html b/ogWebconsole/src/app/components/ogboot/pxe-images/pxe-images.component.html index 72cce0c..bf13061 100644 --- a/ogWebconsole/src/app/components/ogboot/pxe-images/pxe-images.component.html +++ b/ogWebconsole/src/app/components/ogboot/pxe-images/pxe-images.component.html @@ -1,5 +1,3 @@ - -
- - +
{{ column.header }} diff --git a/ogWebconsole/src/app/components/ogboot/pxe/pxe.component.ts b/ogWebconsole/src/app/components/ogboot/pxe/pxe.component.ts index a07895f..55cb6ad 100644 --- a/ogWebconsole/src/app/components/ogboot/pxe/pxe.component.ts +++ b/ogWebconsole/src/app/components/ogboot/pxe/pxe.component.ts @@ -1,5 +1,5 @@ import { HttpClient } from '@angular/common/http'; -import { Component } from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import { CreatePxeTemplateComponent } from './create-pxeTemplate/create-pxe-template.component'; import { MatDialog } from '@angular/material/dialog'; import { MatTableDataSource } from '@angular/material/table'; @@ -19,7 +19,7 @@ import { ConfigService } from '@services/config.service'; templateUrl: './pxe.component.html', styleUrls: ['./pxe.component.css'] }) -export class PxeComponent { +export class PxeComponent implements OnInit{ baseUrl: string; private apiUrl: string; pxeTemplates: any[] = []; @@ -76,7 +76,6 @@ export class PxeComponent { this.loading = true; this.search(); this.loadAlert() - this.syncTemplates() this.loading = false; } @@ -147,17 +146,6 @@ export class PxeComponent { const dialogRef = this.dialog.open(ShowTemplateContentComponent, { data: { data }, width: '700px' }); } - syncTemplates() { - this.http.post(`${this.apiUrl}/sync`, {}) - .subscribe(response => { - this.toastService.success('Sincronización completada'); - this.search() - }, error => { - console.error('Error al sincronizar', error); - this.toastService.error('Error al sincronizar'); - }); - } - applyFilter() { this.http.get(`${this.apiUrl}?page=${this.page}&itemsPerPage=${this.itemsPerPage}`).subscribe({ next: (response) => { diff --git a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets.component.ts b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets.component.ts index cd14ce3..8d59124 100644 --- a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets.component.ts +++ b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets.component.ts @@ -69,19 +69,21 @@ export class OgDhcpSubnetsComponent implements OnInit { } ngOnInit() { - this.loading = true; this.loadAlert() - this.syncSubnets() + this.loadSubnets() } loadSubnets() { + this.loading = true; this.http.get(`${this.baseUrl}/subnets?page=${this.page + 1}&itemsPerPage=${this.itemsPerPage}`).subscribe({ next: (response) => { this.dataSource.data = response['hydra:member']; this.length = response['hydra:totalItems']; + this.loading = false; }, error: error => { this.toastService.error(error.error['hydra:description']); + this.loading = false; } }); @@ -90,28 +92,6 @@ export class OgDhcpSubnetsComponent implements OnInit { } } - syncSubnets() { - 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.loading = false; - }, - error: (error) => { - clearTimeout(timeoutId); - this.loading = false; - this.toastService.error('Error al sincronizar'); - } - }); - } - toggleAction(subnet: any, action: string): void { switch (action) { case 'get':