aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/pages
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/ng2/pages')
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts2
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.html1
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts17
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts8
-rw-r--r--catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.html96
-rw-r--r--catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts244
6 files changed, 325 insertions, 43 deletions
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts
index 8dd4ca96ec..6a27622638 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts
@@ -181,6 +181,8 @@ export class PropertiesUtils {
property.childPropUpdated(childProp);
});
+ } else if (property.derivedDataType === DerivedPropertyType.RANGE) {
+ property.valueObj = JSON.stringify(property.getValueObj());
}
}
property.updateValueObjOrig();
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.html b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.html
index 898b189746..65a024cde4 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.html
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.html
@@ -43,6 +43,7 @@
</div>
<div *ngIf="isGetFunctionSelected()">
<app-tosca-get-function [property]="property" [toscaGetFunction]="toscaFunction"
+ [overridingType] = "overridingType"
[componentInstanceMap]="componentInstanceMap"
[functionType]="toscaFunctionTypeForm.value"
[compositionMap]="compositionMap"
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts
index 81696944c7..ecaff252d3 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts
@@ -30,7 +30,7 @@ import {ToscaGetFunctionValidationEvent} from "./tosca-get-function/tosca-get-fu
import {ToscaFunction} from "../../../../models/tosca-function";
import {ToscaConcatFunctionValidationEvent} from "./tosca-concat-function/tosca-concat-function.component";
import {ToscaCustomFunctionValidationEvent} from "./tosca-custom-function/tosca-custom-function.component";
-import {PROPERTY_TYPES, PROPERTY_DATA} from "../../../../utils/constants";
+import {PROPERTY_TYPES} from "../../../../utils/constants";
import {YamlFunctionValidationEvent} from "./yaml-function/yaml-function.component";
import {ToscaConcatFunction} from "../../../../models/tosca-concat-function";
import {ToscaCustomFunction} from "../../../../models/tosca-custom-function";
@@ -45,6 +45,8 @@ import {CustomToscaFunction} from "../../../../models/default-custom-functions";
export class ToscaFunctionComponent implements OnInit, OnChanges {
@Input() property: PropertyBEModel;
+ @Input() overridingType: PROPERTY_TYPES;
+ @Input() inToscaFunction: ToscaFunction;
@Input() componentInstanceMap: Map<string, InstanceFeDetails> = new Map<string, InstanceFeDetails>();
@Input() customToscaFunctions: Array<CustomToscaFunction> = [];
@Input() allowClear: boolean = true;
@@ -74,7 +76,7 @@ export class ToscaFunctionComponent implements OnInit, OnChanges {
ngOnInit(): void {
this.componentMetadata = this.workspaceService.metadata;
- this.toscaFunction = this.property.toscaFunction ? this.property.toscaFunction : undefined;
+ this.toscaFunction = this.inToscaFunction ? this.inToscaFunction : this.property.toscaFunction ? this.property.toscaFunction : undefined;
this.loadToscaFunctions();
this.formGroup.valueChanges.subscribe(() => {
if (!this.isInitialized) {
@@ -93,7 +95,7 @@ export class ToscaFunctionComponent implements OnInit, OnChanges {
ngOnChanges(changes: SimpleChanges): void {
if (changes.property) {
this.resetForm();
- this.toscaFunction = this.property.toscaFunction ? this.property.toscaFunction : undefined;
+ this.toscaFunction = this.inToscaFunction ? this.inToscaFunction : this.property.toscaFunction ? this.property.toscaFunction : undefined;
this.initToscaFunction();
this.loadToscaFunctions();
this.emitValidityChange();
@@ -130,11 +132,11 @@ export class ToscaFunctionComponent implements OnInit, OnChanges {
return;
}
}
-
if (!this.property.isToscaFunction()) {
return;
}
- this.toscaFunctionForm.setValue(this.property.toscaFunction);
+
+ this.toscaFunctionForm.setValue(this.inToscaFunction ? this.inToscaFunction : this.property.toscaFunction);
let type = this.property.toscaFunction.type;
if (type == ToscaFunctionType.CUSTOM) {
let name = (this.property.toscaFunction as ToscaCustomFunction).name;
@@ -145,7 +147,7 @@ export class ToscaFunctionComponent implements OnInit, OnChanges {
this.toscaFunctionTypeForm.setValue("other");
}
} else {
- this.toscaFunctionTypeForm.setValue(type);
+ this.toscaFunctionTypeForm.setValue(this.inToscaFunction ? this.inToscaFunction.type : type);
}
}
@@ -159,6 +161,9 @@ export class ToscaFunctionComponent implements OnInit, OnChanges {
this.toscaFunctions.push(ToscaFunctionType.GET_INPUT);
this.toscaFunctions.push(ToscaFunctionType.GET_PROPERTY);
if (this.property.type === PROPERTY_TYPES.STRING || this.property.type === PROPERTY_TYPES.ANY) {
+ this.toscaFunctions.push(ToscaFunctionType.CUSTOM);
+ }
+ if ((this.property.type === PROPERTY_TYPES.STRING || this.property.type === PROPERTY_TYPES.ANY) && this.overridingType === undefined) {
this.toscaFunctions.push(ToscaFunctionType.CONCAT);
}
this.loadCustomToscaFunctions();
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts
index fe6f2f143c..284c559c55 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts
@@ -42,6 +42,7 @@ import {ToscaGetFunctionTypeConverter} from "../../../../../models/tosca-get-fun
export class ToscaGetFunctionComponent implements OnInit, OnChanges {
@Input() property: PropertyBEModel;
+ @Input() overridingType: PROPERTY_TYPES;
@Input() toscaGetFunction: ToscaGetFunction;
@Input() componentInstanceMap: Map<string, InstanceFeDetails> = new Map<string, InstanceFeDetails>();
@Input() functionType: ToscaGetFunctionType;
@@ -243,13 +244,13 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
const properties: Array<PropertyBEModel | AttributeBEModel> = this.extractProperties(response);
if (!properties || properties.length === 0) {
const msgCode = this.getNotFoundMsgCode();
- this.dropDownErrorMsg = this.translateService.translate(msgCode, {type: this.propertyTypeToString()});
+ this.dropDownErrorMsg = this.translateService.translate(msgCode, {type: this.overridingType != undefined ? this.overridingType : this.propertyTypeToString()});
return;
}
this.addPropertiesToDropdown(properties);
if (this.propertyDropdownList.length == 0) {
const msgCode = this.getNotFoundMsgCode();
- this.dropDownErrorMsg = this.translateService.translate(msgCode, {type: this.propertyTypeToString()});
+ this.dropDownErrorMsg = this.translateService.translate(msgCode, {type: this.overridingType != undefined ? this.overridingType : this.propertyTypeToString()});
}
}, (error) => {
console.error('An error occurred while loading properties.', error);
@@ -403,6 +404,9 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
}
private hasSameType(property: PropertyBEModel | AttributeBEModel): boolean {
+ if (this.overridingType != undefined) {
+ return property.type === this.overridingType;
+ }
if (this.property.type === PROPERTY_TYPES.ANY) {
return true;
}
diff --git a/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.html b/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.html
index 8024eb1615..c90cfd8210 100644
--- a/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.html
+++ b/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.html
@@ -51,7 +51,10 @@
<label class="i-sdc-form-label required">{{"OPERATOR_LABEL" | translate}}</label>
<ui-element-dropdown class="i-sdc-form-select" data-tests-id="constraintOperator"
[testId]="'constraintOperator'"
- [values]="operatorTypes" [(value)]="currentRule.constraintOperator"></ui-element-dropdown>
+ (change)="onSourceTypeChange()"
+ [values]="operatorTypes" [(value)]="currentRule.constraintOperator"
+ >
+ </ui-element-dropdown>
</div>
</div>
<div class="rule-builder-content">
@@ -61,17 +64,28 @@
data-tests-id="value-type-static"
[(ngModel)]="selectedSourceType"
[value]="SOURCE_TYPES.STATIC.value"
- (ngModelChange)="onSourceTypeChange()"/> {{"VALUE_LABEL" | translate}}
+ (ngModelChange)="onSourceTypeChange($event)"/> {{"VALUE_LABEL" | translate}}
<input type="radio" name="sourceType"
data-tests-id="value-type-tosca-function"
[(ngModel)]="selectedSourceType"
- [value]="SOURCE_TYPES.TOSCA_FUNCTION.value"
- (ngModelChange)="onSourceTypeChange()"/> {{"VALUE_EXPRESSION_LABEL" | translate}}
+ [value]="isValidValuesOperator() || isRangeType() || isInRangeOperator() ? SOURCE_TYPES.TOSCA_FUNCTION_LIST.value: SOURCE_TYPES.TOSCA_FUNCTION.value"
+ (ngModelChange)="onSourceTypeChange($event)"/> {{"VALUE_EXPRESSION_LABEL" | translate}}
</div>
</div>
<div class="rule-builder-content" *ngIf="isToscaFunctionSource() && selectedProperty">
<div class="i-sdc-form-item rule-input-field">
<tosca-function [property]="selectedProperty"
+ [overridingType] = "isLengthOperator() ? overridingType : undefined"
+ [componentInstanceMap]="componentInstanceMap"
+ [allowClear]="false"
+ (onValidityChange)="onToscaFunctionValidityChange($event)"
+ >
+ </tosca-function>
+ </div>
+ </div>
+ <div class="rule-builder-content" *ngIf="isToscaFunctionSource() && selectedProperty && (isRangeType() || isInRangeOperator())">
+ <div class="i-sdc-form-item rule-input-field">
+ <tosca-function [property]="selectedProperty"
[componentInstanceMap]="componentInstanceMap"
[customToscaFunctions]="customToscaFunctions"
[allowClear]="false"
@@ -80,29 +94,97 @@
</tosca-function>
</div>
</div>
+
+ <div class="rule-builder-content" *ngIf="isToscaFunctionListSource() && selectedProperty && (isRangeType() || isInRangeOperator())">
+
+ <div class="i-sdc-form-item rule-input-field">
+ <div class="w-sdc-form-columns-wrapper" *ngFor="let val of rangeToscaFunctionList; let valueIndex = index; trackBy:trackByFn">
+ <div class="w-sdc-form-column" style="border-width:3px; border-style:solid; border-color:#009fdb; padding: 1em;">
+ <tosca-function [property]="selectedProperty"
+ [inToscaFunction]="val"
+ [componentInstanceMap]="componentInstanceMap"
+ [allowClear]="false"
+ (onValidityChange)="onToscaRangeFunctionListValidityChange($event, valueIndex)"
+ >
+ </tosca-function>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="rule-builder-content" *ngIf="isToscaFunctionListSource() && selectedProperty && isValidValuesOperator()">
+
+ <div class="i-sdc-form-item rule-input-field">
+ <div class="add-btn"
+ (click)="addToList()">Add to List
+ </div>
+ <div class="w-sdc-form-columns-wrapper" *ngFor="let val of this.validValuesToscaFunctionList; let valueIndex = index; trackBy:trackByFn">
+ <div class="w-sdc-form-column" style="border-width:3px; border-style:solid; border-color:#009fdb; padding: 1em;">
+ <tosca-function [property]="selectedProperty"
+ [inToscaFunction]="val"
+ [componentInstanceMap]="componentInstanceMap"
+ [allowClear]="false"
+ (onValidityChange)="onToscaFunctionListValidityChange($event, valueIndex)"
+ >
+ </tosca-function>
+ </div>
+ <div class="w-sdc-form-column">
+ <span class="sprite-new delete-btn" (click)="removeFromList(valueIndex)"></span>
+ </div>
+ </div>
+ </div>
+ </div>
<div *ngIf="isToscaFunctionSource() && !selectedProperty">
{{"NODE_FILTER_SELECT_PROPERTY" | translate}}
</div>
<div class="rule-builder-content" *ngIf="isStaticSource()">
<div class="i-sdc-form-item rule-input-field complex-input-field">
<dynamic-property
- *ngIf="isComplexListMapType()"
+ *ngIf="isComplexListMapType() && !isRangeType() && !isValidValuesOperator() && !isLengthOperator()"
[selectedPropertyId]="selectedProperty.uniqueId"
[property]="selectedProperty"
[expandedChildId]="selectedProperty.expandedChildPropertyId ?
selectedProperty.expandedChildPropertyId : selectedProperty.name"
[canBeDeclared]="true"
+ [hideCheckBox]="true"
(propertyChanged)="updateComplexListMapTypeRuleValue()"
[rootProperty]="selectedProperty"
(expandChild)="selectedProperty.updateExpandedChildPropertyId($event)">
</dynamic-property>
<dynamic-element
- *ngIf="!isComplexListMapType()"
+ *ngIf="!isComplexListMapType() && !isValidValuesOperator()"
[(value)]="currentRule.value"
class="rule-assigned-value"
data-tests-id="ruleAssignedValue"
(elementChanged)="onValueChange($event.isValid)"
- [type]="selectedProperty ? selectedProperty.type : 'string'">
+ [type]="isLengthOperator() ? 'integer' : selectedProperty ? selectedProperty.type : 'string'"
+ [operator]="currentRule.constraintOperator">
+ </dynamic-element>
+ <dynamic-element
+ *ngIf="isComplexListMapType() && isLengthOperator()"
+ [(value)]="currentRule.value"
+ class="rule-assigned-value"
+ data-tests-id="ruleAssignedValue"
+ (elementChanged)="onValueChange($event.isValid)"
+ [type]="isLengthOperator() ? 'integer' : selectedProperty ? selectedProperty.type : 'string'"
+ [operator]="currentRule.constraintOperator">
+ </dynamic-element>
+ <dynamic-element
+ *ngIf="isRangeType()"
+ [(value)]="currentRule.value"
+ class="rule-assigned-value"
+ data-tests-id="ruleAssignedValue"
+ (elementChanged)="onValueChange($event.isValid)"
+ [type]="selectedProperty ? selectedProperty.type : 'string'">
+ </dynamic-element>
+ <dynamic-element
+ *ngIf="isValidValuesOperator()"
+ [(value)]="currentRule.value"
+ class="rule-assigned-value"
+ data-tests-id="ruleAssignedValue"
+ (elementChanged)="onValueChange($event.isValid)"
+ [type]="selectedProperty ? selectedProperty.type : 'string'"
+ [operator]="currentRule.constraintOperator">
</dynamic-element>
</div>
</div>
diff --git a/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts b/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts
index 39609a5fbd..5897f272b3 100644
--- a/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts
+++ b/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts
@@ -19,7 +19,7 @@ import {InputBEModel, PropertyBEModel, PropertyFEModel, PropertyModel} from 'app
import {SourceType} from 'app/ng2/components/logic/service-dependencies/service-dependencies.component';
import {DropdownValue} from 'app/ng2/components/ui/form-components/dropdown/ui-element-dropdown.component';
import {ServiceServiceNg2} from 'app/ng2/services/component-services/service.service';
-import {PROPERTY_DATA} from 'app/utils';
+import {PROPERTY_DATA, PROPERTY_TYPES} from 'app/utils';
import {PropertiesUtils} from '../properties-assignment/services/properties.utils';
import {ToscaFunctionValidationEvent} from "../properties-assignment/tosca-function/tosca-function.component";
import {InstanceFeDetails} from "../../../models/instance-fe-details";
@@ -30,7 +30,7 @@ import {ConstraintOperatorType, FilterConstraintHelper} from "../../../utils/fil
import {ToscaFunctionHelper} from "../../../utils/tosca-function-helper";
import {TopologyTemplateService} from "app/ng2/services/component-services/topology-template.service";
import {CustomToscaFunction} from "../../../models/default-custom-functions";
-import {ToscaFunctionType} from "../../../models/tosca-function-type.enum";
+import {ToscaFunction} from "../../../models/tosca-function";
@Component({
selector: 'service-dependencies-editor',
@@ -52,8 +52,23 @@ export class ServiceDependenciesEditorComponent implements OnInit {
ConstraintOperatorType.LESS_THAN,
ConstraintOperatorType.EQUAL,
ConstraintOperatorType.GREATER_OR_EQUAL,
- ConstraintOperatorType.LESS_OR_EQUAL
+ ConstraintOperatorType.LESS_OR_EQUAL,
+ ConstraintOperatorType.IN_RANGE,
+ ConstraintOperatorType.VALID_VALUES,
+ ConstraintOperatorType.LENGTH,
+ ConstraintOperatorType.MIN_LENGTH,
+ ConstraintOperatorType.MAX_LENGTH,
+ ConstraintOperatorType.PATTERN
];
+ @Input() comparableAllowedOperators: ConstraintOperatorType[] = [
+ ConstraintOperatorType.GREATER_THAN,
+ ConstraintOperatorType.LESS_THAN,
+ ConstraintOperatorType.EQUAL,
+ ConstraintOperatorType.GREATER_OR_EQUAL,
+ ConstraintOperatorType.LESS_OR_EQUAL,
+ ConstraintOperatorType.IN_RANGE,
+ ConstraintOperatorType.VALID_VALUES,
+ ];
@Input() capabilityNameAndPropertiesMap: Map<string, PropertyModel[]>;
@Input() filterType: FilterType;
@Input() filterConstraint: PropertyFilterConstraintUi;
@@ -62,6 +77,13 @@ export class ServiceDependenciesEditorComponent implements OnInit {
FILTER_TYPE_CAPABILITY: FilterType = FilterType.CAPABILITY
+ listAllowedOperators: ConstraintOperatorType[] = [
+ ConstraintOperatorType.EQUAL,
+ ConstraintOperatorType.LENGTH,
+ ConstraintOperatorType.MIN_LENGTH,
+ ConstraintOperatorType.MAX_LENGTH
+ ];
+
operatorTypes: DropdownValue[] = [
{label: FilterConstraintHelper.convertToSymbol(ConstraintOperatorType.GREATER_THAN), value: ConstraintOperatorType.GREATER_THAN},
{label: FilterConstraintHelper.convertToSymbol(ConstraintOperatorType.LESS_THAN), value: ConstraintOperatorType.LESS_THAN},
@@ -69,6 +91,9 @@ export class ServiceDependenciesEditorComponent implements OnInit {
{label: FilterConstraintHelper.convertToSymbol(ConstraintOperatorType.GREATER_OR_EQUAL), value: ConstraintOperatorType.GREATER_OR_EQUAL},
{label: FilterConstraintHelper.convertToSymbol(ConstraintOperatorType.LESS_OR_EQUAL), value: ConstraintOperatorType.LESS_OR_EQUAL}
];
+ lengthArray: string[] = [ConstraintOperatorType.LENGTH,
+ ConstraintOperatorType.MIN_LENGTH,
+ ConstraintOperatorType.MAX_LENGTH];
servicePropertyDropdownList: DropdownValue[];
isLoading: false;
@@ -77,10 +102,14 @@ export class ServiceDependenciesEditorComponent implements OnInit {
componentInstanceMap: Map<string, InstanceFeDetails> = new Map<string, InstanceFeDetails>();
customToscaFunctions: Array<CustomToscaFunction>;
capabilityDropdownList: DropdownValue[] = [];
+ validValuesToscaFunctionList: ToscaFunction[];
+ rangeToscaFunctionList: ToscaFunction[];
+ overridingType = PROPERTY_TYPES.INTEGER;
SOURCE_TYPES = {
STATIC: {label: 'Static', value: SourceType.STATIC},
- TOSCA_FUNCTION: {label: 'Tosca Function', value: SourceType.TOSCA_FUNCTION}
+ TOSCA_FUNCTION: {label: 'Tosca Function', value: SourceType.TOSCA_FUNCTION},
+ TOSCA_FUNCTION_LIST: {label: 'Tosca Function List', value: SourceType.TOSCA_FUNCTION_LIST}
};
constructor(private propertiesUtils: PropertiesUtils, private compositionService: CompositionService, private topologyTemplateService: TopologyTemplateService) {}
@@ -100,6 +129,7 @@ export class ServiceDependenciesEditorComponent implements OnInit {
this.initSelectedSourceType();
this.initPropertyDropdown();
this.syncRuleData();
+ this.generateRangeToscaFunctionList();
}
private initCustomToscaFunctions() {
@@ -138,43 +168,87 @@ export class ServiceDependenciesEditorComponent implements OnInit {
this.servicePropertyDropdownList = [new DropdownValue(undefined, selectLabel), ...propertyList.map(prop => new DropdownValue(prop.name, prop.name)).sort((prop1, prop2) => prop1.value.localeCompare(prop2.value))];
}
- private initConstraintOperatorOptions(): void {
- if (!this.selectedProperty) {
- this.operatorTypes = [new DropdownValue(undefined, 'Select a Property')];
- return;
+ private initConstraintOperatorOptions(): void {
+ if (!this.selectedProperty) {
+ this.operatorTypes = [this.setOperatorDropdownValue(undefined)];
+ return;
+ }
+ const operatorList: DropdownValue[] = [];
+ switch (true) {
+ case this.selectedProperty.type === PROPERTY_TYPES.RANGE:
+ if (this.currentRule.constraintOperator !== ConstraintOperatorType.IN_RANGE) {
+ this.currentRule.constraintOperator = ConstraintOperatorType.IN_RANGE;
+ }
+ this.operatorTypes = [this.setOperatorDropdownValue(ConstraintOperatorType.IN_RANGE)];
+ break;
+ case this.selectedProperty.type === PROPERTY_TYPES.STRING:
+ this.allowedOperators.forEach(constraintOperatorType =>
+ operatorList.push(this.setOperatorDropdownValue(constraintOperatorType))
+ );
+ this.operatorTypes = operatorList;
+ break;
+ case this.selectedProperty.type != PROPERTY_TYPES.STRING &&
+ ((PROPERTY_DATA.SIMPLE_TYPES_COMPARABLE.indexOf(this.selectedProperty.type) > -1) ||
+ (PROPERTY_DATA.COMPARABLE_TYPES.indexOf(this.selectedProperty.type) > -1)):
+ this.comparableAllowedOperators.forEach(constraintOperatorType =>
+ operatorList.push(this.setOperatorDropdownValue(constraintOperatorType))
+ );
+ this.operatorTypes = operatorList;
+ break;
+ case this.selectedProperty.type === PROPERTY_TYPES.LIST:
+ this.listAllowedOperators.forEach(constraintOperatorType =>
+ operatorList.push(this.setOperatorDropdownValue(constraintOperatorType))
+ );
+ this.operatorTypes = operatorList;
+ break;
+ default:
+ if (this.currentRule.constraintOperator !== ConstraintOperatorType.EQUAL) {
+ this.currentRule.constraintOperator = ConstraintOperatorType.EQUAL;
+ }
+ this.operatorTypes = [this.setOperatorDropdownValue(ConstraintOperatorType.EQUAL)];
+ break;
+ }
}
- if (PROPERTY_DATA.SIMPLE_TYPES_COMPARABLE.indexOf(this.selectedProperty.type) === -1) {
- if (this.currentRule.constraintOperator !== ConstraintOperatorType.EQUAL) {
- this.currentRule.constraintOperator = ConstraintOperatorType.EQUAL;
- }
- this.operatorTypes = [new DropdownValue(ConstraintOperatorType.EQUAL, FilterConstraintHelper.convertToSymbol(ConstraintOperatorType.EQUAL))];
- } else {
- const operatorList: DropdownValue[] = [];
- this.allowedOperators.forEach(constraintOperatorType =>
- operatorList.push(new DropdownValue(constraintOperatorType, FilterConstraintHelper.convertToSymbol(constraintOperatorType)))
- );
- this.operatorTypes = operatorList;
+ private setOperatorDropdownValue(constraintOperatorType: ConstraintOperatorType) {
+ if (constraintOperatorType === undefined) {
+ return new DropdownValue(undefined, 'Select a Property');
+ }
+ return new DropdownValue(constraintOperatorType, FilterConstraintHelper.convertToSymbol(constraintOperatorType));
}
- }
- private initSelectedSourceType(): void {
+ private initSelectedSourceType(): void {
if (!this.currentRule.sourceType || this.currentRule.sourceType === SourceType.STATIC) {
this.selectedSourceType = SourceType.STATIC;
} else {
- this.selectedSourceType = SourceType.TOSCA_FUNCTION;
+ if (!this.isValidValuesOperator() && !this.isRangeType() && !this.isInRangeOperator()){
+ this.selectedSourceType = SourceType.TOSCA_FUNCTION;
+ }
+ else {
+ this.selectedSourceType = SourceType.TOSCA_FUNCTION_LIST;
+ }
}
}
private initCurrentRule(): void {
+ let propertyList: PropertyBEModel[] = [];
+ if (this.filterType == FilterType.CAPABILITY) {
+ if (this.currentRule.capabilityName) {
+ propertyList = this.capabilityNameAndPropertiesMap.get(this.currentRule.capabilityName);
+ }
+ } else {
+ propertyList = this.selectedInstanceProperties;
+ }
if (this.filterConstraint) {
+ this.filterConstraint.originalType = propertyList.find(prop=>prop.name==this.filterConstraint.servicePropertyName).type;
this.currentRule = new PropertyFilterConstraintUi(this.filterConstraint);
} else {
this.currentRule = new PropertyFilterConstraintUi({
sourceName: SourceType.STATIC,
sourceType: SourceType.STATIC,
constraintOperator: ConstraintOperatorType.EQUAL,
- value: undefined
+ value: undefined,
+ originalType: undefined
});
}
}
@@ -223,18 +297,26 @@ export class ServiceDependenciesEditorComponent implements OnInit {
}
newProperty.value = undefined;
newProperty.toscaFunction = undefined;
+
if (typeof this.currentRule.value === 'string') {
newProperty.value = this.currentRule.value;
this.propertiesUtils.initValueObjectRef(newProperty);
} else if (ToscaFunctionHelper.isValueToscaFunction(this.currentRule.value)) {
newProperty.toscaFunction = ToscaFunctionHelper.convertObjectToToscaFunction(this.currentRule.value);
newProperty.value = newProperty.toscaFunction.buildValueString();
+ } else if (Array.isArray(this.currentRule.value) &&
+ typeof this.currentRule.value[0] === "object" &&
+ this.currentRule.value[0]['propertySource'] != undefined) {
+ this.validValuesToscaFunctionList = this.currentRule.value;
+ this.rangeToscaFunctionList = this.currentRule.value;
+ newProperty.toscaFunction = this.currentRule.value;
} else {
newProperty.value = JSON.stringify(this.currentRule.value);
this.propertiesUtils.initValueObjectRef(newProperty);
}
this.selectedProperty = newProperty;
+ this.currentRule.originalType = this.selectedProperty.type;
}
updateSelectedProperty(): void {
@@ -256,6 +338,7 @@ export class ServiceDependenciesEditorComponent implements OnInit {
this.propertiesUtils.initValueObjectRef(newProperty);
this.selectedProperty = newProperty;
+ this.currentRule.originalType = this.selectedProperty.type;
}
isStaticSource(): boolean {
@@ -266,10 +349,30 @@ export class ServiceDependenciesEditorComponent implements OnInit {
return this.selectedSourceType === SourceType.TOSCA_FUNCTION
}
+ isToscaFunctionListSource(): boolean {
+ return this.selectedSourceType === SourceType.TOSCA_FUNCTION_LIST
+ }
+
isComplexListMapType(): boolean {
return this.selectedProperty && this.selectedProperty.derivedDataType > 0;
}
+ isRangeType(): boolean {
+ return this.selectedProperty && this.selectedProperty.derivedDataType == 4;
+ }
+
+ isLengthOperator(): boolean {
+ return this.lengthArray.indexOf(this.currentRule.constraintOperator) > -1;
+ }
+
+ isInRangeOperator(): boolean {
+ return this.currentRule.constraintOperator && this.currentRule.constraintOperator === ConstraintOperatorType.IN_RANGE;
+ }
+
+ isValidValuesOperator(): boolean {
+ return this.currentRule.constraintOperator && this.currentRule.constraintOperator === ConstraintOperatorType.VALID_VALUES;
+ }
+
updateComplexListMapTypeRuleValue(): void {
this.currentRule.value = PropertyFEModel.cleanValueObj(this.selectedProperty.valueObj);
this.onValueChange(this.selectedProperty.valueObjIsValid);
@@ -277,11 +380,23 @@ export class ServiceDependenciesEditorComponent implements OnInit {
onToscaFunctionValidityChange(validationEvent: ToscaFunctionValidationEvent): void {
if (validationEvent.isValid && validationEvent.toscaFunction) {
- this.currentRule.value = validationEvent.toscaFunction;
- this.currentRule.sourceType = validationEvent.toscaFunction.type
- if (validationEvent.toscaFunction instanceof ToscaGetFunction) {
- this.currentRule.sourceName = validationEvent.toscaFunction.sourceName;
- }
+ if (this.isValidValuesOperator()) {
+ this.currentRule.value = this.validValuesToscaFunctionList;
+ this.currentRule.sourceType = SourceType.TOSCA_FUNCTION_LIST;
+ if (validationEvent.toscaFunction instanceof ToscaGetFunction) {
+ this.currentRule.sourceName = SourceType.TOSCA_FUNCTION_LIST;
+ }
+ }
+ else {
+ if (this.isLengthOperator()) {
+ this.overridingType = PROPERTY_TYPES.INTEGER;
+ }
+ this.currentRule.value = validationEvent.toscaFunction;
+ this.currentRule.sourceType = validationEvent.toscaFunction.type
+ if (validationEvent.toscaFunction instanceof ToscaGetFunction) {
+ this.currentRule.sourceName = validationEvent.toscaFunction.sourceName;
+ }
+ }
} else {
this.currentRule.updateValidity(false);
this.currentRule.value = undefined;
@@ -290,12 +405,50 @@ export class ServiceDependenciesEditorComponent implements OnInit {
}
}
+ onToscaFunctionListValidityChange(validationEvent: ToscaFunctionValidationEvent, valueIndex: number): void {
+ if (validationEvent.isValid && validationEvent.toscaFunction) {
+ this.validValuesToscaFunctionList.splice(this.validValuesToscaFunctionList.length -1, 1, validationEvent.toscaFunction);
+ this.currentRule.value = this.validValuesToscaFunctionList;
+ this.currentRule.sourceType = 'SEVERAL';
+ if (validationEvent.toscaFunction instanceof ToscaGetFunction) {
+ this.currentRule.sourceName = validationEvent.toscaFunction.sourceName;
+ }
+ } else {
+ this.currentRule.updateValidity(false);
+ this.currentRule.value = undefined;
+ this.currentRule.sourceType = undefined;
+ this.currentRule.sourceName = undefined;
+ }
+ }
+
+ onToscaRangeFunctionListValidityChange(validationEvent: ToscaFunctionValidationEvent, valueIndex: number): void {
+ if (validationEvent.isValid && validationEvent.toscaFunction) {
+ this.rangeToscaFunctionList.splice(valueIndex, 1, validationEvent.toscaFunction);
+ this.currentRule.value = this.rangeToscaFunctionList;
+ this.currentRule.sourceType = 'SEVERAL';
+ if (validationEvent.toscaFunction instanceof ToscaGetFunction) {
+ this.currentRule.sourceName = validationEvent.toscaFunction.sourceName;
+ }
+ } else {
+ this.currentRule.updateValidity(false);
+ this.currentRule.value = undefined;
+ this.currentRule.sourceType = undefined;
+ this.currentRule.sourceName = undefined;
+ }
+ }
+
onSourceTypeChange(): void {
this.currentRule.value = undefined;
+ if (!this.isStaticSource() && (this.isValidValuesOperator() || this.isRangeType() || this.isInRangeOperator())) {
+ this.selectedSourceType = SourceType.TOSCA_FUNCTION_LIST;
+ }
this.currentRule.sourceType = this.selectedSourceType;
if (this.isStaticSource()) {
this.currentRule.sourceName = SourceType.STATIC;
}
+ if (this.isToscaFunctionListSource()) {
+ this.currentRule.sourceName = SourceType.TOSCA_FUNCTION_LIST;
+ }
this.updateSelectedProperty();
}
@@ -305,6 +458,41 @@ export class ServiceDependenciesEditorComponent implements OnInit {
this.onPropertyChange();
}
+ addToList(){
+ if (!this.validValuesToscaFunctionList) {
+ this.validValuesToscaFunctionList = new Array();
+ }
+ this.validValuesToscaFunctionList.push(ToscaFunctionHelper.convertObjectToToscaFunction(undefined));
+ }
+
+ generateRangeToscaFunctionList() {
+ if (!this.rangeToscaFunctionList) {
+ this.rangeToscaFunctionList = new Array();
+ this.rangeToscaFunctionList.push(ToscaFunctionHelper.convertObjectToToscaFunction(undefined));
+ this.rangeToscaFunctionList.push(ToscaFunctionHelper.convertObjectToToscaFunction(undefined));
+ }
+ }
+
+ trackByFn(index) {
+ return index;
+ }
+
+ removeFromList(valueIndex: number){
+ this.validValuesToscaFunctionList.splice(valueIndex, 1);
+ this.currentRule.updateValidity(!this.doesArrayContainsEmptyValues(this.validValuesToscaFunctionList) && !(this.validValuesToscaFunctionList.length === 0));
+ if (this.doesArrayContainsEmptyValues(this.validValuesToscaFunctionList) || (this.validValuesToscaFunctionList.length === 0)) {
+ this.currentRule.value = undefined;
+ this.currentRule.sourceType = undefined;
+ this.currentRule.sourceName = undefined;
+ }
+ }
+
+ private doesArrayContainsEmptyValues(arr) {
+ for(const element of arr) {
+ if(element === undefined) return true;
+ }
+ return false;
+ }
}
export enum FilterType {