-
+
-
-
-
- {{ 'buttonSelectImage' | translate }}
-
-
-
-
-
-
-
+
+ {{ client.name | slice:0:20 }}
+ {{ client.ip }}
+ {{ client.mac }}
+
+
-
- {{ column.header | translate }}
-
-
- {{ column.cell(image) }}
-
-
-
-
- {{ image.size }} MB
- {{ image.size / 1024 }} GB
+
+
+ {{ 'labelModel' | translate }}
+
+
+ }
+
+
+
+
+
+
+
+
+
+
+ {{ 'buttonSelectImage' | translate }}
+
+
+
+
+
+
+
+ @for (column of columns; track column.columnDef) {
+
+ {{ column.header | translate }}
+
+ {{ column.cell(image) }}
+
+ }
-
-
- {{ image.operativeSystem?.name }}
- {{ image.image?.name}}
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ }
{{ 'buttonCancel' | translate }}
- {{ 'buttonExecute' | translate }}
+ {{ 'buttonExecute' | translate }}
diff --git a/ogWebconsole/src/app/components/commands/main-commands/execute-command/remove-cache-image/remove-cache-image.component.ts b/ogWebconsole/src/app/components/commands/main-commands/execute-command/remove-cache-image/remove-cache-image.component.ts
index 782b7cd..390c235 100644
--- a/ogWebconsole/src/app/components/commands/main-commands/execute-command/remove-cache-image/remove-cache-image.component.ts
+++ b/ogWebconsole/src/app/components/commands/main-commands/execute-command/remove-cache-image/remove-cache-image.component.ts
@@ -15,7 +15,7 @@ import {ToastrService} from "ngx-toastr";
export class RemoveCacheImageComponent {
public translate = inject(TranslateService);
baseUrl: string;
- selectedPartition: any = null;
+ selectedImage: any = null;
dataSource = new MatTableDataSource
();
clientId: string | null = null;
selectedClients: any[] = [];
@@ -26,34 +26,14 @@ export class RemoveCacheImageComponent {
loading: boolean = false;
columns = [
{
- columnDef: 'diskNumber',
- header: 'labelDisk',
- cell: (partition: any) => partition.diskNumber
- },
- {
- columnDef: 'partitionNumber',
- header: 'partition',
- cell: (partition: any) => partition.partitionNumber
+ columnDef: 'name',
+ header: 'name',
+ cell: (image: any) => image.name
},
{
columnDef: 'size',
- header: 'labelDiskSize',
- cell: (partition: any) => `${partition.size} MB`
- },
- {
- columnDef: 'partitionCode',
- header: 'partitionType',
- cell: (partition: any) => partition.partitionCode
- },
- {
- columnDef: 'filesystem',
- header: 'fileSystem',
- cell: (partition: any) => partition.filesystem
- },
- {
- columnDef: 'operativeSystem',
- header: 'sW',
- cell: (partition: any) => partition.operativeSystem?.name
+ header: 'size',
+ cell: (image: any) => this.formatBytes(image.size)
}
];
@@ -97,9 +77,43 @@ export class RemoveCacheImageComponent {
this.http.get(url).subscribe(
(response: any) => {
if (response.partitions) {
- this.dataSource.data = response.partitions.filter((partition: any) => {
- return partition.partitionNumber !== 0 && partition.image;
+ const cachePartitions = response.partitions.filter((partition: any) => {
+ return partition.partitionNumber !== 0 && partition.filesystem === 'CACHE' && partition.cacheContent !== "";
});
+
+ let imagesMap: { [key: string]: number } = {};
+
+ cachePartitions.forEach((p: any) => {
+ if (p.cacheContent) {
+ const items = p.cacheContent.split(',');
+ items.forEach((item: string) => {
+ const parts = item.split(':');
+ if (parts.length >= 2) {
+ const filename = parts[0];
+ let size = 0;
+
+ let baseName = filename;
+ if (baseName.endsWith('.img.full.sum')) baseName = baseName.replace('.img.full.sum', '');
+ else if (baseName.endsWith('.img.sum')) baseName = baseName.replace('.img.sum', '');
+ // El tamaño de la imagen que usamos es sólo del fichero .img
+ else if (baseName.endsWith('.img')) {
+ baseName = baseName.replace('.img', '');
+ size = parseInt(parts[1], 10) || 0;
+ }
+
+ if (!imagesMap[baseName]) {
+ imagesMap[baseName] = 0;
+ }
+ imagesMap[baseName] += size;
+ }
+ });
+ }
+ });
+
+ this.dataSource.data = Object.keys(imagesMap).map(name => ({
+ name: name,
+ size: imagesMap[name]
+ }));
}
},
(error) => {
@@ -108,6 +122,15 @@ export class RemoveCacheImageComponent {
);
}
+ formatBytes(bytes: number, decimals = 2) {
+ if (bytes === 0) return '0 Bytes';
+ const k = 1024;
+ const dm = decimals < 0 ? 0 : decimals;
+ const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
+ }
+
toggleClientSelection(client: any) {
client.selected = !client.selected;
this.updateSelectedClients();
@@ -141,7 +164,7 @@ export class RemoveCacheImageComponent {
this.loading = true;
this.http.post(`${this.baseUrl}/clients/server/remove-cache-image`, {
clients: this.selectedClients.map((client: any) => client.uuid),
- partition: this.selectedPartition['@id']
+ imageName: this.selectedImage.name
}).subscribe(
response => {
this.toastService.success(this.translate.instant('clientUpdatedSuccessfully'));
diff --git a/ogWebconsole/src/locale/cat.json b/ogWebconsole/src/locale/cat.json
index a69d3f6..0942b70 100644
--- a/ogWebconsole/src/locale/cat.json
+++ b/ogWebconsole/src/locale/cat.json
@@ -575,7 +575,7 @@
"login": "Iniciar sessió",
"createImage": "Crear imatge",
"deployImage": "Desplegar imatge",
- "deleteImageCache": "Esborrar cache d'imatge",
+ "deleteImageCache": "Esborrar imatge de cache",
"partition": "Particionar i formatar",
"softwareInventory": "Inventari de software",
"hardwareInventory": "Inventari de hardware",
diff --git a/ogWebconsole/src/locale/en.json b/ogWebconsole/src/locale/en.json
index 3857c4a..558716d 100644
--- a/ogWebconsole/src/locale/en.json
+++ b/ogWebconsole/src/locale/en.json
@@ -575,7 +575,7 @@
"login": "Login",
"createImage": "Create Image",
"deployImage": "Deploy Image",
- "deleteImageCache": "Delete Image Cache",
+ "deleteImageCache": "Delete Image from Cache",
"partition": "Partition and Format",
"softwareInventory": "Software Inventory",
"hardwareInventory": "Hardware Inventory",
diff --git a/ogWebconsole/src/locale/es.json b/ogWebconsole/src/locale/es.json
index c1dce8f..d14ecd4 100644
--- a/ogWebconsole/src/locale/es.json
+++ b/ogWebconsole/src/locale/es.json
@@ -575,7 +575,7 @@
"login": "Iniciar sesión",
"createImage": "Crear imagen",
"deployImage": "Desplegar imagen",
- "deleteImageCache": "Borrar caché de imagen",
+ "deleteImageCache": "Borrar imagen de cache",
"partition": "Particionar y formatear",
"softwareInventory": "Inventario de software",
"hardwareInventory": "Inventario de hardware",