Validators fo docker configurator

This commit is contained in:
piotrpekala7 2020-09-09 17:32:48 +02:00
parent 820fa9f690
commit 169a06fd3a
2 changed files with 7 additions and 3 deletions

View File

@ -21,6 +21,7 @@
<mat-form-field class="form-field">
<input formControlName="memory" matInput type="number" [(ngModel)]="node.properties.memory" placeholder="Maximum memory">
<span matSuffix>MB</span>
</mat-form-field>
<mat-form-field class="form-field">

View File

@ -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;
});
}