refs #1058. Fixed Software Profile bug
testing/ogGui-multibranch/pipeline/head There was a failure building this commit Details

oggui/translations
Manuel Aranda Rosales 2024-10-29 16:51:17 +01:00
parent ffebe422ba
commit 151ea50c4f
4 changed files with 40 additions and 4 deletions

View File

@ -7,6 +7,15 @@
<input matInput formControlName="name" required>
</mat-form-field>
<mat-form-field appearance="fill" class="form-field">
<mat-label>Repositorio</mat-label>
<mat-select formControlName="imageRepository" required>
<mat-option *ngFor="let imageRepository of repositories" [value]="imageRepository['@id']">
{{ imageRepository.name }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="fill" class="form-field">
<mat-label>Descripción</mat-label>
<input matInput formControlName="description" name="description">

View File

@ -14,6 +14,7 @@ export class CreateImageComponent implements OnInit {
imageForm: FormGroup<any>;
imageId: string | null = null;
softwareProfiles: any[] = [];
repositories: any[] = [];
constructor(
private fb: FormBuilder,
@ -29,6 +30,7 @@ export class CreateImageComponent implements OnInit {
comments: [''],
remotePc: [false],
softwareProfile: ['', Validators.required],
imageRepository: ['', Validators.required],
});
}
@ -37,6 +39,7 @@ export class CreateImageComponent implements OnInit {
this.load()
}
this.fetchSoftwareProfiles();
this.fetchRepositories();
}
load(): void {
@ -47,7 +50,8 @@ export class CreateImageComponent implements OnInit {
description: [response.description],
comments: [response.comments],
remotePc: [response.remotePc],
softwareProfile: [response.softwareProfile, Validators.required],
softwareProfile: [response.softwareProfile['@id'], Validators.required],
imageRepository: [response.repository['@id'], Validators.required],
});
this.imageId = response['@id'];
},
@ -70,13 +74,32 @@ export class CreateImageComponent implements OnInit {
});
}
fetchRepositories() {
const url = `${this.baseUrl}/image-repositories`;
this.http.get(url).subscribe({
next: (response: any) => {
this.repositories = response['hydra:member'];
},
error: (error) => {
console.error('Error al obtener los repositorios de imágenes:', error);
this.toastService.error('Error al obtener los repositorios de imágenes');
}
});
}
saveImage(): void {
if (this.imageForm.invalid) {
this.toastService.error('Por favor, rellena los campos obligatorios');
return;
}
const payload = {
name: this.imageForm.value.name,
description: this.imageForm.value.description,
comments: this.imageForm.value.comments,
remotePc: this.imageForm.value.remotePc,
softwareProfile: this.imageForm.value.softwareProfile
softwareProfile: this.imageForm.value.softwareProfile,
imageRepository: this.imageForm.value.imageRepository,
};
if (this.imageId) {

View File

@ -38,9 +38,14 @@ export class ImagesComponent implements OnInit {
header: 'Perfil de software',
cell: (image: any) => `${image.softwareProfile?.description}`
},
{
columnDef: 'imageRepository',
header: 'Repositorio',
cell: (image: any) => `${image.imageRepository?.name}`
},
{
columnDef: 'remotePc',
header: 'Acceso remoto',
header: 'Remote Pc',
cell: (image: any) => `${image.remotePc}`
},
{

View File

@ -110,7 +110,6 @@ export class CreateSoftwareProfileComponent {
}
load(): void {
console.log(this.data);
this.dataService.getSoftwareProfile(this.data).subscribe({
next: (response) => {
this.formGroup = this.fb.group({