Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
Fix list (#1087)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdmikechen authored Jul 20, 2023
1 parent 09a7e77 commit dbcf369
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
<nz-option *ngFor="let image of imageList" [nzValue]="image" [nzLabel]="image"></nz-option>
</nz-select>
<ng-template #renderTemplate>
<nz-divider></nz-divider>
<div class="container">
<input type="text" nz-input #inputElement />
<a class="add-item" (click)="addItem(inputElement)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,14 @@ export class ExperimentCustomizedFormComponent implements OnInit, OnDestroy {
gitPassword: new FormControl(null, [])
});

// Initialise the list of image, the default values of image are from the current experiment list images
this.experimentService.fetchExperimentList().subscribe(
(list) => {
list.forEach((item) => {
this.imageList.push(item.spec.environment.image);
const envImage = item.spec.environment.image;
if (this.imageList.indexOf(envImage) === -1) {
this.imageList.push(envImage)
}
});
},
(error) => {
Expand Down Expand Up @@ -160,9 +164,14 @@ export class ExperimentCustomizedFormComponent implements OnInit, OnDestroy {
}

addItem(input: HTMLInputElement): void {
const value = input.value;
if (this.imageList.indexOf(value) === -1) {
this.imageList = [...this.imageList, input.value || `New item ${this.imageIndex++}`];
let value = input.value;
if (value === null || typeof value === "undefined") {
return;
} else {
value = value.replace(/\s+/g, "");
if (value !== "" && this.imageList.indexOf(value) === -1) {
this.imageList = [...this.imageList, value];
}
}
}

Expand Down

0 comments on commit dbcf369

Please sign in to comment.