in submarine-workbench/workbench-web/src/app/pages/workbench/experiment/experiment-home/experiment-form/experiment-customized-form/experiment-customized-form.component.ts [88:157]
ngOnInit() {
this.experiment = new FormGroup({
experimentName: new FormControl(null, [Validators.pattern('([a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9]|[a-zA-Z0-9]+)'), Validators.required]),
description: new FormControl(null, [Validators.required]),
tags: new FormControl([], []),
cmd: new FormControl('', [Validators.required]),
image: new FormControl(this.defaultImage, [Validators.required]),
envs: new FormArray([], [this.experimentValidatorService.nameValidatorFactory('key')]),
specs: new FormArray([], [this.experimentValidatorService.nameValidatorFactory('name')]),
gitRepo: new FormControl(null, []),
gitBranch: new FormControl(null, []),
gitUsername: new FormControl(null, []),
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) => {
const envImage = item.spec.environment.image;
if (this.imageList.indexOf(envImage) === -1) {
this.imageList.push(envImage)
}
});
},
(error) => {
console.error(error);
}
)
// Bind the component method for callback
this.checkStatus = this.checkStatus.bind(this);
if (this.mode === 'update') {
this.updateExperimentInit();
} else if (this.mode === 'clone') {
this.cloneExperimentInit(this.targetSpec);
}
// Fire status to parent when form value has changed
const sub1 = this.experiment.valueChanges.subscribe(this.checkStatus);
const sub2 = this.experimentFormService.stepService.subscribe((n) => {
if (n > 0) {
if (this.step === this.PREVIEW_STEP) {
this.handleSubmit();
} else if (this.step === this.SECOND_STEP) {
this.onPreview();
this.step += 1;
} else {
this.step += 1;
}
} else {
this.step -= 1;
}
// Send the current step and okText back to parent
this.experimentFormService.modalPropsChange({
okText: this.step !== this.PREVIEW_STEP ? 'Next step' : 'Submit',
currentStep: this.step
});
// Run check after step is changed
this.checkStatus();
});
this.subscriptions.push(sub1, sub2);
//TODO: get tags from server
this.listOfOption = [];
}