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 48aa5da..90ee6ca 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 @@ -102,8 +102,8 @@ @if (imageType === 'monolithic') { -
- +
+ {{ 'selectDeployMethod' | translate }} @for (method of allMethods; track method.value) { @@ -111,6 +111,19 @@ } + + + {{ 'selectRepository' | translate }} + + @for (repo of allImageRepositories; track repo.uuid) { + {{ repo.name }} ({{ repo.ip }}) + } + + @if (loadingAllRepositories) { + hourglass_empty + } + + {{ 'selectImagePrompt' | translate }} @@ -127,8 +140,20 @@ @if (imageType === 'git') { -
- +
+ + {{ 'selectRepository' | translate }} + + @for (repo of allImageRepositories; track repo.uuid) { + {{ repo.name }} ({{ repo.ip }}) + } + + @if (loadingAllRepositories) { + hourglass_empty + } + + + {{ 'buttonSelectRepository' | translate }} @@ -143,10 +168,10 @@ } - + {{ 'buttonSelectBranch' | translate }} + [disabled]="loadingBranches || !selectedGitRepository"> @for (branch of branches; track branch) { {{ branch }} @@ -158,7 +183,7 @@ } - + {{ 'labelTag' | translate }} {{ 'buttonNo' | translate }} 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 0faf0fd..e571f48 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 @@ -63,6 +63,8 @@ export class DeployImageComponent implements OnInit { selectedModelClient: any = null; filteredPartitions: any[] = []; + allImageRepositories: any[] = []; + loadingAllRepositories: boolean = false; selectedRepository: any = null; imageType: string = 'monolithic'; @@ -145,6 +147,42 @@ export class DeployImageComponent implements OnInit { this.route.queryParams.subscribe(params => { this.runScriptContext = params['runScriptContext'] ? JSON.parse(params['runScriptContext']) : null; }); + this.loadAllRepositories(); + } + + loadAllRepositories() { + this.loadingAllRepositories = true; + this.http.get(`${this.baseUrl}/image-repositories?page=1&itemsPerPage=10000`).subscribe( + (response: any) => { + this.allImageRepositories = response?.['hydra:member'] || []; + this.loadingAllRepositories = false; + // Si ya había un selectedRepository cargado por el cliente, asegurarse de enlazar la misma referencia del array + if (this.selectedRepository) { + const match = this.allImageRepositories.find(r => r.uuid === this.selectedRepository.uuid); + if (match) { + this.selectedRepository = match; + } + } + }, + (error) => { + console.error(this.translate.instant('errorLoadingRepositories1'), error); + this.loadingAllRepositories = false; + } + ); + } + + compareRepositories(r1: any, r2: any): boolean { + return r1 && r2 ? r1.uuid === r2.uuid : r1 === r2; + } + + onRepositorySelected(repo: any) { + this.selectedRepository = repo; + if (this.imageType === 'git') { + this.selectedGitRepository = ''; + this.selectedBranch = ''; + this.loadGitRepositories(); + } + this.loadImages(); } onImageTypeSelected(event: any) { @@ -217,7 +255,13 @@ export class DeployImageComponent implements OnInit { this.filteredPartitions = fullClientData.partitions; this.selectedRepository = fullClientData.repository ?? null; - if (this.selectedRepository?.uuid) { + if (this.selectedRepository?.uuid && this.allImageRepositories.length > 0) { + const match = this.allImageRepositories.find(r => r.uuid === this.selectedRepository.uuid); + if (match) { + this.selectedRepository = match; + } + } else if (this.selectedRepository?.uuid) { + // Fallback por si la llamada de loadAllRepositories no ha terminado this.http.get(`${this.baseUrl}/image-repositories/${this.selectedRepository.uuid}`).subscribe( (repository: any) => { this.selectedRepository = repository; @@ -267,7 +311,9 @@ export class DeployImageComponent implements OnInit { if (this.imageType === 'monolithic') { url = `${this.baseUrl}/image-image-repositories?status=success&repository.id=${repositoryId}&page=1&itemsPerPage=1000`; } else { - url = `${this.baseUrl}/git-image-repositories?status=success&repository.id=${repositoryId}&page=1&itemsPerPage=1000`; + // Para 'git', la carga de repositorios y ramas se maneja con loadGitRepositories() y loadGitBranches() + this.images = []; + return; } this.http.get(url).subscribe( diff --git a/ogWebconsole/src/locale/cat.json b/ogWebconsole/src/locale/cat.json index 76153a0..4836deb 100644 --- a/ogWebconsole/src/locale/cat.json +++ b/ogWebconsole/src/locale/cat.json @@ -152,7 +152,7 @@ "buttonSelectIso": "Seleccionar ISO", "buttonSelectOption": "Seleccionar opció", "buttonSelectPartition": "Seleccionar partició", - "buttonSelectRepository": "Seleccionar Repositori", + "buttonSelectRepository": "Seleccionar Repositori Git", "buttonSync": "Sincronitzar", "buttonUpdate": "Actualitzar", "buttonUpdateData": "Actualitzar dades", @@ -1282,7 +1282,7 @@ "selectParentOuDhcpHint": "Seleccioni una Unitat Organitzativa Pare (OU) on agrupar les subxarxes i clients que es detectin automàticament en el servei DHCP.", "selectPartitionToBootOs": "Seleccionar partició per arrencar SO", "selectPartitionToInventory": "Seleccionar partició per inventariar", - "selectRepository": "Seleccionar repositori", + "selectRepository": "Seleccionar Repositori OG", "selectRepoToView": "Tria un repositori de la llista per veure el seu estat detallat.", "selectScriptToRun": "Seleccioni script a executar", "selectScriptToView": "Tria un script desat de la llista per veure el seu contingut i configurar paràmetres.", diff --git a/ogWebconsole/src/locale/en.json b/ogWebconsole/src/locale/en.json index c87fbce..a605c7e 100644 --- a/ogWebconsole/src/locale/en.json +++ b/ogWebconsole/src/locale/en.json @@ -152,7 +152,7 @@ "buttonSelectIso": "Select ISO", "buttonSelectOption": "Select option", "buttonSelectPartition": "Select partition", - "buttonSelectRepository": "Select Repository", + "buttonSelectRepository": "Select Git Repository", "buttonSync": "Sync", "buttonUpdate": "Refresh", "buttonUpdateData": "Update data", @@ -1283,7 +1283,7 @@ "selectParentOuDhcpHint": "Select a Parent Organizational Unit (OU) to group the subnets and clients automatically detected in the DHCP service.", "selectPartitionToBootOs": "Select partition to boot OS", "selectPartitionToInventory": "Select partition to inventory", - "selectRepository": "Select repository", + "selectRepository": "Select OG Repository", "selectRepoToView": "Select a repository from the list to view its detailed status.", "selectScriptToRun": "Select script to run", "selectScriptToView": "Select a saved script from the list to view its content and configure parameters.", diff --git a/ogWebconsole/src/locale/es.json b/ogWebconsole/src/locale/es.json index 61dd482..ae8f7f4 100644 --- a/ogWebconsole/src/locale/es.json +++ b/ogWebconsole/src/locale/es.json @@ -152,7 +152,7 @@ "buttonSelectIso": "Seleccionar ISO", "buttonSelectOption": "Seleccionar opción", "buttonSelectPartition": "Seleccionar partición", - "buttonSelectRepository": "Seleccionar Repositorio", + "buttonSelectRepository": "Seleccionar Repositorio Git", "buttonSync": "Sincronizar", "buttonUpdate": "Actualizar", "buttonUpdateData": "Actualizar datos", @@ -1283,7 +1283,7 @@ "selectParentOuDhcpHint": "Seleccione una Unidad Organizativa Padre (OU) donde agrupar las subredes y clientes que se detecten automáticamente en el servicio DHCP.", "selectPartitionToBootOs": "Seleccionar particion para arrancar SO", "selectPartitionToInventory": "Seleccionar partición para inventariar", - "selectRepository": "Seleccionar repositorio", + "selectRepository": "Seleccionar Repositorio OG", "selectRepoToView": "Elige un repositorio de la lista para ver su estado detallado.", "selectScriptToRun": "Seleccione script a ejecutar", "selectScriptToView": "Elige un script guardado de la lista para ver su contenido y configurar parámetros.",