From 6289dd4033fbc8d1ab2ece4eb990717216a0f13f Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Thu, 28 Aug 2025 16:22:06 +0200 Subject: [PATCH 1/2] refs #2720. Show get-script data --- .../partition-assistant.component.css | 77 ++++++++++++++++--- .../partition-assistant.component.html | 29 +++---- .../partition-assistant.component.ts | 60 ++++++++++++++- 3 files changed, 140 insertions(+), 26 deletions(-) diff --git a/ogWebconsole/src/app/components/groups/components/client-main-view/partition-assistant/partition-assistant.component.css b/ogWebconsole/src/app/components/groups/components/client-main-view/partition-assistant/partition-assistant.component.css index d1071c1..4739a62 100644 --- a/ogWebconsole/src/app/components/groups/components/client-main-view/partition-assistant/partition-assistant.component.css +++ b/ogWebconsole/src/app/components/groups/components/client-main-view/partition-assistant/partition-assistant.component.css @@ -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; +} + diff --git a/ogWebconsole/src/app/components/groups/components/client-main-view/partition-assistant/partition-assistant.component.html b/ogWebconsole/src/app/components/groups/components/client-main-view/partition-assistant/partition-assistant.component.html index 34b7fde..20e7772 100644 --- a/ogWebconsole/src/app/components/groups/components/client-main-view/partition-assistant/partition-assistant.component.html +++ b/ogWebconsole/src/app/components/groups/components/client-main-view/partition-assistant/partition-assistant.component.html @@ -32,6 +32,21 @@ +
+ + + Script generado + + + + + + + + + +
+
@@ -136,20 +151,6 @@
-
- - - Instrucciones generadas - - - -
{{ generatedInstructions }}
-
-
-
-
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 ad5ae8c..5ebafb9 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 @@ -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(); -- 2.40.1 From 3ed534b48ffcc6fa212a6e8cf81529a748c362ad Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Thu, 28 Aug 2025 16:24:06 +0200 Subject: [PATCH 2/2] Updated changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41ab645..0d7818b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,10 @@ # Changelog + +## [0.21.0] - 2025-08-28 +### Added +- Se ha incluido una integracion con el agente, para generar los scripts que se llaman al particionar. + +--- ## [0.20.1] - 2025-08-28 ### Improved - Se ha mejorado la UX de los asistentes. -- 2.40.1