From ef3158a045e843acfa3af03513bead2aef3c5617 Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Thu, 8 May 2025 08:06:57 +0200 Subject: [PATCH] refs #1922. Show new fields in clients table. --- ogWebconsole/src/app/app-routing.module.ts | 2 +- ogWebconsole/src/app/app.module.ts | 6 +- .../create-image/create-image.component.html | 10 ++ .../partition-assistant.component.ts | 18 ++- .../components/groups/groups.component.html | 12 +- .../client-details.component.html | 7 +- .../client-details.component.ts | 107 ++---------------- 7 files changed, 51 insertions(+), 111 deletions(-) diff --git a/ogWebconsole/src/app/app-routing.module.ts b/ogWebconsole/src/app/app-routing.module.ts index 3a0ca83..f901d43 100644 --- a/ogWebconsole/src/app/app-routing.module.ts +++ b/ogWebconsole/src/app/app-routing.module.ts @@ -17,7 +17,7 @@ import { CalendarComponent } from "./components/calendar/calendar.component"; import { CommandsComponent } from './components/commands/main-commands/commands.component'; import { CommandsGroupsComponent } from './components/commands/commands-groups/commands-groups.component'; import { CommandsTaskComponent } from './components/commands/commands-task/commands-task.component'; -import { TaskLogsComponent } from './components/commands/commands-task/task-logs/task-logs.component'; +import { TaskLogsComponent } from './components/task-logs/task-logs.component'; import {SoftwareComponent} from "./components/software/software.component"; import {SoftwareProfileComponent} from "./components/software-profile/software-profile.component"; import {OperativeSystemComponent} from "./components/operative-system/operative-system.component"; diff --git a/ogWebconsole/src/app/app.module.ts b/ogWebconsole/src/app/app.module.ts index 13cef17..9338131 100644 --- a/ogWebconsole/src/app/app.module.ts +++ b/ogWebconsole/src/app/app.module.ts @@ -67,7 +67,7 @@ import { PXEimagesComponent } from './components/ogboot/pxe-images/pxe-images.co import { CreatePXEImageComponent } from './components/ogboot/pxe-images/create-image/create-image/create-image.component'; import { InfoImageComponent } from './components/ogboot/pxe-images/info-image/info-image/info-image.component'; import { PxeComponent } from './components/ogboot/pxe/pxe.component'; -import { CreatePxeTemplateComponent } from './components/ogboot/pxe/create-pxeTemplate/create-pxe-template.component'; +import { CreatePxeTemplateComponent } from './components/ogboot/pxe/manage-pxeTemplate/create-pxe-template.component'; import { PxeBootFilesComponent } from './components/ogboot/pxe-boot-files/pxe-boot-files.component'; import { MatExpansionPanel, MatExpansionPanelDescription, MatExpansionPanelTitle } from "@angular/material/expansion"; import { OgbootStatusComponent } from './components/ogboot/ogboot-status/ogboot-status.component'; @@ -87,7 +87,7 @@ import { CreateCommandGroupComponent } from './components/commands/commands-grou import { DetailCommandGroupComponent } from './components/commands/commands-groups/detail-command-group/detail-command-group.component'; import { CreateTaskComponent } from './components/commands/commands-task/create-task/create-task.component'; import { DetailTaskComponent } from './components/commands/commands-task/detail-task/detail-task.component'; -import { TaskLogsComponent } from './components/commands/commands-task/task-logs/task-logs.component'; +import { TaskLogsComponent } from './components/task-logs/task-logs.component'; import { MatSliderModule } from '@angular/material/slider'; import { ImagesComponent } from './components/images/images.component'; import { CreateImageComponent } from './components/images/create-image/create-image.component'; @@ -117,7 +117,7 @@ import { CreateMultipleClientComponent } from './components/groups/shared/client import { ExportImageComponent } from './components/images/export-image/export-image.component'; import { ImportImageComponent } from "./components/repositories/import-image/import-image.component"; import { LoadingComponent } from './shared/loading/loading.component'; -import { InputDialogComponent } from './components/commands/commands-task/task-logs/input-dialog/input-dialog.component'; +import { InputDialogComponent } from './components/task-logs/input-dialog/input-dialog.component'; import { ManageOrganizationalUnitComponent } from './components/groups/shared/organizational-units/manage-organizational-unit/manage-organizational-unit.component'; import { BackupImageComponent } from './components/repositories/backup-image/backup-image.component'; import { ServerInfoDialogComponent } from "./components/ogdhcp/server-info-dialog/server-info-dialog.component"; diff --git a/ogWebconsole/src/app/components/groups/components/client-main-view/create-image/create-image.component.html b/ogWebconsole/src/app/components/groups/components/client-main-view/create-image/create-image.component.html index 3369556..6c3be8f 100644 --- a/ogWebconsole/src/app/components/groups/components/client-main-view/create-image/create-image.component.html +++ b/ogWebconsole/src/app/components/groups/components/client-main-view/create-image/create-image.component.html @@ -13,6 +13,16 @@
+
+ + Tipo de imagen + + Monolítica + Git + + +
+
Nombre canónico diff --git a/ogWebconsole/src/app/components/groups/components/client-main-view/partition-assistant/partition-assistant.component.ts b/ogWebconsole/src/app/components/groups/components/client-main-view/partition-assistant/partition-assistant.component.ts index 3bf2684..d5fbe0d 100644 --- a/ogWebconsole/src/app/components/groups/components/client-main-view/partition-assistant/partition-assistant.component.ts +++ b/ogWebconsole/src/app/components/groups/components/client-main-view/partition-assistant/partition-assistant.component.ts @@ -252,6 +252,8 @@ export class PartitionAssistantComponent implements OnInit{ if (disk) { const remainingGB = this.getRemainingGB(disk.partitions, disk.totalDiskSize); + console.log('Remaining GB:', remainingGB); + console.log('Total Disk Size:', disk); if (remainingGB > 0) { const removedPartitions = disk.partitions.filter((p) => !p.removed); @@ -259,7 +261,6 @@ export class PartitionAssistantComponent implements OnInit{ removedPartitions.length > 0 ? Math.max(...removedPartitions.map((p) => p.partitionNumber)) : 0; const newPartitionNumber = maxPartitionNumber + 1; - disk.partitions.push({ partitionNumber: newPartitionNumber, size: 0, @@ -303,10 +304,14 @@ export class PartitionAssistantComponent implements OnInit{ } getRemainingGB(partitions: Partition[], totalDiskSize: number): number { - const totalUsedGB = partitions.reduce((acc, partition) => acc + partition.size, 0); + const totalUsedGB = partitions + .filter(partition => !partition.removed) + .reduce((acc, partition) => acc + partition.size, 0); + return Math.max(0, totalDiskSize - totalUsedGB); } + save() { if (!this.selectedDisk) { this.toastService.error('No se ha seleccionado un disco.'); @@ -373,6 +378,10 @@ export class PartitionAssistantComponent implements OnInit{ if (partitionToRemove) { partitionToRemove.removed = true; } + + disk.used = this.calculateUsedSpace(disk.partitions); + disk.percentage = (disk.used / disk.totalDiskSize) * 100; + this.updateDiskChart(disk); this.updatePartitionPercentages(disk.partitions, disk.totalDiskSize); } @@ -391,9 +400,12 @@ export class PartitionAssistantComponent implements OnInit{ } calculateUsedSpace(partitions: Partition[]): number { - return partitions.reduce((acc, partition) => acc + partition.size, 0); + return partitions + .filter(partition => !partition.removed) + .reduce((acc, partition) => acc + partition.size, 0); } + generateChartData(partitions: Partition[]): any[] { return partitions.map((partition) => ({ name: `Partición ${partition.partitionNumber}`, diff --git a/ogWebconsole/src/app/components/groups/groups.component.html b/ogWebconsole/src/app/components/groups/groups.component.html index a338c2d..4fc74d1 100644 --- a/ogWebconsole/src/app/components/groups/groups.component.html +++ b/ogWebconsole/src/app/components/groups/groups.component.html @@ -371,15 +371,19 @@ {{ 'firmwareType' | translate }} - - {{ client.firmwareType ? client.firmwareType : 'N/A' }} + + {{ client.firmwareType }} OG Live - {{ client.ogLive?.date | date }} + +
+ {{ client.ogLive?.kernel }} + {{ client.ogLive?.date | date }} +
@@ -457,4 +461,4 @@
-
\ No newline at end of file + diff --git a/ogWebconsole/src/app/components/groups/shared/client-details/client-details.component.html b/ogWebconsole/src/app/components/groups/shared/client-details/client-details.component.html index 8beb74e..e7f3c9a 100644 --- a/ogWebconsole/src/app/components/groups/shared/client-details/client-details.component.html +++ b/ogWebconsole/src/app/components/groups/shared/client-details/client-details.component.html @@ -46,9 +46,14 @@ + - + + + + +
diff --git a/ogWebconsole/src/app/components/groups/shared/client-details/client-details.component.ts b/ogWebconsole/src/app/components/groups/shared/client-details/client-details.component.ts index 788cb42..ddf03be 100644 --- a/ogWebconsole/src/app/components/groups/shared/client-details/client-details.component.ts +++ b/ogWebconsole/src/app/components/groups/shared/client-details/client-details.component.ts @@ -38,41 +38,27 @@ export class ClientDetailsComponent { view: [number, number] = [260, 160]; showLegend: boolean = true; - arrayCommands: any[] = [ - { name: 'Enceder', slug: 'power-on' }, - { name: 'Apagar', slug: 'power-off' }, - { name: 'Reiniciar', slug: 'reboot' }, - { name: 'Iniciar Sesión', slug: 'login' }, - { name: 'Crear imagen', slug: 'create-image' }, - { name: 'Clonar/desplegar imagen', slug: 'deploy-image' }, - { name: 'Eliminar Imagen Cache', slug: 'delete-image-cache' }, - { name: 'Particionar y Formatear', slug: 'partition' }, - { name: 'Inventario Software', slug: 'software-inventory' }, - { name: 'Inventario Hardware', slug: 'hardware-inventory' }, - { name: 'Ejecutar comando', slug: 'run-script' }, - ]; - datePipe: DatePipe = new DatePipe('es-ES'); columns = [ { columnDef: 'diskNumber', header: 'Disco', - cell: (partition: any) => `${partition.diskNumber}`, + cell: (partition: any) => partition.diskNumber, }, { columnDef: 'partitionNumber', header: 'Particion', - cell: (partition: any) => `${partition.partitionNumber}` + cell: (partition: any) => partition.partitionNumber }, { columnDef: 'partitionCode', header: 'Tipo de partición', - cell: (partition: any) => `${partition.partitionCode}` + cell: (partition: any) => partition.partitionCode }, { columnDef: 'description', header: 'Sistema de ficheros', - cell: (partition: any) => `${partition.filesystem}` + cell: (partition: any) => partition.filesystem }, { columnDef: 'size', @@ -82,12 +68,12 @@ export class ClientDetailsComponent { { columnDef: 'memoryUsage', header: 'Uso', - cell: (partition: any) => `${partition.memoryUsage} %` + cell: (partition: any) => `${partition.memoryUsage}%` }, { columnDef: 'operativeSystem', header: 'SO', - cell: (partition: any) => `${partition.operativeSystem?.name}` + cell: (partition: any) => partition.operativeSystem?.name }, ]; displayedColumns = [...this.columns.map(column => column.columnDef)]; @@ -121,21 +107,6 @@ export class ClientDetailsComponent { } } - loadClient = (uuid: string) => { - this.http.get(`${this.baseUrl}${uuid}`).subscribe({ - next: data => { - this.clientData = data; - this.updateGeneralData(); - this.updateNetworkData(); - this.loadPartitions() - this.loading = false; - }, - error: error => { - console.error('Error al obtener el cliente:', error); - } - }); - } - updateGeneralData() { this.generalData = [ { property: 'Nombre', value: this.clientData?.name || '' }, @@ -150,7 +121,7 @@ export class ClientDetailsComponent { updateNetworkData() { this.networkData = [ { property: 'Padre', value: this.clientData?.organizationalUnit?.name || '' }, - { property: 'Pxe', value: this.clientData?.template?.name || '' }, + { property: 'Pxe', value: this.clientData?.pxeTemplate?.name || '' }, { property: 'Remote Pc', value: this.clientData.remotePc || '' }, { property: 'Subred', value: this.clientData?.subnet || '' }, { property: 'OGlive', value: this.clientData?.ogLive?.name || '' }, @@ -205,21 +176,14 @@ export class ClientDetailsComponent { this.isDiskUsageEmpty = this.diskUsageData.length === 0; } - onEditClick(event: MouseEvent, uuid: string): void { - event.stopPropagation(); - const dialogRef = this.dialog.open(ManageClientComponent, { data: { uuid }, width: '900px' }); - dialogRef.afterClosed().subscribe(); - } - loadPartitions(): void { if (!this.clientData?.id) { - console.error('El ID del cliente no está disponible.'); return; } this.http.get(`${this.baseUrl}/partitions?client.id=${this.clientData.id}&order[diskNumber, partitionNumber]=ASC`).subscribe({ next: data => { - const filteredPartitions = data['hydra:member'].filter((partition: any) => partition.partitionNumber !== 0); + const filteredPartitions = data['hydra:member']; this.dataSource = filteredPartitions; this.partitions = filteredPartitions; this.calculateDiskUsage(); @@ -233,59 +197,4 @@ export class ClientDetailsComponent { onNoClick(): void { this.dialog.closeAll(); } - - rebootClient(): void { - this.http.post(`${this.baseUrl}/clients/server/${this.clientData.uuid}/reboot`, {}).subscribe( - response => { - this.toastService.success('Cliente actualizado correctamente'); - }, - error => { - this.toastService.error('Error de conexión con el cliente'); - } - ); - } - - powerOnClient(): void { - const payload = { - client: this.clientData['@id'] - } - - this.http.post(`${this.baseUrl}${this.clientData.repository['@id']}/wol`, payload).subscribe( - response => { - this.toastService.success('Cliente actualizado correctamente'); - }, - error => { - this.toastService.error('Error de conexión con el cliente'); - } - ); - } - - powerOffClient(): void { - this.http.post(`${this.baseUrl}/clients/server/${this.clientData.uuid}/power-off`, {}).subscribe( - response => { - this.toastService.success('Cliente actualizado correctamente'); - }, - error => { - this.toastService.error('Error de conexión con el cliente'); - } - ); - } - - openPartitionAssistant(): void { - this.router.navigate([`/clients/${this.clientData.uuid}/partition-assistant`]).then(r => { - console.log('navigated', r); - }); - } - - openCreateImageAssistant(): void { - this.router.navigate([`/clients/${this.clientData.uuid}/create-image`]).then(r => { - console.log('navigated', r); - }); - } - - openDeployImageAssistant(): void { - this.router.navigate([`/clients/deploy-image`]).then(r => { - console.log('navigated', r); - }); - } }