refs #2596. Create task options from createImage
testing/ogGui-multibranch/pipeline/head There was a failure building this commit Details

pull/36/head
Manuel Aranda Rosales 2025-08-25 13:12:41 +02:00
parent ee950fd685
commit 3eae96f2c8
4 changed files with 114 additions and 3 deletions

View File

@ -1,4 +1,13 @@
# Changelog
## [0.20.0] - 2025-08-25
### Added
- Se ha añadido un nuevo boton en "Trazas" para marcar la misma como completada cuando se requiera.
- Nuevo estado "ocupado" en las trazas para indicar que el cliente envia un "409" y que ya esta ejecutando una accion
### Improved
- Mejorada la interfaz para gestionar las tareas.
---
## [0.19.0] - 2025-08-06
### Added
- Se ha añadido un nuevo estado "enviado" para cuando se ejecuten acciones a equipos en estado Windows o Linux

View File

@ -129,8 +129,9 @@
.button-row {
display: flex;
padding-right: 1em;
gap: 12px;
padding-right: 0;
align-items: center;
}
/* Tabla de particiones modernizada */

View File

@ -23,6 +23,13 @@
<div class="button-row">
<button class="action-button" id="execute-button" [disabled]="!selectedPartition || loading" (click)="save()">Ejecutar</button>
</div>
<div class="button-row">
<button class="action-button" color="accent"
[disabled]="!isFormValid()"
(click)="openScheduleModal()">
Opciones de programación
</button>
</div>
</div>
<div class="select-container">

View File

@ -9,6 +9,7 @@ import {MatDialog} from "@angular/material/dialog";
import {QueueConfirmationModalComponent} from "../../../../../shared/queue-confirmation-modal/queue-confirmation-modal.component";
import {CreateRepositoryModalComponent} from "./create-repository-modal/create-repository-modal.component";
import {CreateBranchModalComponent} from "../../../../repositories/show-git-images/create-branch-modal/create-branch-modal.component";
import {CreateTaskComponent} from "../../../../commands/commands-task/create-task/create-task.component";
@Component({
selector: 'app-create-image',
@ -108,7 +109,6 @@ export class CreateClientImageComponent implements OnInit{
}
ngOnInit() {
console.log('CreateImageComponent ngOnInit ejecutado');
this.clientId = this.route.snapshot.paramMap.get('id');
this.loadPartitions();
this.loadImages();
@ -612,8 +612,102 @@ export class CreateClientImageComponent implements OnInit{
this.isDestinationBranchEditable = !this.isDestinationBranchEditable;
if (!this.isDestinationBranchEditable) {
// Opcional: Aquí se pueden agregar validaciones adicionales
console.log('Rama destino guardada:', this.destinationBranch);
}
}
isFormValid(): boolean {
if (!this.selectedPartition) {
return false;
}
if (this.imageType === 'monolithic') {
if (this.monolithicAction === 'create') {
return this.name !== null && this.name.trim().length > 0;
} else if (this.monolithicAction === 'update') {
return this.selectedImage !== null;
}
} else if (this.imageType === 'git') {
if (this.hasValidGitData) {
return this.destinationBranch !== null && this.destinationBranch.trim().length > 0;
} else {
return this.selectedGitRepository !== null;
}
}
return false;
}
openScheduleModal(): void {
let scope = 'clients';
// Verificar que tenemos la información del cliente
if (!this.client) {
this.toastService.error('No se ha cargado la información del cliente');
return;
}
// Crear un array con el objeto cliente completo
let selectedClients = [this.client];
console.log(selectedClients);
const dialogRef = this.dialog.open(CreateTaskComponent, {
width: '800px',
data: {
scope: scope,
selectedClients: selectedClients,
organizationalUnit: this.client['@id'],
source: 'create-image',
runScriptContext: null
}
});
dialogRef.afterClosed().subscribe((result: any) => {
if (result) {
// Verificar que tenemos la partición seleccionada
if (!this.selectedPartition) {
this.toastService.error('Debe seleccionar una partición');
return;
}
let payload: any = {};
if (this.imageType === 'monolithic') {
payload = {
type: 'monolithic',
action: this.monolithicAction,
diskNumber: this.selectedPartition.diskNumber,
partitionNumber: this.selectedPartition.partitionNumber,
imageName: this.monolithicAction === 'create' ? this.name : this.selectedImage?.name
};
} else if (this.imageType === 'git') {
payload = {
type: 'git',
diskNumber: this.selectedPartition.diskNumber,
partitionNumber: this.selectedPartition.partitionNumber,
repository: this.selectedGitRepository?.name || this.gitData?.repo,
sourceBranch: this.gitData?.branch,
destinationBranch: this.destinationBranch
};
}
const taskId = result['taskId'] ? result['taskId']['@id'] : result['@id'];
const executionOrder = result['executionOrder'] || 1;
this.http.post(`${this.baseUrl}/command-task-scripts`, {
commandTask: taskId,
parameters: payload,
order: executionOrder,
type: 'create-image',
}).subscribe({
next: () => {
this.toastService.success('Tarea de creación de imagen programada con éxito');
},
error: (error) => {
this.toastService.error(error.error['hydra:description'] || 'Error al programar la tarea');
}
});
}
});
}
}