Update add-docker-template.component.ts

This commit is contained in:
piotrpekala7 2020-06-02 18:08:25 +02:00
parent 455a13b96f
commit 7625ff5cfa

View File

@ -25,6 +25,7 @@ export class AddDockerTemplateComponent implements OnInit {
consoleTypes: string[] = [];
isRemoteComputerChosen: boolean = false;
dockerImages: DockerImage[] = [];
selectedImage: DockerImage;
newImageSelected: boolean = false;
virtualMachineForm: FormGroup;
@ -101,9 +102,15 @@ export class AddDockerTemplateComponent implements OnInit {
}
addTemplate() {
if ((!this.virtualMachineForm.invalid || !this.newImageSelected) && !this.containerNameForm.invalid && !this.networkAdaptersForm.invalid) {
if ((!this.virtualMachineForm.invalid || (!this.newImageSelected && this.selectedImage)) && !this.containerNameForm.invalid && !this.networkAdaptersForm.invalid) {
this.dockerTemplate.template_id = uuid();
this.dockerTemplate.image = this.virtualMachineForm.get('filename').value;
if (this.newImageSelected) {
this.dockerTemplate.image = this.virtualMachineForm.get('filename').value;
} else {
this.dockerTemplate.image = this.selectedImage.image;
}
this.dockerTemplate.name = this.containerNameForm.get('templateName').value;
this.dockerTemplate.adapters = this.networkAdaptersForm.get('adapters').value;
this.dockerTemplate.compute_id = this.isGns3VmChosen ? 'vm' : 'local';