Merge branch 'main' into develop
testing/ogGui-multibranch/pipeline/pr-main Build queued... Details
testing/ogGui-multibranch/pipeline/head There was a failure building this commit Details

pull/89/head
Manuel Aranda Rosales 2026-05-06 23:42:12 +02:00
commit 99f6b61265
6 changed files with 131 additions and 117 deletions

View File

@ -1,5 +1,9 @@
# Changelog # Changelog
## [1.5.7] - 2026-05-05
### Fixed
- Modificada vista para eliminar imagen de cache, se muestra la lista de ficheros de imagen contenida en la cache y se borra el fichero
## [1.5.6] - 2026-05-05 ## [1.5.6] - 2026-05-05
### Fixed ### Fixed
- Corregida edicion de menus - Corregida edicion de menus

View File

@ -1,9 +1,12 @@
<h2 mat-dialog-title> {{ 'selectImageToDeleteFromCache' | translate }}</h2> <h2 mat-dialog-title> {{ 'selectImageToDeleteFromCache' | translate }}</h2>
<mat-dialog-content class="dialog-content"> <mat-dialog-content class="dialog-content">
<mat-spinner class="loading-spinner" *ngIf="loading"></mat-spinner> @if (loading) {
<mat-spinner class="loading-spinner"></mat-spinner>
}
<div *ngIf="!loading" class="select-container"> @if (!loading) {
<div class="select-container">
<mat-expansion-panel> <mat-expansion-panel>
<mat-expansion-panel-header> <mat-expansion-panel-header>
<mat-panel-title> {{ 'labelClients' | translate }}</mat-panel-title> <mat-panel-title> {{ 'labelClients' | translate }}</mat-panel-title>
@ -19,7 +22,8 @@
</div> </div>
<div class="clients-grid"> <div class="clients-grid">
<div *ngFor="let client of data.clients" class="client-item"> @for (client of data.clients; track client['@id']) {
<div class="client-item">
<div class="client-card" <div class="client-card"
(click)="client.status === 'og-live' && toggleClientSelection(client)" (click)="client.status === 'og-live' && toggleClientSelection(client)"
[ngClass]="{'selected-client': client.selected, 'disabled-client': client.status !== 'og-live'}" > [ngClass]="{'selected-client': client.selected, 'disabled-client': client.status !== 'og-live'}" >
@ -45,59 +49,42 @@
</mat-radio-group> </mat-radio-group>
</div> </div>
</div> </div>
}
</div> </div>
</mat-expansion-panel> </mat-expansion-panel>
</div> </div>
<mat-divider *ngIf="!loading" style="margin-top: 20px;"></mat-divider> <mat-divider style="margin-top: 20px;"></mat-divider>
<div *ngIf="!loading" class="partition-table-container"> <div class="partition-table-container">
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8"> <table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
<ng-container matColumnDef="select"> <ng-container matColumnDef="select">
<th mat-header-cell *matHeaderCellDef i18n="@@columnActions" style="text-align: start">{{ 'buttonSelectImage' | translate }}</th> <th mat-header-cell *matHeaderCellDef i18n="@@columnActions" style="text-align: start">{{ 'buttonSelectImage' | translate }}</th>
<td mat-cell *matCellDef="let row"> <td mat-cell *matCellDef="let row">
<mat-radio-group <mat-radio-group [(ngModel)]="selectedImage">
[(ngModel)]="selectedPartition" <mat-radio-button [value]="row"></mat-radio-button>
[disabled]="!row.operativeSystem"
>
<mat-radio-button [value]="row">
</mat-radio-button>
</mat-radio-group> </mat-radio-group>
</td> </td>
</ng-container> </ng-container>
<ng-container *ngFor="let column of columns" [matColumnDef]="column.columnDef"> @for (column of columns; track column.columnDef) {
<ng-container [matColumnDef]="column.columnDef">
<th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let image"> <td mat-cell *matCellDef="let image">
<ng-container *ngIf="column.columnDef !== 'size' && column.columnDef !== 'operativeSystem'">
{{ column.cell(image) }} {{ column.cell(image) }}
</ng-container>
<ng-container *ngIf="column.columnDef === 'size'">
<div style="display: flex; flex-direction: column;">
<span> {{ image.size }} MB</span>
<span style="font-size: 0.75rem; color: gray;">{{ image.size / 1024 }} GB</span>
</div>
</ng-container>
<ng-container *ngIf="column.columnDef === 'operativeSystem'">
<div style="display: flex; flex-direction: column;">
<span> {{ image.operativeSystem?.name }} </span>
<span style="font-size: 0.75rem; color: gray;">{{ image.image?.name}} </span>
</div>
</ng-container>
</td> </td>
</ng-container> </ng-container>
}
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table> </table>
</div> </div>
}
</mat-dialog-content> </mat-dialog-content>
<div mat-dialog-actions class="action-container"> <div mat-dialog-actions class="action-container">
<button class="ordinary-button" (click)="close()">{{ 'buttonCancel' | translate }}</button> <button class="ordinary-button" (click)="close()">{{ 'buttonCancel' | translate }}</button>
<button class="submit-button" (click)="execute()" [disabled]="!selectedPartition">{{ 'buttonExecute' | translate }}</button> <button class="submit-button" (click)="execute()" [disabled]="!selectedImage">{{ 'buttonExecute' | translate }}</button>
</div> </div>

View File

@ -15,7 +15,7 @@ import {ToastrService} from "ngx-toastr";
export class RemoveCacheImageComponent { export class RemoveCacheImageComponent {
public translate = inject(TranslateService); public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
selectedPartition: any = null; selectedImage: any = null;
dataSource = new MatTableDataSource<any>(); dataSource = new MatTableDataSource<any>();
clientId: string | null = null; clientId: string | null = null;
selectedClients: any[] = []; selectedClients: any[] = [];
@ -26,34 +26,14 @@ export class RemoveCacheImageComponent {
loading: boolean = false; loading: boolean = false;
columns = [ columns = [
{ {
columnDef: 'diskNumber', columnDef: 'name',
header: 'labelDisk', header: 'name',
cell: (partition: any) => partition.diskNumber cell: (image: any) => image.name
},
{
columnDef: 'partitionNumber',
header: 'partition',
cell: (partition: any) => partition.partitionNumber
}, },
{ {
columnDef: 'size', columnDef: 'size',
header: 'labelDiskSize', header: 'size',
cell: (partition: any) => `${partition.size} MB` cell: (image: any) => this.formatBytes(image.size)
},
{
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
} }
]; ];
@ -97,9 +77,43 @@ export class RemoveCacheImageComponent {
this.http.get(url).subscribe( this.http.get(url).subscribe(
(response: any) => { (response: any) => {
if (response.partitions) { if (response.partitions) {
this.dataSource.data = response.partitions.filter((partition: any) => { const cachePartitions = response.partitions.filter((partition: any) => {
return partition.partitionNumber !== 0 && partition.image; 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) => { (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) { toggleClientSelection(client: any) {
client.selected = !client.selected; client.selected = !client.selected;
this.updateSelectedClients(); this.updateSelectedClients();
@ -141,7 +164,7 @@ export class RemoveCacheImageComponent {
this.loading = true; this.loading = true;
this.http.post(`${this.baseUrl}/clients/server/remove-cache-image`, { this.http.post(`${this.baseUrl}/clients/server/remove-cache-image`, {
clients: this.selectedClients.map((client: any) => client.uuid), clients: this.selectedClients.map((client: any) => client.uuid),
partition: this.selectedPartition['@id'] imageName: this.selectedImage.name
}).subscribe( }).subscribe(
response => { response => {
this.toastService.success(this.translate.instant('clientUpdatedSuccessfully')); this.toastService.success(this.translate.instant('clientUpdatedSuccessfully'));

View File

@ -575,7 +575,7 @@
"login": "Iniciar sessió", "login": "Iniciar sessió",
"createImage": "Crear imatge", "createImage": "Crear imatge",
"deployImage": "Desplegar imatge", "deployImage": "Desplegar imatge",
"deleteImageCache": "Esborrar cache d'imatge", "deleteImageCache": "Esborrar imatge de cache",
"partition": "Particionar i formatar", "partition": "Particionar i formatar",
"softwareInventory": "Inventari de software", "softwareInventory": "Inventari de software",
"hardwareInventory": "Inventari de hardware", "hardwareInventory": "Inventari de hardware",

View File

@ -577,7 +577,7 @@
"login": "Login", "login": "Login",
"createImage": "Create Image", "createImage": "Create Image",
"deployImage": "Deploy Image", "deployImage": "Deploy Image",
"deleteImageCache": "Delete Image Cache", "deleteImageCache": "Delete Image from Cache",
"partition": "Partition and Format", "partition": "Partition and Format",
"softwareInventory": "Software Inventory", "softwareInventory": "Software Inventory",
"hardwareInventory": "Hardware Inventory", "hardwareInventory": "Hardware Inventory",

View File

@ -577,7 +577,7 @@
"login": "Iniciar sesión", "login": "Iniciar sesión",
"createImage": "Crear imagen", "createImage": "Crear imagen",
"deployImage": "Desplegar imagen", "deployImage": "Desplegar imagen",
"deleteImageCache": "Borrar caché de imagen", "deleteImageCache": "Borrar imagen de cache",
"partition": "Particionar y formatear", "partition": "Particionar y formatear",
"softwareInventory": "Inventario de software", "softwareInventory": "Inventario de software",
"hardwareInventory": "Inventario de hardware", "hardwareInventory": "Inventario de hardware",