From 4e4ec8e9c21acf7f9210aaebf8f13a60542737fc Mon Sep 17 00:00:00 2001 From: franciscovila Date: Thu, 30 Jun 2022 16:06:54 +0100 Subject: Allow set values in properties of type timestamp Issue-ID: SDC-4080 Signed-off-by: franciscovila Change-Id: I4c03e660e64118a388beb1d0db3527f9a1427c3f --- .../app/models/properties-inputs/property-fe-model.ts | 1 + .../dynamic-property/dynamic-property.component.ts | 2 +- .../ui/dynamic-element/dynamic-element.component.ts | 17 ++++++++++++++--- catalog-ui/src/app/utils/constants.ts | 5 +++-- 4 files changed, 19 insertions(+), 6 deletions(-) (limited to 'catalog-ui') diff --git a/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts b/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts index d4b45408ca..f231ec8aa8 100644 --- a/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts +++ b/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts @@ -284,6 +284,7 @@ export class PropertyFEModel extends PropertyBEModel { valueObj = value || defaultValue || null; // use null for empty value object if (valueObj && propertyType !== PROPERTY_TYPES.STRING && + propertyType !== PROPERTY_TYPES.TIMESTAMP && propertyType !== PROPERTY_TYPES.JSON && PROPERTY_DATA.SCALAR_TYPES.indexOf(propertyType) == -1) { valueObj = JSON.parse(value); // the value object contains the real value ans not the value as string diff --git a/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts b/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts index 865aea6598..6107e8ad50 100644 --- a/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts +++ b/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts @@ -81,7 +81,7 @@ export class DynamicPropertyComponent { } initConsraintsValues(){ - let primitiveProperties = ['string', 'integer', 'float', 'boolean']; + let primitiveProperties = ['string', 'integer', 'float', 'boolean', PROPERTY_TYPES.TIMESTAMP]; //Property has constraints if(this.property.constraints && this.property.constraints[0]){ diff --git a/catalog-ui/src/app/ng2/components/ui/dynamic-element/dynamic-element.component.ts b/catalog-ui/src/app/ng2/components/ui/dynamic-element/dynamic-element.component.ts index 5e3214d888..50c77d3f53 100644 --- a/catalog-ui/src/app/ng2/components/ui/dynamic-element/dynamic-element.component.ts +++ b/catalog-ui/src/app/ng2/components/ui/dynamic-element/dynamic-element.component.ts @@ -28,7 +28,7 @@ import {UiElementInputComponent} from "../form-components/input/ui-element-input import {UiElementPopoverInputComponent} from "../form-components/popover-input/ui-element-popover-input.component"; import {UiElementIntegerInputComponent} from "../form-components/integer-input/ui-element-integer-input.component"; import {UiElementDropDownComponent, DropdownValue} from "../form-components/dropdown/ui-element-dropdown.component"; -import {PROPERTY_DATA} from "../../../../utils/constants"; +import {PROPERTY_DATA, PROPERTY_TYPES} from "../../../../utils/constants"; enum DynamicElementComponentCreatorIdentifier { STRING, @@ -38,7 +38,8 @@ enum DynamicElementComponentCreatorIdentifier { SUBNETPOOLID, ENUM, LIST, - DEFAULT + DEFAULT, + TIMESTAMP } @Component({ @@ -107,6 +108,9 @@ export class DynamicElementComponent { case this.type === 'string': this.elementCreatorIdentifier = DynamicElementComponentCreatorIdentifier.STRING; break; + case this.type === PROPERTY_TYPES.TIMESTAMP: + this.elementCreatorIdentifier = DynamicElementComponentCreatorIdentifier.TIMESTAMP; + break; case this.type === 'boolean': this.elementCreatorIdentifier = DynamicElementComponentCreatorIdentifier.BOOLEAN; break; @@ -146,6 +150,9 @@ export class DynamicElementComponent { case 'string': this.elementCreatorIdentifier = DynamicElementComponentCreatorIdentifier.STRING; break; + case PROPERTY_TYPES.TIMESTAMP: + this.elementCreatorIdentifier = DynamicElementComponentCreatorIdentifier.TIMESTAMP; + break; case 'boolean': this.elementCreatorIdentifier = DynamicElementComponentCreatorIdentifier.BOOLEAN; break; @@ -190,6 +197,10 @@ export class DynamicElementComponent { this.createComponent(UiElementInputComponent); break; + case DynamicElementComponentCreatorIdentifier.TIMESTAMP: + this.createComponent(UiElementInputComponent); + break; + case DynamicElementComponentCreatorIdentifier.BOOLEAN: this.createComponent(UiElementDropDownComponent); @@ -210,7 +221,7 @@ export class DynamicElementComponent { case DynamicElementComponentCreatorIdentifier.DEFAULT: default: this.createComponent(UiElementInputComponent); - console.log("ERROR: No ui-models component to handle type: " + this.type); + console.error("ERROR: No ui-models component to handle type: " + this.type); } // } // //There are consraints diff --git a/catalog-ui/src/app/utils/constants.ts b/catalog-ui/src/app/utils/constants.ts index af5c23c764..4e268f7087 100644 --- a/catalog-ui/src/app/utils/constants.ts +++ b/catalog-ui/src/app/utils/constants.ts @@ -133,6 +133,7 @@ export class SEVERITY { export class PROPERTY_TYPES { public static STRING = 'string'; public static INTEGER = 'integer'; + public static TIMESTAMP = 'timestamp'; public static FLOAT = 'float'; public static BOOLEAN = 'boolean'; public static JSON = 'json'; @@ -151,8 +152,8 @@ export class SOURCES { } export class PROPERTY_DATA { - public static TYPES = [PROPERTY_TYPES.STRING, PROPERTY_TYPES.INTEGER, PROPERTY_TYPES.FLOAT, PROPERTY_TYPES.BOOLEAN, PROPERTY_TYPES.JSON, PROPERTY_TYPES.SCALAR, PROPERTY_TYPES.SCALAR_FREQUENCY, PROPERTY_TYPES.SCALAR_SIZE, PROPERTY_TYPES.SCALAR_TIME, PROPERTY_TYPES.LIST, PROPERTY_TYPES.MAP]; - public static SIMPLE_TYPES = [PROPERTY_TYPES.STRING, PROPERTY_TYPES.INTEGER, PROPERTY_TYPES.FLOAT, PROPERTY_TYPES.BOOLEAN, PROPERTY_TYPES.JSON, PROPERTY_TYPES.SCALAR, PROPERTY_TYPES.SCALAR_FREQUENCY, PROPERTY_TYPES.SCALAR_SIZE, PROPERTY_TYPES.SCALAR_TIME]; + public static TYPES = [PROPERTY_TYPES.STRING, PROPERTY_TYPES.INTEGER, PROPERTY_TYPES.TIMESTAMP, PROPERTY_TYPES.FLOAT, PROPERTY_TYPES.BOOLEAN, PROPERTY_TYPES.JSON, PROPERTY_TYPES.SCALAR, PROPERTY_TYPES.SCALAR_FREQUENCY, PROPERTY_TYPES.SCALAR_SIZE, PROPERTY_TYPES.SCALAR_TIME, PROPERTY_TYPES.LIST, PROPERTY_TYPES.MAP]; + public static SIMPLE_TYPES = [PROPERTY_TYPES.STRING, PROPERTY_TYPES.INTEGER, PROPERTY_TYPES.TIMESTAMP, PROPERTY_TYPES.FLOAT, PROPERTY_TYPES.BOOLEAN, PROPERTY_TYPES.JSON, PROPERTY_TYPES.SCALAR, PROPERTY_TYPES.SCALAR_FREQUENCY, PROPERTY_TYPES.SCALAR_SIZE, PROPERTY_TYPES.SCALAR_TIME]; public static SIMPLE_TYPES_COMPARABLE = [PROPERTY_TYPES.STRING, PROPERTY_TYPES.INTEGER, PROPERTY_TYPES.FLOAT]; public static SCALAR_TYPES = [PROPERTY_TYPES.SCALAR, PROPERTY_TYPES.SCALAR_FREQUENCY, PROPERTY_TYPES.SCALAR_SIZE, PROPERTY_TYPES.SCALAR_TIME]; public static ROOT_DATA_TYPE = "tosca.datatypes.Root"; -- cgit 1.2.3-korg