]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: move config option types to their own class
authorTatjana Dehler <tdehler@suse.com>
Thu, 29 Nov 2018 14:51:34 +0000 (15:51 +0100)
committerTatjana Dehler <tdehler@suse.com>
Wed, 23 Jan 2019 10:24:55 +0000 (11:24 +0100)
Move the config option types information into their own class to
reuse them easily in other components.

Signed-off-by: Tatjana Dehler <tdehler@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration-form/configuration-form.types.spec.ts [new file with mode: 0644]
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration-form/configuration-form.types.ts [new file with mode: 0644]
src/pybind/mgr/dashboard/frontend/src/locale/messages.xlf

index d411d6724d2b77d8e641e637b92cddad04747474..a80f9bd85a371b6cb8c2e5bf372cff6e6f71d19c 100644 (file)
@@ -41,124 +41,6 @@ describe('ConfigurationFormComponent', () => {
     expect(component).toBeTruthy();
   });
 
-  describe('getType', () => {
-    it('should return uint type', () => {
-      const ret = component.getType('uint');
-      expect(ret).toBeTruthy();
-      expect(ret.name).toBe('uint');
-      expect(ret.inputType).toBe('number');
-      expect(ret.humanReadable).toBe('Positive integer value');
-      expect(ret.defaultMin).toBe(0);
-      expect(ret.patternHelpText).toBe('The entered value needs to be a positive number.');
-      expect(ret.isNumberType).toBe(true);
-      expect(ret.allowsNegative).toBe(false);
-    });
-
-    it('should return int type', () => {
-      const ret = component.getType('int');
-      expect(ret).toBeTruthy();
-      expect(ret.name).toBe('int');
-      expect(ret.inputType).toBe('number');
-      expect(ret.humanReadable).toBe('Integer value');
-      expect(ret.defaultMin).toBeUndefined();
-      expect(ret.patternHelpText).toBe('The entered value needs to be a number.');
-      expect(ret.isNumberType).toBe(true);
-      expect(ret.allowsNegative).toBe(true);
-    });
-
-    it('should return size type', () => {
-      const ret = component.getType('size');
-      expect(ret).toBeTruthy();
-      expect(ret.name).toBe('size');
-      expect(ret.inputType).toBe('number');
-      expect(ret.humanReadable).toBe('Positive integer value (size)');
-      expect(ret.defaultMin).toBe(0);
-      expect(ret.patternHelpText).toBe('The entered value needs to be a positive number.');
-      expect(ret.isNumberType).toBe(true);
-      expect(ret.allowsNegative).toBe(false);
-    });
-
-    it('should return secs type', () => {
-      const ret = component.getType('secs');
-      expect(ret).toBeTruthy();
-      expect(ret.name).toBe('secs');
-      expect(ret.inputType).toBe('number');
-      expect(ret.humanReadable).toBe('Positive integer value (secs)');
-      expect(ret.defaultMin).toBe(1);
-      expect(ret.patternHelpText).toBe('The entered value needs to be a positive number.');
-      expect(ret.isNumberType).toBe(true);
-      expect(ret.allowsNegative).toBe(false);
-    });
-
-    it('should return float type', () => {
-      const ret = component.getType('float');
-      expect(ret).toBeTruthy();
-      expect(ret.name).toBe('float');
-      expect(ret.inputType).toBe('number');
-      expect(ret.humanReadable).toBe('Decimal value');
-      expect(ret.defaultMin).toBeUndefined();
-      expect(ret.patternHelpText).toBe('The entered value needs to be a number or decimal.');
-      expect(ret.isNumberType).toBe(true);
-      expect(ret.allowsNegative).toBe(true);
-    });
-
-    it('should return str type', () => {
-      const ret = component.getType('str');
-      expect(ret).toBeTruthy();
-      expect(ret.name).toBe('str');
-      expect(ret.inputType).toBe('text');
-      expect(ret.humanReadable).toBe('Text');
-      expect(ret.defaultMin).toBeUndefined();
-      expect(ret.patternHelpText).toBeUndefined();
-      expect(ret.isNumberType).toBe(false);
-      expect(ret.allowsNegative).toBeUndefined();
-    });
-
-    it('should return addr type', () => {
-      const ret = component.getType('addr');
-      expect(ret).toBeTruthy();
-      expect(ret.name).toBe('addr');
-      expect(ret.inputType).toBe('text');
-      expect(ret.humanReadable).toBe('IPv4 or IPv6 address');
-      expect(ret.defaultMin).toBeUndefined();
-      expect(ret.patternHelpText).toBe('The entered value needs to be a valid IP address.');
-      expect(ret.isNumberType).toBe(false);
-      expect(ret.allowsNegative).toBeUndefined();
-    });
-
-    it('should return uuid type', () => {
-      const ret = component.getType('uuid');
-      expect(ret).toBeTruthy();
-      expect(ret.name).toBe('uuid');
-      expect(ret.inputType).toBe('text');
-      expect(ret.humanReadable).toBe('UUID');
-      expect(ret.defaultMin).toBeUndefined();
-      expect(ret.patternHelpText).toBe(
-        'The entered value is not a valid UUID, e.g.: 67dcac9f-2c03-4d6c-b7bd-1210b3a259a8'
-      );
-      expect(ret.isNumberType).toBe(false);
-      expect(ret.allowsNegative).toBeUndefined();
-    });
-
-    it('should return bool type', () => {
-      const ret = component.getType('bool');
-      expect(ret).toBeTruthy();
-      expect(ret.name).toBe('bool');
-      expect(ret.inputType).toBe('checkbox');
-      expect(ret.humanReadable).toBe('Boolean value');
-      expect(ret.defaultMin).toBeUndefined();
-      expect(ret.patternHelpText).toBeUndefined();
-      expect(ret.isNumberType).toBe(false);
-      expect(ret.allowsNegative).toBeUndefined();
-    });
-
-    it('should throw an error for unknown type', () => {
-      expect(() =>
-        component.getType('unknown').toThrowError('Found unknown type "unknown" for config option.')
-      );
-    });
-  });
-
   describe('getValidators', () => {
     it('should return a validator for types float, addr and uuid', () => {
       const types = ['float', 'addr', 'uuid'];
index 87b94e5e832147d1ea8d87e88e6ca18cf26a4cdb..460f7eaf8eedae220971727d43a36bba974e5f90 100644 (file)
@@ -1,5 +1,5 @@
 import { Component, OnInit } from '@angular/core';
-import { FormControl, FormGroup, ValidatorFn, Validators } from '@angular/forms';
+import { FormControl, FormGroup, ValidatorFn } from '@angular/forms';
 import { ActivatedRoute, Router } from '@angular/router';
 
 import { I18n } from '@ngx-translate/i18n-polyfill';
@@ -8,10 +8,10 @@ import * as _ from 'lodash';
 import { ConfigurationService } from '../../../../shared/api/configuration.service';
 import { NotificationType } from '../../../../shared/enum/notification-type.enum';
 import { CdFormGroup } from '../../../../shared/forms/cd-form-group';
-import { CdValidators } from '../../../../shared/forms/cd-validators';
 import { NotificationService } from '../../../../shared/services/notification.service';
 import { ConfigFormCreateRequestModel } from './configuration-form-create-request.model';
 import { ConfigFormModel } from './configuration-form.model';
+import { ConfigOptionTypes } from './configuration-form.types';
 
 @Component({
   selector: 'cd-configuration-form',
@@ -66,127 +66,20 @@ export class ConfigurationFormComponent implements OnInit {
     });
   }
 
-  getType(type: string): any {
-    const knownTypes = [
-      {
-        name: 'uint',
-        inputType: 'number',
-        humanReadable: this.i18n('Positive integer value'),
-        defaultMin: 0,
-        patternHelpText: this.i18n('The entered value needs to be a positive number.'),
-        isNumberType: true,
-        allowsNegative: false
-      },
-      {
-        name: 'int',
-        inputType: 'number',
-        humanReadable: this.i18n('Integer value'),
-        patternHelpText: this.i18n('The entered value needs to be a number.'),
-        isNumberType: true,
-        allowsNegative: true
-      },
-      {
-        name: 'size',
-        inputType: 'number',
-        humanReadable: this.i18n('Positive integer value (size)'),
-        defaultMin: 0,
-        patternHelpText: this.i18n('The entered value needs to be a positive number.'),
-        isNumberType: true,
-        allowsNegative: false
-      },
-      {
-        name: 'secs',
-        inputType: 'number',
-        humanReadable: this.i18n('Positive integer value (secs)'),
-        defaultMin: 1,
-        patternHelpText: this.i18n('The entered value needs to be a positive number.'),
-        isNumberType: true,
-        allowsNegative: false
-      },
-      {
-        name: 'float',
-        inputType: 'number',
-        humanReadable: this.i18n('Decimal value'),
-        patternHelpText: this.i18n('The entered value needs to be a number or decimal.'),
-        isNumberType: true,
-        allowsNegative: true
-      },
-      {
-        name: 'str',
-        inputType: 'text',
-        humanReadable: this.i18n('Text'),
-        isNumberType: false
-      },
-      {
-        name: 'addr',
-        inputType: 'text',
-        humanReadable: this.i18n('IPv4 or IPv6 address'),
-        patternHelpText: this.i18n('The entered value needs to be a valid IP address.'),
-        isNumberType: false
-      },
-      {
-        name: 'uuid',
-        inputType: 'text',
-        humanReadable: this.i18n('UUID'),
-        patternHelpText: this.i18n(
-          'The entered value is not a valid UUID, e.g.: 67dcac9f-2c03-4d6c-b7bd-1210b3a259a8'
-        ),
-        isNumberType: false
-      },
-      {
-        name: 'bool',
-        inputType: 'checkbox',
-        humanReadable: this.i18n('Boolean value'),
-        isNumberType: false
-      }
-    ];
-
-    let currentType = null;
-
-    knownTypes.forEach((knownType) => {
-      if (knownType.name === type) {
-        currentType = knownType;
-      }
-    });
-
-    if (currentType !== null) {
-      return currentType;
-    }
-
-    throw new Error('Found unknown type "' + type + '" for config option.');
-  }
-
   getValidators(configOption: any): ValidatorFn[] {
-    const typeParams = this.getType(configOption.type);
-    this.patternHelpText = typeParams.patternHelpText;
-
-    if (typeParams.isNumberType) {
-      const validators = [];
-
-      if (configOption.max && configOption.max !== '') {
-        this.maxValue = configOption.max;
-        validators.push(Validators.max(configOption.max));
-      }
+    const typeValidators = ConfigOptionTypes.getTypeValidators(configOption);
+    if (typeValidators) {
+      this.patternHelpText = typeValidators.patternHelpText;
 
-      if ('min' in configOption && configOption.min !== '') {
-        this.minValue = configOption.min;
-        validators.push(Validators.min(configOption.min));
-      } else if ('defaultMin' in typeParams) {
-        this.minValue = typeParams.defaultMin;
-        validators.push(Validators.min(typeParams.defaultMin));
+      if ('max' in typeValidators && typeValidators.max !== '') {
+        this.maxValue = typeValidators.max;
       }
 
-      if (configOption.type === 'float') {
-        validators.push(CdValidators.decimalNumber());
-      } else {
-        validators.push(CdValidators.number(typeParams.allowsNegative));
+      if ('min' in typeValidators && typeValidators.min !== '') {
+        this.minValue = typeValidators.min;
       }
 
-      return validators;
-    } else if (configOption.type === 'addr') {
-      return [CdValidators.ip()];
-    } else if (configOption.type === 'uuid') {
-      return [CdValidators.uuid()];
+      return typeValidators.validators;
     }
   }
 
@@ -250,7 +143,7 @@ export class ConfigurationFormComponent implements OnInit {
         .setValidators(validators);
     });
 
-    const currentType = this.getType(response.type);
+    const currentType = ConfigOptionTypes.getType(response.type);
     this.type = currentType.name;
     this.inputType = currentType.inputType;
     this.humanReadableType = currentType.humanReadable;
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration-form/configuration-form.types.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration-form/configuration-form.types.spec.ts
new file mode 100644 (file)
index 0000000..d5fa623
--- /dev/null
@@ -0,0 +1,215 @@
+import { ConfigFormModel } from './configuration-form.model';
+import { ConfigOptionTypes } from './configuration-form.types';
+
+describe('ConfigOptionTypes', () => {
+  describe('getType', () => {
+    it('should return uint type', () => {
+      const ret = ConfigOptionTypes.getType('uint');
+      expect(ret).toBeTruthy();
+      expect(ret.name).toBe('uint');
+      expect(ret.inputType).toBe('number');
+      expect(ret.humanReadable).toBe('Unsigned integer value');
+      expect(ret.defaultMin).toBe(0);
+      expect(ret.patternHelpText).toBe('The entered value needs to be an unsigned number.');
+      expect(ret.isNumberType).toBe(true);
+      expect(ret.allowsNegative).toBe(false);
+    });
+
+    it('should return int type', () => {
+      const ret = ConfigOptionTypes.getType('int');
+      expect(ret).toBeTruthy();
+      expect(ret.name).toBe('int');
+      expect(ret.inputType).toBe('number');
+      expect(ret.humanReadable).toBe('Integer value');
+      expect(ret.defaultMin).toBeUndefined();
+      expect(ret.patternHelpText).toBe('The entered value needs to be a number.');
+      expect(ret.isNumberType).toBe(true);
+      expect(ret.allowsNegative).toBe(true);
+    });
+
+    it('should return size type', () => {
+      const ret = ConfigOptionTypes.getType('size');
+      expect(ret).toBeTruthy();
+      expect(ret.name).toBe('size');
+      expect(ret.inputType).toBe('number');
+      expect(ret.humanReadable).toBe('Unsigned integer value (>=16bit)');
+      expect(ret.defaultMin).toBe(0);
+      expect(ret.patternHelpText).toBe('The entered value needs to be a unsigned number.');
+      expect(ret.isNumberType).toBe(true);
+      expect(ret.allowsNegative).toBe(false);
+    });
+
+    it('should return secs type', () => {
+      const ret = ConfigOptionTypes.getType('secs');
+      expect(ret).toBeTruthy();
+      expect(ret.name).toBe('secs');
+      expect(ret.inputType).toBe('number');
+      expect(ret.humanReadable).toBe('Number of seconds');
+      expect(ret.defaultMin).toBe(1);
+      expect(ret.patternHelpText).toBe('The entered value needs to be a number >= 1.');
+      expect(ret.isNumberType).toBe(true);
+      expect(ret.allowsNegative).toBe(false);
+    });
+
+    it('should return float type', () => {
+      const ret = ConfigOptionTypes.getType('float');
+      expect(ret).toBeTruthy();
+      expect(ret.name).toBe('float');
+      expect(ret.inputType).toBe('number');
+      expect(ret.humanReadable).toBe('Double value');
+      expect(ret.defaultMin).toBeUndefined();
+      expect(ret.patternHelpText).toBe('The entered value needs to be a number or decimal.');
+      expect(ret.isNumberType).toBe(true);
+      expect(ret.allowsNegative).toBe(true);
+    });
+
+    it('should return str type', () => {
+      const ret = ConfigOptionTypes.getType('str');
+      expect(ret).toBeTruthy();
+      expect(ret.name).toBe('str');
+      expect(ret.inputType).toBe('text');
+      expect(ret.humanReadable).toBe('Text');
+      expect(ret.defaultMin).toBeUndefined();
+      expect(ret.patternHelpText).toBeUndefined();
+      expect(ret.isNumberType).toBe(false);
+      expect(ret.allowsNegative).toBeUndefined();
+    });
+
+    it('should return addr type', () => {
+      const ret = ConfigOptionTypes.getType('addr');
+      expect(ret).toBeTruthy();
+      expect(ret.name).toBe('addr');
+      expect(ret.inputType).toBe('text');
+      expect(ret.humanReadable).toBe('IPv4 or IPv6 address');
+      expect(ret.defaultMin).toBeUndefined();
+      expect(ret.patternHelpText).toBe('The entered value needs to be a valid IP address.');
+      expect(ret.isNumberType).toBe(false);
+      expect(ret.allowsNegative).toBeUndefined();
+    });
+
+    it('should return uuid type', () => {
+      const ret = ConfigOptionTypes.getType('uuid');
+      expect(ret).toBeTruthy();
+      expect(ret.name).toBe('uuid');
+      expect(ret.inputType).toBe('text');
+      expect(ret.humanReadable).toBe('UUID');
+      expect(ret.defaultMin).toBeUndefined();
+      expect(ret.patternHelpText).toBe(
+        'The entered value is not a valid UUID, e.g.: 67dcac9f-2c03-4d6c-b7bd-1210b3a259a8'
+      );
+      expect(ret.isNumberType).toBe(false);
+      expect(ret.allowsNegative).toBeUndefined();
+    });
+
+    it('should return bool type', () => {
+      const ret = ConfigOptionTypes.getType('bool');
+      expect(ret).toBeTruthy();
+      expect(ret.name).toBe('bool');
+      expect(ret.inputType).toBe('checkbox');
+      expect(ret.humanReadable).toBe('Boolean value');
+      expect(ret.defaultMin).toBeUndefined();
+      expect(ret.patternHelpText).toBeUndefined();
+      expect(ret.isNumberType).toBe(false);
+      expect(ret.allowsNegative).toBeUndefined();
+    });
+
+    it('should throw an error for unknown type', () => {
+      expect(() => ConfigOptionTypes.getType('unknown')).toThrowError(
+        'Found unknown type "unknown" for config option.'
+      );
+    });
+  });
+
+  describe('getTypeValidators', () => {
+    it('should return two validators for type uint, secs and size', () => {
+      const types = ['uint', 'size', 'secs'];
+
+      types.forEach((valType) => {
+        const configOption = new ConfigFormModel();
+        configOption.type = valType;
+
+        const ret = ConfigOptionTypes.getTypeValidators(configOption);
+        expect(ret).toBeTruthy();
+        expect(ret.validators.length).toBe(2);
+      });
+    });
+
+    it('should return a validator for types float, int, addr and uuid', () => {
+      const types = ['float', 'int', 'addr', 'uuid'];
+
+      types.forEach((valType) => {
+        const configOption = new ConfigFormModel();
+        configOption.type = valType;
+
+        const ret = ConfigOptionTypes.getTypeValidators(configOption);
+        expect(ret).toBeTruthy();
+        expect(ret.validators.length).toBe(1);
+      });
+    });
+
+    it('should return undefined for type bool and str', () => {
+      const types = ['str', 'bool'];
+
+      types.forEach((valType) => {
+        const configOption = new ConfigFormModel();
+        configOption.type = valType;
+
+        const ret = ConfigOptionTypes.getTypeValidators(configOption);
+        expect(ret).toBeUndefined();
+      });
+    });
+
+    it('should return a pattern and a min validator', () => {
+      const configOption = new ConfigFormModel();
+      configOption.type = 'int';
+      configOption.min = 2;
+
+      const ret = ConfigOptionTypes.getTypeValidators(configOption);
+      expect(ret).toBeTruthy();
+      expect(ret.validators.length).toBe(2);
+      expect(ret.min).toBe(2);
+      expect(ret.max).toBeUndefined();
+    });
+
+    it('should return a pattern and a max validator', () => {
+      const configOption = new ConfigFormModel();
+      configOption.type = 'int';
+      configOption.max = 5;
+
+      const ret = ConfigOptionTypes.getTypeValidators(configOption);
+      expect(ret).toBeTruthy();
+      expect(ret.validators.length).toBe(2);
+      expect(ret.min).toBeUndefined();
+      expect(ret.max).toBe(5);
+    });
+
+    it('should return multiple validators', () => {
+      const configOption = new ConfigFormModel();
+      configOption.type = 'float';
+      configOption.max = 5.2;
+      configOption.min = 1.5;
+
+      const ret = ConfigOptionTypes.getTypeValidators(configOption);
+      expect(ret).toBeTruthy();
+      expect(ret.validators.length).toBe(3);
+      expect(ret.min).toBe(1.5);
+      expect(ret.max).toBe(5.2);
+    });
+
+    it(
+      'should return a pattern help text for type uint, int, size, secs, ' + 'float, addr and uuid',
+      () => {
+        const types = ['uint', 'int', 'size', 'secs', 'float', 'addr', 'uuid'];
+
+        types.forEach((valType) => {
+          const configOption = new ConfigFormModel();
+          configOption.type = valType;
+
+          const ret = ConfigOptionTypes.getTypeValidators(configOption);
+          expect(ret).toBeTruthy();
+          expect(ret.patternHelpText).toBeDefined();
+        });
+      }
+    );
+  });
+});
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration-form/configuration-form.types.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration-form/configuration-form.types.ts
new file mode 100644 (file)
index 0000000..ed8a3b7
--- /dev/null
@@ -0,0 +1,120 @@
+import { Validators } from '@angular/forms';
+import { CdValidators } from '../../../../shared/forms/cd-validators';
+import { ConfigFormModel } from './configuration-form.model';
+
+import * as _ from 'lodash';
+
+export class ConfigOptionTypes {
+  // TODO: I18N
+  private static knownTypes: Array<any> = [
+    {
+      name: 'uint',
+      inputType: 'number',
+      humanReadable: 'Unsigned integer value',
+      defaultMin: 0,
+      patternHelpText: 'The entered value needs to be an unsigned number.',
+      isNumberType: true,
+      allowsNegative: false
+    },
+    {
+      name: 'int',
+      inputType: 'number',
+      humanReadable: 'Integer value',
+      patternHelpText: 'The entered value needs to be a number.',
+      isNumberType: true,
+      allowsNegative: true
+    },
+    {
+      name: 'size',
+      inputType: 'number',
+      humanReadable: 'Unsigned integer value (>=16bit)',
+      defaultMin: 0,
+      patternHelpText: 'The entered value needs to be a unsigned number.',
+      isNumberType: true,
+      allowsNegative: false
+    },
+    {
+      name: 'secs',
+      inputType: 'number',
+      humanReadable: 'Number of seconds',
+      defaultMin: 1,
+      patternHelpText: 'The entered value needs to be a number >= 1.',
+      isNumberType: true,
+      allowsNegative: false
+    },
+    {
+      name: 'float',
+      inputType: 'number',
+      humanReadable: 'Double value',
+      patternHelpText: 'The entered value needs to be a number or decimal.',
+      isNumberType: true,
+      allowsNegative: true
+    },
+    { name: 'str', inputType: 'text', humanReadable: 'Text', isNumberType: false },
+    {
+      name: 'addr',
+      inputType: 'text',
+      humanReadable: 'IPv4 or IPv6 address',
+      patternHelpText: 'The entered value needs to be a valid IP address.',
+      isNumberType: false
+    },
+    {
+      name: 'uuid',
+      inputType: 'text',
+      humanReadable: 'UUID',
+      patternHelpText:
+        'The entered value is not a valid UUID, e.g.: 67dcac9f-2c03-4d6c-b7bd-1210b3a259a8',
+      isNumberType: false
+    },
+    { name: 'bool', inputType: 'checkbox', humanReadable: 'Boolean value', isNumberType: false }
+  ];
+
+  public static getType(type: string): any {
+    const currentType = _.find(this.knownTypes, (t) => {
+      return t.name === type;
+    });
+
+    if (currentType !== undefined) {
+      return currentType;
+    }
+
+    throw new Error('Found unknown type "' + type + '" for config option.');
+  }
+
+  public static getTypeValidators(configOption: ConfigFormModel): any {
+    const typeParams = ConfigOptionTypes.getType(configOption.type);
+
+    if (typeParams.name === 'bool' || typeParams.name === 'str') {
+      return;
+    }
+
+    const typeValidators = { validators: [], patternHelpText: typeParams.patternHelpText };
+
+    if (typeParams.isNumberType) {
+      if (configOption.max && configOption.max !== '') {
+        typeValidators['max'] = configOption.max;
+        typeValidators.validators.push(Validators.max(configOption.max));
+      }
+
+      if (configOption.min && configOption.min !== '') {
+        typeValidators['min'] = configOption.min;
+        typeValidators.validators.push(Validators.min(configOption.min));
+      } else if ('defaultMin' in typeParams) {
+        typeValidators['min'] = typeParams.defaultMin;
+        typeValidators.validators.push(Validators.min(typeParams.defaultMin));
+      }
+
+      if (configOption.type === 'float') {
+        typeValidators.validators.push(CdValidators.decimalNumber());
+      } else {
+        typeValidators.validators.push(CdValidators.number(typeParams.allowsNegative));
+      }
+    } else if (configOption.type === 'addr') {
+      typeValidators.validators = [CdValidators.ip()];
+    } else if (configOption.type === 'uuid') {
+      typeValidators.validators = [CdValidators.uuid()];
+    }
+
+    return typeValidators;
+  }
+}
index d6c8808f42c9ee3352a2aae9cafda92bc11042bc..021d07415851bf9952418b0601481e5b86a8713a 100644 (file)
           <context context-type="linenumber">1</context>
         </context-group>
       </trans-unit>
-      <trans-unit id="a69f9ab917ee06c8e595d0809a27c0a934672550" datatype="html">
-        <source>Positive integer value</source>
-        <context-group purpose="location">
-          <context context-type="sourcefile">src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts</context>
-          <context context-type="linenumber">1</context>
-        </context-group>
-      </trans-unit>
-      <trans-unit id="138a48a2e66e2893105099731fcb5b9d876a9b15" datatype="html">
-        <source>The entered value needs to be a positive number.</source>
-        <context-group purpose="location">
-          <context context-type="sourcefile">src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts</context>
-          <context context-type="linenumber">1</context>
-        </context-group>
-        <context-group purpose="location">
-          <context context-type="sourcefile">src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts</context>
-          <context context-type="linenumber">1</context>
-        </context-group>
-        <context-group purpose="location">
-          <context context-type="sourcefile">src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts</context>
-          <context context-type="linenumber">1</context>
-        </context-group>
-      </trans-unit>
-      <trans-unit id="d2cd389d621b06af850ac34ef328adbdc4875f3d" datatype="html">
-        <source>Integer value</source>
-        <context-group purpose="location">
-          <context context-type="sourcefile">src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts</context>
-          <context context-type="linenumber">1</context>
-        </context-group>
-      </trans-unit>
-      <trans-unit id="eae7086660cf1e38c7194a2c49ff52cc656f90f5" datatype="html">
-        <source>The entered value needs to be a number.</source>
-        <context-group purpose="location">
-          <context context-type="sourcefile">src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts</context>
-          <context context-type="linenumber">1</context>
-        </context-group>
-      </trans-unit>
-      <trans-unit id="95eec2fcc0e9a0ec2f05e0b255503d6624afe210" datatype="html">
-        <source>Positive integer value (size)</source>
-        <context-group purpose="location">
-          <context context-type="sourcefile">src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts</context>
-          <context context-type="linenumber">1</context>
-        </context-group>
-      </trans-unit>
-      <trans-unit id="c2ad0013d170aef399c688944f7456cfcb3eb32b" datatype="html">
-        <source>Positive integer value (secs)</source>
-        <context-group purpose="location">
-          <context context-type="sourcefile">src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts</context>
-          <context context-type="linenumber">1</context>
-        </context-group>
-      </trans-unit>
-      <trans-unit id="09be1ce38e2c81f3b8be2e904791fb253de3b0fe" datatype="html">
-        <source>Decimal value</source>
-        <context-group purpose="location">
-          <context context-type="sourcefile">src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts</context>
-          <context context-type="linenumber">1</context>
-        </context-group>
-      </trans-unit>
-      <trans-unit id="a73376e04b4fb3a20734c8c39743fba32e6676ce" datatype="html">
-        <source>The entered value needs to be a number or decimal.</source>
-        <context-group purpose="location">
-          <context context-type="sourcefile">src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts</context>
-          <context context-type="linenumber">1</context>
-        </context-group>
-      </trans-unit>
-      <trans-unit id="8ba143716c2da6e4120c0c1a804f0bdd9a7e5f5b" datatype="html">
-        <source>Text</source>
-        <context-group purpose="location">
-          <context context-type="sourcefile">src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts</context>
-          <context context-type="linenumber">1</context>
-        </context-group>
-      </trans-unit>
-      <trans-unit id="e8553bdeeab82f1bd176a59b97677516726a5a94" datatype="html">
-        <source>IPv4 or IPv6 address</source>
-        <context-group purpose="location">
-          <context context-type="sourcefile">src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts</context>
-          <context context-type="linenumber">1</context>
-        </context-group>
-      </trans-unit>
-      <trans-unit id="7aacd038b39cfd347107d01d1dc27f5cb3e0951c" datatype="html">
-        <source>The entered value needs to be a valid IP address.</source>
-        <context-group purpose="location">
-          <context context-type="sourcefile">src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts</context>
-          <context context-type="linenumber">1</context>
-        </context-group>
-      </trans-unit>
-      <trans-unit id="8c87d9527af7ff2ada84c911516a9e43a352e401" datatype="html">
-        <source>UUID</source>
-        <context-group purpose="location">
-          <context context-type="sourcefile">src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts</context>
-          <context context-type="linenumber">1</context>
-        </context-group>
-      </trans-unit>
-      <trans-unit id="46e09b8290d3d0afdb6baa2021395b0570606a31" datatype="html">
-        <source>The entered value is not a valid UUID, e.g.: 67dcac9f-2c03-4d6c-b7bd-1210b3a259a8</source>
-        <context-group purpose="location">
-          <context context-type="sourcefile">src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts</context>
-          <context context-type="linenumber">1</context>
-        </context-group>
-      </trans-unit>
-      <trans-unit id="e079c654595070cfd27aae68a2f4f22b2a43e4cb" datatype="html">
-        <source>Boolean value</source>
-        <context-group purpose="location">
-          <context context-type="sourcefile">src/app/ceph/cluster/configuration/configuration-form/configuration-form.component.ts</context>
-          <context context-type="linenumber">1</context>
-        </context-group>
-      </trans-unit>
       <trans-unit id="cdb623df78c6ed1fdd9e6dc35f83d6dbea75ebfa" datatype="html">
         <source>Config option <x id="INTERPOLATION" equiv-text="{{name}}"/> has been updated.</source>
         <context-group purpose="location">