From 169a06fd3a63acf67a207713fbbe54652c61e1f7 Mon Sep 17 00:00:00 2001 From: piotrpekala7 <31202938+piotrpekala7@users.noreply.github.com> Date: Wed, 9 Sep 2020 17:32:48 +0200 Subject: [PATCH] Validators fo docker configurator --- .../docker/configurator-docker.component.html | 1 + .../configurator/docker/configurator-docker.component.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/app/components/project-map/node-editors/configurator/docker/configurator-docker.component.html b/src/app/components/project-map/node-editors/configurator/docker/configurator-docker.component.html index 232e63f4..f0d49a6a 100644 --- a/src/app/components/project-map/node-editors/configurator/docker/configurator-docker.component.html +++ b/src/app/components/project-map/node-editors/configurator/docker/configurator-docker.component.html @@ -21,6 +21,7 @@ + MB diff --git a/src/app/components/project-map/node-editors/configurator/docker/configurator-docker.component.ts b/src/app/components/project-map/node-editors/configurator/docker/configurator-docker.component.ts index aea879a6..157d00a2 100644 --- a/src/app/components/project-map/node-editors/configurator/docker/configurator-docker.component.ts +++ b/src/app/components/project-map/node-editors/configurator/docker/configurator-docker.component.ts @@ -6,6 +6,7 @@ import { NodeService } from '../../../../../services/node.service'; import { ToasterService } from '../../../../../services/toaster.service'; import { MatDialogRef } from '@angular/material/dialog'; import { DockerConfigurationService } from '../../../../../services/docker-configuration.service'; +import { NonNegativeValidator } from '../../../../../validators/non-negative-validator'; @Component({ @@ -34,13 +35,14 @@ export class ConfiguratorDialogDockerComponent implements OnInit { public nodeService: NodeService, private toasterService: ToasterService, private formBuilder: FormBuilder, - private dockerConfigurationService: DockerConfigurationService + private dockerConfigurationService: DockerConfigurationService, + private nonNegativeValidator: NonNegativeValidator, ) { this.generalSettingsForm = this.formBuilder.group({ name: new FormControl('', Validators.required), adapter: new FormControl('', Validators.required), - memory: new FormControl(''), - cpus: new FormControl(''), + memory: new FormControl('', nonNegativeValidator.get), + cpus: new FormControl('', nonNegativeValidator.get), startCommand: new FormControl('', Validators.required), consoleHttpPort: new FormControl('', Validators.required), consoleHttpPath: new FormControl('', Validators.required) @@ -52,6 +54,7 @@ export class ConfiguratorDialogDockerComponent implements OnInit { this.node = node; this.name = node.name; this.getConfiguration(); + if (!this.node.properties.memory) this.node.properties.cpus = 0.0; }); }