aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app
diff options
context:
space:
mode:
authorsiddharth0905 <siddharth.singh4@amdocs.com>2019-04-10 17:49:51 +0530
committerAvi Gaffa <avi.gaffa@amdocs.com>2019-04-11 07:11:04 +0000
commit6896c1b309aaa50dca820169b9f1ae3f8af84294 (patch)
tree8da13382863f2e4adc9724dd046b535032ae58c7 /catalog-ui/src/app
parent4568e48647b15b5654a669651ddf536d590288b0 (diff)
Apply Valid Value Constraints validation
Apply Valid Value Constraints validation for FE and BE in Property Assignment, Input, Service Consumption screen Change-Id: I01c7523bad702f003cd52fd88bc69fe950b2b4f3 Issue-ID: SDC-2224 Signed-off-by: siddharth0905 <siddharth.singh4@amdocs.com>
Diffstat (limited to 'catalog-ui/src/app')
-rw-r--r--catalog-ui/src/app/models/properties-inputs/property-be-model.ts9
-rw-r--r--catalog-ui/src/app/models/properties.ts3
-rw-r--r--catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.html1
-rw-r--r--catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html1
-rw-r--r--catalog-ui/src/app/ng2/components/logic/service-consumption/service-consumption.component.ts2
-rw-r--r--catalog-ui/src/app/ng2/components/ui/dynamic-element/dynamic-element.component.ts28
-rw-r--r--catalog-ui/src/app/ng2/pages/interface-operation/interface-operation.page.component.ts2
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts7
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/property-creator/property-creator.component.ts3
-rw-r--r--catalog-ui/src/app/ng2/pages/service-consumption-editor/service-consumption-editor.component.html1
-rw-r--r--catalog-ui/src/app/ng2/services/component-services/component.service.ts4
11 files changed, 51 insertions, 10 deletions
diff --git a/catalog-ui/src/app/models/properties-inputs/property-be-model.ts b/catalog-ui/src/app/models/properties-inputs/property-be-model.ts
index aa68551950..a1a85aa73d 100644
--- a/catalog-ui/src/app/models/properties-inputs/property-be-model.ts
+++ b/catalog-ui/src/app/models/properties-inputs/property-be-model.ts
@@ -28,12 +28,12 @@ export enum DerivedPropertyType {
}
export class PropertyBEModel {
-
+ constraints: Array<any>;
defaultValue: string;
definition: boolean;
description: string;
fromDerived: boolean;
- getInputValues: Array<PropertyInputDetail>
+ getInputValues: Array<PropertyInputDetail>;
name: string;
parentUniqueId: string;
password: boolean;
@@ -43,9 +43,12 @@ export class PropertyBEModel {
type: string;
uniqueId: string;
value: string;
+ parentPropertyType: string;
+ subPropertyInputPath: string;
constructor(property?: PropertyBEModel) {
if (property) {
+ this.constraints = property.constraints;
this.defaultValue = property.defaultValue;
this.description = property.description;
this.fromDerived = property.fromDerived;
@@ -60,6 +63,8 @@ export class PropertyBEModel {
this.value = property.value;
this.definition = property.definition;
this.getInputValues = property.getInputValues;
+ this.parentPropertyType = property.parentPropertyType;
+ this.subPropertyInputPath = property.subPropertyInputPath;
}
if (!this.schema || !this.schema.property) {
diff --git a/catalog-ui/src/app/models/properties.ts b/catalog-ui/src/app/models/properties.ts
index a629140cb8..016c5b9f20 100644
--- a/catalog-ui/src/app/models/properties.ts
+++ b/catalog-ui/src/app/models/properties.ts
@@ -40,7 +40,6 @@ export class PropertiesGroup {
export interface IPropertyModel extends InputPropertyBase {
//server data
- constraints:Array<Object>;
source:string;
//instance properties
@@ -60,7 +59,6 @@ export class PropertyModel extends PropertyBEModel implements IPropertyModel {
//server data
uniqueId:string;
name:string;
- constraints:Array<Object>;
defaultValue:string;
description:string;
password:boolean;
@@ -93,7 +91,6 @@ export class PropertyModel extends PropertyBEModel implements IPropertyModel {
constructor(property?:PropertyModel) {
super(property);
if (property) {
- this.constraints = property.constraints;
this.source = property.source;
this.valueUniqueUid = property.valueUniqueUid;
this.path = property.path;
diff --git a/catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.html b/catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.html
index 65873a35a5..3ef1f57bf2 100644
--- a/catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.html
+++ b/catalog-ui/src/app/ng2/components/logic/inputs-table/inputs-table.component.html
@@ -57,6 +57,7 @@
pattern="validationUtils.getValidationPattern(input.type)"
[value]="input.defaultValueObj"
[type]="input.type"
+ [constraints]="input.constraints"
[name]="input.name"
(elementChanged)="onInputChanged(input, $event)"
[readonly]="readonly"
diff --git a/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html b/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html
index 3f87b070e8..c4639aeda0 100644
--- a/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html
+++ b/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html
@@ -51,6 +51,7 @@
[childType]="property.schema.property.type"
[name]="property.name"
[path]="property.propertiesName"
+ [constraints]="property.constraints"
(elementChanged)="onElementChanged($event)"
[readonly]="readonly || property.isDeclared || property.isDisabled"
[testId]="'prop-' + propertyTestsId"
diff --git a/catalog-ui/src/app/ng2/components/logic/service-consumption/service-consumption.component.ts b/catalog-ui/src/app/ng2/components/logic/service-consumption/service-consumption.component.ts
index b0f6dfb649..ef8d63df97 100644
--- a/catalog-ui/src/app/ng2/components/logic/service-consumption/service-consumption.component.ts
+++ b/catalog-ui/src/app/ng2/components/logic/service-consumption/service-consumption.component.ts
@@ -39,6 +39,7 @@ export class ConsumptionInput extends PropertyFEModel{
type: string;
source: string;
value: any;
+ constraints: Array<any>;
constructor(input?: any) {
super(input);
@@ -47,6 +48,7 @@ export class ConsumptionInput extends PropertyFEModel{
this.type = input.type;
this.source = input.source;
this.value = input.value || "";
+ this.constraints = input.constraints;
}
}
}
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 4f283fb3f1..049d40831a 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
@@ -22,7 +22,7 @@
import * as _ from "lodash";
import { Component, Compiler, EventEmitter, ViewContainerRef, ViewChild, Input, Output, ElementRef, ComponentRef, ComponentFactoryResolver } from '@angular/core'
-import {ValidationConfiguration} from "app/models";
+import {ValidationConfiguration, PropertyFEModel} from "app/models";
import {IUiElementChangeEvent} from "../form-components/ui-element-base.component";
import {UiElementInputComponent} from "../form-components/input/ui-element-input.component";
import {UiElementPopoverInputComponent} from "../form-components/popover-input/ui-element-popover-input.component";
@@ -36,6 +36,7 @@ enum DynamicElementComponentCreatorIdentifier {
FLOAT,
BOOLEAN,
SUBNETPOOLID,
+ ENUM,
DEFAULT
}
@@ -58,6 +59,7 @@ export class DynamicElementComponent {
@Input() name: string;
@Input() testId: string;
@Input() readonly:boolean;
+ @Input() constraints: Array<any>;
@Input() path:string;//optional param. used only for for subnetpoolid type
@Input() value: any;
@@ -86,6 +88,9 @@ export class DynamicElementComponent {
case this.path && this.path.toUpperCase().indexOf("SUBNETPOOLID") !== -1:
this.elementCreatorIdentifier = DynamicElementComponentCreatorIdentifier.SUBNETPOOLID;
break;
+ case this.getValidValues() !== undefined && this.getValidValues() !== null:
+ this.elementCreatorIdentifier = DynamicElementComponentCreatorIdentifier.ENUM;
+ break;
case this.type === 'integer':
this.elementCreatorIdentifier = DynamicElementComponentCreatorIdentifier.INTEGER;
break;
@@ -153,6 +158,19 @@ export class DynamicElementComponent {
this.createComponent(UiElementPopoverInputComponent);
break;
+ case DynamicElementComponentCreatorIdentifier.ENUM:
+ this.createComponent(UiElementDropDownComponent);
+ let validVals:Array<DropdownValue> = [...this.getValidValues()].map(val => new DropdownValue(val, val));
+ if (this.type === 'float' || this.type === 'integer') {
+ this.value = this.value && Number(this.value);
+ validVals = _.map(
+ validVals,
+ val => new DropdownValue(Number(val.value), val.value)
+ );
+ }
+ this.cmpRef.instance.values = validVals;
+ break;
+
case DynamicElementComponentCreatorIdentifier.INTEGER:
this.createComponent(UiElementIntegerInputComponent);
this.cmpRef.instance.pattern = this.validation.validationPatterns.integer;
@@ -195,6 +213,14 @@ export class DynamicElementComponent {
this.cmpRef.instance.valueChange.subscribe((event) => { this.valueChange.emit(event); });
}
+ getValidValues(): Array<string> {
+ let validVals;
+ _.forEach(this.constraints, constraint => {
+ validVals = validVals || constraint.validValues;
+ });
+ return validVals;
+ }
+
createComponent(ComponentToCreate:any):void {
let factory = this.componentFactoryResolver.resolveComponentFactory(ComponentToCreate);
this.cmpRef = this.target.createComponent(factory);
diff --git a/catalog-ui/src/app/ng2/pages/interface-operation/interface-operation.page.component.ts b/catalog-ui/src/app/ng2/pages/interface-operation/interface-operation.page.component.ts
index 9035b3ff50..97c7b4d959 100644
--- a/catalog-ui/src/app/ng2/pages/interface-operation/interface-operation.page.component.ts
+++ b/catalog-ui/src/app/ng2/pages/interface-operation/interface-operation.page.component.ts
@@ -136,7 +136,7 @@ export class InterfaceOperationComponent {
ngOnInit(): void {
this.isLoading = true;
- this.workflowIsOnline = !_.isUndefined(this.PluginsService.getPluginByStateUrl('workflowDesigner'));
+ this.workflowIsOnline = false;//!_.isUndefined(this.PluginsService.getPluginByStateUrl('workflowDesigner'));
const workflowSubscription = this.enableWorkflowAssociation && this.workflowIsOnline ? this.WorkflowServiceNg2.getWorkflows() : Promise.resolve();
Observable.forkJoin(
this.ComponentServiceNg2.getInterfaces(this.component),
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts
index 953c973d1a..615325559e 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts
@@ -126,7 +126,7 @@ export class PropertiesAssignmentComponent {
this.loadingInstances = true;
this.loadingProperties = true;
this.componentServiceNg2
- .getComponentInputs(this.component)
+ .getComponentInputsWithProperties(this.component)
.subscribe(response => {
_.forEach(response.inputs, (input: InputBEModel) => {
const newInput: InputFEModel = new InputFEModel(input);
@@ -468,7 +468,10 @@ export class PropertiesAssignmentComponent {
};
} else {
if (this.isSelf()) {
- request = this.componentServiceNg2.updateServiceProperties(this.component, changedProperties);
+ request = this.componentServiceNg2.updateServiceProperties(this.component, _.map(changedProperties, cp => {
+ delete cp.constraints;
+ return cp;
+ }));
} else {
request = this.componentInstanceServiceNg2
.updateInstanceProperties(this.component, this.selectedInstanceData.uniqueId, changedProperties);
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/property-creator/property-creator.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/property-creator/property-creator.component.ts
index d5946d2e4a..7d76904539 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/property-creator/property-creator.component.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/property-creator/property-creator.component.ts
@@ -46,7 +46,8 @@ export class PropertyCreatorComponent {
let nonPrimitiveTypesValues = _.map(nonPrimitiveTypes,
(type: string) => new DropdownValue(type,
type.replace("org.openecomp.datatypes.heat.",""))
- );
+ )
+ .sort((a, b) => a.label.localeCompare(b.label));
this.typesProperties = _.concat(this.typesProperties,nonPrimitiveTypesValues);
this.typesSchemaProperties = _.concat(typesSimpleProperties,nonPrimitiveTypesValues);
this.typesProperties.unshift(new DropdownValue('','Select Type...'));
diff --git a/catalog-ui/src/app/ng2/pages/service-consumption-editor/service-consumption-editor.component.html b/catalog-ui/src/app/ng2/pages/service-consumption-editor/service-consumption-editor.component.html
index 5d42fa7694..e77d880176 100644
--- a/catalog-ui/src/app/ng2/pages/service-consumption-editor/service-consumption-editor.component.html
+++ b/catalog-ui/src/app/ng2/pages/service-consumption-editor/service-consumption-editor.component.html
@@ -52,6 +52,7 @@
*ngIf="consumptionInput.isSimpleType && (consumptionInput.source === SOURCE_TYPES.STATIC || consumptionInput.source === '')"
data-tests-id="inputValue"
[(value)]="consumptionInput.value"
+ [constraints]="consumptionInput.constraints"
(elementChanged)="onChange($event.value, $event.isValid, consumptionInput)"
[type]="consumptionInput.type">
</dynamic-element>
diff --git a/catalog-ui/src/app/ng2/services/component-services/component.service.ts b/catalog-ui/src/app/ng2/services/component-services/component.service.ts
index a25fb75a41..3243291483 100644
--- a/catalog-ui/src/app/ng2/services/component-services/component.service.ts
+++ b/catalog-ui/src/app/ng2/services/component-services/component.service.ts
@@ -108,6 +108,10 @@ export class ComponentServiceNg2 {
return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_INPUTS]);
}
+ getComponentInputsWithProperties(component:Component):Observable<ComponentGenericResponse> {
+ return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_INPUTS, COMPONENT_FIELDS.COMPONENT_INSTANCES, COMPONENT_FIELDS.COMPONENT_INSTANCES_PROPERTIES, COMPONENT_FIELDS.COMPONENT_PROPERTIES]);
+ }
+
getComponentDeploymentArtifacts(component:Component):Observable<ComponentGenericResponse> {
return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_DEPLOYMENT_ARTIFACTS]);
}