From 2a8cd04129b57e9abc4e65bc7c826bd214b09f22 Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Tue, 20 Aug 2024 12:42:45 +0200 Subject: [PATCH] Improvements sync ogCore --- .../images/images/images.component.css | 10 ++++++++ .../images/images/images.component.html | 4 ++++ .../images/images/images.component.ts | 23 ++++++++++++++++--- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/ogWebconsole/src/app/components/images/images/images.component.css b/ogWebconsole/src/app/components/images/images/images.component.css index de78773..1ae51cc 100644 --- a/ogWebconsole/src/app/components/images/images/images.component.css +++ b/ogWebconsole/src/app/components/images/images/images.component.css @@ -97,3 +97,13 @@ table { .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; +} + diff --git a/ogWebconsole/src/app/components/images/images/images.component.html b/ogWebconsole/src/app/components/images/images/images.component.html index 3a310b2..d5f74ef 100644 --- a/ogWebconsole/src/app/components/images/images/images.component.html +++ b/ogWebconsole/src/app/components/images/images/images.component.html @@ -8,6 +8,10 @@

Oglives creados en servidor ogBoot: {{ alertMessage }}

Oglives creados en servidor ogCore (base de datos): {{ length }}

+ +
+ +
diff --git a/ogWebconsole/src/app/components/images/images/images.component.ts b/ogWebconsole/src/app/components/images/images/images.component.ts index 3686993..8075122 100644 --- a/ogWebconsole/src/app/components/images/images/images.component.ts +++ b/ogWebconsole/src/app/components/images/images/images.component.ts @@ -108,10 +108,12 @@ export class ImagesComponent implements OnInit { this.http.post(`${this.apiUrl}/server/${image.uuid}/set-default`, {}).subscribe({ next: () => { console.log('Imagen cambiada'); + this.toastService.success('Petición de cambio de imagen enviada'); this.loadImages(); }, error: (error) => { console.error('Error al cambiar la imagen:', error); + this.toastService.error('Error al instalar la imagen por defecto'); } }); break; @@ -119,10 +121,12 @@ export class ImagesComponent implements OnInit { this.http.post(`${this.apiUrl}/server/${image.uuid}/install`, {}).subscribe({ next: () => { console.log('Imagen cambiada'); + this.toastService.success('Petición de instalación enviada'); this.loadImages(); }, error: (error) => { - console.error('Error al cambiar la imagen:', error); + console.error('Error al instalar la imagen:', error); + this.toastService.error('Error al instalar la imagen'); } }); break; @@ -130,10 +134,12 @@ export class ImagesComponent implements OnInit { this.http.post(`${this.apiUrl}/server/${image.uuid}/uninstall`, {}).subscribe({ next: () => { console.log('Imagen cambiada'); + this.toastService.success('Petición de desinstalación enviada'); this.loadImages(); }, error: (error) => { - console.error('Error al cambiar la imagen:', error); + console.error('Error al desinstalar la imagen:', error); + this.toastService.error('Error al desinstalar la imagen'); } }); break; @@ -191,7 +197,7 @@ export class ImagesComponent implements OnInit { this.http.get(`${this.apiUrl}/server/get-collection`) .subscribe(response => { // @ts-ignore - this.alertMessage = response.length + this.alertMessage = response.installed_ogLives.length }, error => { console.error('Error al cargar la información del alert', error); }); @@ -204,4 +210,15 @@ export class ImagesComponent implements OnInit { return { name: 'cancel', color: 'red' }; // Icono de cruz roja } } + + syncOgCore(): void { + this.http.post(`${this.apiUrl}/sync`, {}) + .subscribe(response => { + this.toastService.success('Sincronización completada'); + this.loadImages() + }, error => { + console.error('Error al sincronizar', error); + this.toastService.error('Error al sincronizar'); + }); + } }