diff --git a/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.css b/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.css index d14ed3c..11a5938 100644 --- a/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.css +++ b/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.css @@ -6,6 +6,11 @@ padding: 20px; } +.select-task { + padding: 20px; + margin-bottom: 16px; +} + .full-width { width: 100%; } diff --git a/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.html b/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.html index b9a8aa8..79de16a 100644 --- a/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.html +++ b/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.html @@ -1,9 +1,40 @@ -

{{ editing ? ('editTask' | translate) : ('createTask' | translate) }}

+

+ {{ editing ? ('editTask' | translate) : ('createTask' | translate) }} +

-
+ + + Crear tarea + Introducir en tarea existente + + + +
+ + Seleccione una tarea + + {{ task.name }} + + + + + Orden de ejecución + + +
+ + + {{ 'nameLabel' | translate }} @@ -17,17 +48,17 @@ Ámbito - - Unidad Organizativa - Grupo de aulas - Aulas - Grupos de clientes + + Unidad Organizativa + Grupo de aulas + Aulas + Grupos de clientes - + {{ 'organizationalUnitLabel' | translate }} - +
{{ unit.name }}
{{ unit.path }}
@@ -35,11 +66,18 @@
- ¿Quieres programar la tarea al finalizar su creación? + + ¿Quieres programar la tarea al finalizar su creación? +
- + diff --git a/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.ts b/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.ts index 92c6440..9ff9ba6 100644 --- a/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.ts +++ b/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.ts @@ -25,6 +25,10 @@ export class CreateTaskComponent implements OnInit { clients: any[] = []; allOrganizationalUnits: any[] = []; loading: boolean = false; + taskMode: 'create' | 'add' = 'create'; + existingTasks: any[] = []; + selectedExistingTask: string | null = null; + executionOrder: number | null = null; constructor( private fb: FormBuilder, @@ -53,6 +57,7 @@ export class CreateTaskComponent implements OnInit { this.loadIndividualCommands(), this.loadOrganizationalUnits(), this.startUnitsFilter(), + this.loadTasks() ]; Promise.all(observables).then(() => { @@ -90,6 +95,21 @@ export class CreateTaskComponent implements OnInit { }) } + loadTasks(): Promise { + return new Promise((resolve, reject) => { + this.http.get(`${this.apiUrl}?page=1&itemsPerPage=100`).subscribe( + (data) => { + this.existingTasks = data['hydra:member']; + resolve(); + }, + (error) => { + this.toastr.error('Error al cargar las tareas existentes'); + reject(error); + } + ); + }); + } + onScopeChange(scope: string): void { this.filterUnits(scope).subscribe(filteredUnits => { this.availableOrganizationalUnits = filteredUnits; @@ -161,6 +181,27 @@ export class CreateTaskComponent implements OnInit { }); } + addToExistingTask() { + if (!this.selectedExistingTask) { + this.toastr.error('Debes seleccionar una tarea existente.'); + return; + } + + if (this.executionOrder == null || this.executionOrder < 1) { + this.toastr.error('Debes introducir un orden de ejecución válido (mayor que 0).'); + return; + } + + const data = { + taskId: this.selectedExistingTask, + executionOrder: this.executionOrder + }; + + this.toastr.success('Tarea actualizada con éxito'); + this.dialogRef.close(data); + } + + saveTask(): void { if (this.taskForm.invalid) { this.toastr.error('Por favor, rellene todos los campos obligatorios'); diff --git a/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.html b/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.html index f01022a..9780df4 100644 --- a/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.html +++ b/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.html @@ -10,11 +10,15 @@
- +
-
@@ -142,18 +146,21 @@
Puerto - + Dirección - + Modo Multicast - - + + {{ option.name }} @@ -161,25 +168,29 @@ Velocidad - + Máximo Clientes - + Tiempo Máximo de Espera - +
Modo P2P - - + + {{ option.name }} @@ -187,7 +198,8 @@ Semilla - +
diff --git a/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.ts b/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.ts index 7ab67dc..ff560c5 100644 --- a/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.ts +++ b/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.ts @@ -332,13 +332,34 @@ export class DeployImageComponent implements OnInit{ }); } + isFormValid(): boolean { + if (!this.allSelected || !this.selectedModelClient || !this.selectedImage || !this.selectedMethod || !this.selectedPartition) { + return false; + } + + if (this.isMethod('udpcast') || this.isMethod('uftp') || this.isMethod('udpcast-direct')) { + if (!this.mcastPort || !this.mcastIp || !this.mcastMode || !this.mcastSpeed || !this.mcastMaxClients || !this.mcastMaxTime) { + return false; + } + } + + if (this.isMethod('p2p')) { + if (!this.p2pMode || !this.p2pTime) { + return false; + } + } + + return true; + } + openScheduleModal(): void { const dialogRef = this.dialog.open(CreateTaskComponent, { width: '800px', data: { scope: this.runScriptContext.type, - organizationalUnit: this.runScriptContext['@id'] + organizationalUnit: this.runScriptContext['@id'], + source: 'assistant' } }); @@ -359,9 +380,9 @@ export class DeployImageComponent implements OnInit{ }; this.http.post(`${this.baseUrl}/command-task-scripts`, { - commandTask: result['@id'], + commandTask: result['taskId'] ? result['taskId']['@id'] : result['@id'], parameters: payload, - order: 1, + order: result['executionOrder'] || 1, type: 'deploy-image', }).subscribe({ next: () => { 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 2e034f9..9513cb6 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 @@ -267,5 +267,18 @@ button.remove-btn:hover { font-weight: 500; } +.instructions-box { + margin-top: 15px; + background-color: #f5f5f5; + border: 1px solid #ccc; + padding: 15px; + border-radius: 6px; +} + +.instructions-textarea textarea { + font-family: monospace; + white-space: pre; +} + 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 ec2d67c..838f72d 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 @@ -13,6 +13,12 @@ +
+ +
+
+ +
+ + + +
+
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 2eb888d..5fc8b78 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 @@ -52,6 +52,7 @@ export class PartitionAssistantComponent implements OnInit{ selectedClients: any[] = []; selectedModelClient: any = null; partitionCode: string = ''; + generatedInstructions: string = ''; constructor( private http: HttpClient, @@ -426,7 +427,8 @@ export class PartitionAssistantComponent implements OnInit{ width: '800px', data: { scope: this.runScriptContext.type, - organizationalUnit: this.runScriptContext['@id'] + organizationalUnit: this.runScriptContext['@id'], + source: 'assistant' } }); @@ -473,4 +475,39 @@ export class PartitionAssistantComponent implements OnInit{ } }); } + + generateInstructions(): void { + if (!this.selectedDisk || !this.selectedDisk.partitions) { + this.generatedInstructions = 'No hay particiones configuradas para generar instrucciones.'; + return; + } + + const diskNumber = this.selectedDisk.diskNumber; + const partitionTable = this.partitionCode || 'MSDOS'; + + let instructions = `ogCreatePartitionTable ${diskNumber} ${partitionTable}\n`; + instructions += `ogEcho log session "[0] $MSG_HELP_ogCreatePartitions"\n`; + instructions += `ogEcho session "[10] $MSG_HELP_ogUnmountAll ${diskNumber}"\n`; + instructions += `ogUnmountAll ${diskNumber} 2>/dev/null\n`; + instructions += `ogUnmountCache\n`; + instructions += `ogEcho session "[30] $MSG_HELP_ogUpdatePartitionTable ${diskNumber}"\n`; + instructions += `ogDeletePartitionTable ${diskNumber}\n`; + instructions += `ogUpdatePartitionTable ${diskNumber}\n`; + + this.selectedDisk.partitions.forEach((partition: { removed: any; partitionNumber: any; partitionCode: any; filesystem: any; size: any; format: any; }, index: any) => { + if (partition.removed) return; + + const partNumber = partition.partitionNumber; + const partType = partition.partitionCode; + const fs = partition.filesystem; + const size = partition.size; + const shouldFormat = partition.format ? 'yes' : 'no'; + + instructions += `ogCreatePartition ${diskNumber} ${partNumber} ${partType} ${fs} ${size}MB ${shouldFormat}\n`; + }); + + instructions += `ogExecAndLog command session ogListPartitions ${diskNumber}\n`; + + this.generatedInstructions = instructions; + } } diff --git a/ogWebconsole/src/app/components/groups/components/client-main-view/run-script-assistant/run-script-assistant.component.ts b/ogWebconsole/src/app/components/groups/components/client-main-view/run-script-assistant/run-script-assistant.component.ts index b463fc0..2909ac5 100644 --- a/ogWebconsole/src/app/components/groups/components/client-main-view/run-script-assistant/run-script-assistant.component.ts +++ b/ogWebconsole/src/app/components/groups/components/client-main-view/run-script-assistant/run-script-assistant.component.ts @@ -203,7 +203,8 @@ export class RunScriptAssistantComponent implements OnInit{ width: '800px', data: { scope: this.runScriptContext.type, - organizationalUnit: this.runScriptContext['@id'] + organizationalUnit: this.runScriptContext['@id'], + source: 'assistant' } });