refs #2720. Show get-script data
testing/ogGui-multibranch/pipeline/head There was a failure building this commit Details

pull/38/head
Manuel Aranda Rosales 2025-08-28 16:22:06 +02:00
parent 5803a14076
commit 6289dd4033
3 changed files with 140 additions and 26 deletions

View File

@ -1184,18 +1184,19 @@
.instructions-box {
margin-top: 15px;
background-color: #f5f5f5;
border: 1px solid #ccc;
padding: 15px;
border-radius: 6px;
}
.instructions-card {
background: #f5f5f5;
box-shadow: none !important;
margin-top: 20px;
border-radius: 16px;
border: none;
.instructions-box .instructions-card {
padding: 24px 32px;
background: white;
border-radius: 12px;
border: 1px solid #bbdefb;
}
.instructions-box .instructions-card .mat-card-title {
margin-bottom: 8px;
}
.instructions-card pre {
@ -1210,6 +1211,24 @@
line-height: 1.5;
}
/* Script textarea for generated instructions */
.instructions-card .script-textarea {
width: 100%;
min-height: 260px;
font-family: monospace;
font-size: 13px;
line-height: 1.4;
white-space: pre;
resize: vertical;
padding: 12px;
box-sizing: border-box;
}
.instructions-top {
margin: 12px 0 20px 0;
padding: 0 20px;
}
@media (max-width: 768px) {
.header-container {
flex-direction: column;
@ -1275,10 +1294,8 @@
.partition-validation-indicator {
margin: 16px 0;
padding: 16px 20px;
border-radius: 12px;
transition: all 0.3s ease;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.validation-status {
@ -1415,6 +1432,46 @@
::ng-deep .model-selector .mat-radio-outer-circle { border-color: #667eea !important; }
::ng-deep .model-selector .mat-radio-inner-circle { background-color: #667eea !important; }
/* Overrides: info badges sin fondo ni borde, estilo neutro */
.info-badge {
background: transparent;
border: none;
box-shadow: none;
}
.info-badge:hover {
transform: none;
box-shadow: none;
}
.info-badge:first-of-type,
.info-badge:last-of-type {
background: transparent;
border-color: transparent;
}
.info-badge:first-of-type .info-icon,
.info-badge:last-of-type .info-icon,
.info-badge:first-of-type .info-label,
.info-badge:last-of-type .info-label,
.info-badge:first-of-type .info-value,
.info-badge:last-of-type .info-value {
color: inherit;
}
/* Colores neutros en badges */
.info-badge .info-label {
color: #333;
}
.info-badge .info-value {
color: #333;
}
.info-badge .info-icon {
color: #6c757d;
}

View File

@ -32,6 +32,21 @@
</div>
</div>
<div *ngIf="showInstructions" class="instructions-box instructions-top" (click)="$event.stopPropagation()">
<mat-card class="instructions-card">
<mat-card-title>
Script generado
<span style="float: right;">
<button mat-icon-button matTooltip="Copiar" (click)="copyInstructions()"><mat-icon>content_copy</mat-icon></button>
<button mat-icon-button matTooltip="Cerrar" (click)="showInstructions = false"><mat-icon>close</mat-icon></button>
</span>
</mat-card-title>
<mat-card-content>
<textarea class="script-textarea" readonly>{{ generatedInstructions }}</textarea>
</mat-card-content>
</mat-card>
</div>
<div class="select-container">
<mat-expansion-panel>
<mat-expansion-panel-header>
@ -136,20 +151,6 @@
</div>
<div class="partition-assistant" *ngIf="selectedDisk">
<div *ngIf="showInstructions" class="instructions-box">
<mat-card class="instructions-card">
<mat-card-title>
Instrucciones generadas
<button mat-icon-button (click)="showInstructions = false" style="float: right;">
<mat-icon>close</mat-icon>
</button>
</mat-card-title>
<mat-card-content>
<pre>{{ generatedInstructions }}</pre>
</mat-card-content>
</mat-card>
</div>
<div class="row-button">
<button class="action-button" [disabled]="partitionCode === 'MSDOS'" (click)="addPartition(selectedDisk.diskNumber)">Añadir partición</button>

View File

@ -669,10 +669,66 @@ export class PartitionAssistantComponent implements OnInit, AfterViewInit, OnDes
}
generateInstructions(): void {
this.showInstructions = true;
this.generatedInstructions = `og-partition --disk ${this.selectedDiskNumber} --partitions ${this.selectedDisk.partitions.map((p: Partition) => `${p.partitionNumber}:${p.size}:${p.partitionCode}:${p.filesystem}:${p.format}`).join(',')}`;
if (!this.selectedModelClient || !this.selectedDisk) {
this.toastService.error('Selecciona un cliente modelo y un disco.');
return;
}
const partitions = this.selectedDisk.partitions
.filter((p: Partition) => !p.removed)
.map((p: Partition) => ({
diskNumber: this.selectedDisk.diskNumber,
partitionNumber: p.partitionNumber,
size: p.size,
partitionCode: p.partitionCode,
filesystem: p.filesystem,
format: !!p.format,
}));
const payload: any = {
partitions,
diskNumber: this.selectedDisk.diskNumber,
partitionTable: this.partitionCode,
};
const url = `${this.baseUrl}${this.selectedModelClient.uuid}/get-partition-script-data`;
this.loading = true;
this.http.post(url, payload, { responseType: 'text' as 'json' }).subscribe({
next: (resp: any) => {
this.loading = false;
this.showInstructions = true;
let text = '';
try {
const obj = JSON.parse(resp);
if (typeof obj === 'string') {
text = obj;
} else if (obj?.script) {
text = obj.script;
} else if (Array.isArray(obj?.scripts)) {
text = obj.scripts.join('\n\n');
} else {
text = JSON.stringify(obj, null, 2);
}
} catch {
text = String(resp ?? '');
}
this.generatedInstructions = text;
},
error: (error) => {
this.loading = false;
this.toastService.error(error?.error?.message || 'Error al generar el script.');
}
});
}
copyInstructions(): void {
if (!this.generatedInstructions) { return; }
navigator.clipboard?.writeText(this.generatedInstructions)
.then(() => this.toastService.success('Script copiado al portapapeles'))
.catch(() => this.toastService.error('No se pudo copiar el script.'));
}
onDiskSelected(diskNumber: number) {
this.selectedDiskNumber = diskNumber;
this.scrollToPartitionTable();