summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/pages
diff options
context:
space:
mode:
authoraribeiro <anderson.ribeiro@est.tech>2021-11-18 10:29:39 +0000
committerMichael Morris <michael.morris@est.tech>2021-12-06 11:51:31 +0000
commitd5edf5274286e9808dfabf2f49a03a1ba235b70c (patch)
tree7e746ee88b36b19bdd91fb1c55a0bf97d0bfbca7 /catalog-ui/src/app/ng2/pages
parentfbc285a47209b763ef3bf7b64e7e0c6e3e1a5202 (diff)
Add node filter with getInput function
Support get_input functions for creating node and substitution filters Issue-ID: SDC-3793 Signed-off-by: aribeiro <anderson.ribeiro@est.tech> Change-Id: Ie00f621be8418b4a9c88afcbbc07d80c22165e9b
Diffstat (limited to 'catalog-ui/src/app/ng2/pages')
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/substitution-filter-tab/substitution-filter-tab.component.html5
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/substitution-filter-tab/substitution-filter-tab.component.ts23
-rw-r--r--catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.html10
-rw-r--r--catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts136
4 files changed, 113 insertions, 61 deletions
diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/substitution-filter-tab/substitution-filter-tab.component.html b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/substitution-filter-tab/substitution-filter-tab.component.html
index c8845deece..a9fad5a733 100644
--- a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/substitution-filter-tab/substitution-filter-tab.component.html
+++ b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/substitution-filter-tab/substitution-filter-tab.component.html
@@ -23,8 +23,9 @@
<substitution-filter
[compositeService]="metaData"
[currentServiceInstance]="component"
- [selectedInstanceProperties]="selectedInstanceProperties"
- [selectedInstanceSiblings]="selectedInstanceSiblings"
+ [parentServiceProperties]="parentServiceProperties"
+ [parentServiceInputs]="parentServiceInputs"
+ [selectedInstanceProperties]="parentServiceProperties"
[selectedInstanceConstraints]="selectedInstanceConstraints"
[readonly]="isViewOnly"
(hasSubstitutionFilter)="notifyDependencyEventsObserver($event)"
diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/substitution-filter-tab/substitution-filter-tab.component.ts b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/substitution-filter-tab/substitution-filter-tab.component.ts
index c4101ab2bc..bf8d1e43b1 100644
--- a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/substitution-filter-tab/substitution-filter-tab.component.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/substitution-filter-tab/substitution-filter-tab.component.ts
@@ -21,7 +21,7 @@ import { Component, Input } from '@angular/core';
import { Store } from '@ngxs/store';
import {
Component as TopologyTemplate,
- FullComponentInstance,
+ FullComponentInstance, InputBEModel,
PropertiesGroup,
PropertyBEModel,
} from 'app/models';
@@ -47,7 +47,8 @@ export class SubstitutionFilterTabComponent {
selectedInstanceSiblings: ServiceInstanceObject[];
componentInstancesConstraints: any[];
selectedInstanceConstraints: ConstraintObject[];
- selectedInstanceProperties: PropertyBEModel[];
+ parentServiceProperties: PropertyBEModel[];
+ parentServiceInputs: InputBEModel[];
componentInstanceProperties: PropertiesGroup;
metaData: ComponentMetadata;
@@ -85,21 +86,11 @@ export class SubstitutionFilterTabComponent {
}
private initInstancesWithProperties = (): void => {
- this.topologyTemplateService.getComponentPropertiesSubstitutionFilter(this.metaData.componentType, this.metaData.uniqueId).subscribe((genericResponse: ComponentGenericResponse) => {
- this.selectedInstanceProperties = genericResponse.properties;
- this.updateInstanceAttributes();
+ this.topologyTemplateService.getComponentPropertiesAndInputsForSubstitutionFilter(this.metaData.componentType, this.metaData.uniqueId)
+ .subscribe((genericResponse: ComponentGenericResponse) => {
+ this.parentServiceProperties = genericResponse.properties;
+ this.parentServiceInputs = genericResponse.inputs;
});
}
- private updateInstanceAttributes = (): void => {
- if (this.isComponentInstanceSelected && this.componentInstanceProperties) {
- const instancesMappedList = this.compositionService.componentInstances.map((coInstance) => new ServiceInstanceObject({
- id: coInstance.uniqueId,
- name: coInstance.name,
- properties: this.componentInstanceProperties[coInstance.uniqueId] || []
- }));
- this.selectedInstanceProperties = this.componentInstanceProperties[this.component.uniqueId];
- this.selectedInstanceSiblings = instancesMappedList.filter((coInstance) => coInstance.id !== this.component.uniqueId);
- }
- }
}
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 f84214e4ce..8a577aef77 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
@@ -6,7 +6,7 @@
<div class="i-sdc-form-content">
<div class="rule-builder-content">
<div class="i-sdc-form-item rule-input-field">
- <label class="i-sdc-form-label required">Service {{currentServiceName}} Property</label>
+ <label class="i-sdc-form-label required">{{currentServiceName}} Property</label>
<ui-element-dropdown
class="i-sdc-form-select"
data-tests-id="servicePropertyName"
@@ -21,9 +21,15 @@
</div>
<div class="i-sdc-form-item rule-input-field">
+ <label class="i-sdc-form-label required" >Function Type</label>
+ <ui-element-dropdown class="i-sdc-form-select" data-tests-id="functionType" [values]="functionTypes" [(value)]="currentRule.sourceType" (change)="onSelectFunctionType()"></ui-element-dropdown>
+ </div>
+
+ <div class="i-sdc-form-item rule-input-field" *ngIf="isPropertyFunctionSelected()">
<label class="i-sdc-form-label required" >Source</label>
- <ui-element-dropdown class="i-sdc-form-select" data-tests-id="sourceType" [values]="sourceTypes" [(value)]="currentRule.sourceName" (change)="onSelectSourceType($event)"></ui-element-dropdown>
+ <ui-element-dropdown class="i-sdc-form-select" data-tests-id="sourceType" [values]="sourceTypes" [(value)]="currentRule.sourceName" (change)="onSelectSourceType()"></ui-element-dropdown>
</div>
+
<div [ngClass]="isComplexListMapType() && isStaticSource() ? 'complex-input-field' : ''"
class="rule-input-field assigned-value-field">
<label class="i-sdc-form-label required" >{{assignedValueLabel}}</label>
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 cb3e87c8d1..c6b3b65512 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
@@ -56,6 +56,7 @@ export class ServiceDependenciesEditorComponent {
compositeServiceName: string,
currentServiceName: string,
parentServiceInputs: InputBEModel[],
+ parentServiceProperties: PropertyBEModel[];
selectedInstanceProperties: PropertyBEModel[],
operatorTypes: DropdownValue[],
selectedInstanceSiblings: ServiceInstanceObject[]
@@ -65,6 +66,7 @@ export class ServiceDependenciesEditorComponent {
selectedPropertyObj: PropertyFEModel;
ddValueSelectedServicePropertiesNames: DropdownValue[];
operatorTypes: DropdownValue[];
+ functionTypes: DropdownValue[];
sourceTypes: UIDropDownSourceTypesElement[] = [];
currentRule: ConstraintObjectUI;
currentIndex: number;
@@ -75,7 +77,8 @@ export class ServiceDependenciesEditorComponent {
SOURCE_TYPES = {
STATIC: {label: 'Static', value: 'static'},
- SERVICE_PROPERTY: {label: 'Service Property', value: 'property'}
+ SERVICE_PROPERTY: {label: 'Service Property', value: 'property'},
+ SERVICE_INPUT: {label: 'Service Input', value: 'service_input'}
};
constructor(private propertiesUtils: PropertiesUtils) {}
@@ -83,6 +86,19 @@ export class ServiceDependenciesEditorComponent {
ngOnInit() {
this.currentIndex = this.input.serviceRuleIndex;
this.serviceRulesList = this.input.serviceRules;
+ this.initCurrentRule();
+ this.currentServiceName = this.input.currentServiceName;
+ this.operatorTypes = this.input.operatorTypes;
+ this.selectedServiceProperties = this.input.selectedInstanceProperties;
+ this.ddValueSelectedServicePropertiesNames = _.map(this.input.selectedInstanceProperties, (prop) => new DropdownValue(prop.name, prop.name));
+ this.initFunctionTypes();
+ if (this.SOURCE_TYPES.STATIC.value !== this.currentRule.sourceType) {
+ this.loadSourceTypesData();
+ }
+ this.syncRuleData();
+ }
+
+ private initCurrentRule() {
this.currentRule = this.serviceRulesList && this.input.serviceRuleIndex >= 0 ?
this.serviceRulesList[this.input.serviceRuleIndex] :
new ConstraintObjectUI({
@@ -91,39 +107,73 @@ export class ServiceDependenciesEditorComponent {
value: '',
constraintOperator: OPERATOR_TYPES.EQUAL
});
- this.currentServiceName = this.input.currentServiceName;
- this.operatorTypes = this.input.operatorTypes;
- this.selectedServiceProperties = this.input.selectedInstanceProperties;
- this.ddValueSelectedServicePropertiesNames = _.map(this.input.selectedInstanceProperties, (prop) => new DropdownValue(prop.name, prop.name));
- this.initSourceTypes();
- this.syncRuleData();
+ if (this.currentRule && this.currentRule.sourceType === this.SOURCE_TYPES.SERVICE_INPUT.value) {
+ this.currentRule.sourceName = this.input.compositeServiceName;
+ }
+ }
+
+ private initFunctionTypes() {
+ this.functionTypes = [
+ {label: this.SOURCE_TYPES.STATIC.label, value: this.SOURCE_TYPES.STATIC.value},
+ {label: this.SOURCE_TYPES.SERVICE_PROPERTY.label, value: this.SOURCE_TYPES.SERVICE_PROPERTY.value},
+ {label: this.SOURCE_TYPES.SERVICE_INPUT.label, value: this.SOURCE_TYPES.SERVICE_INPUT.value}];
+ }
+
+ onServicePropertyChanged() {
+ this.updateSelectedPropertyObj();
+ this.updateOperatorTypesList();
+ this.currentRule.sourceName = "";
+ this.currentRule.value = "";
+ }
+
+ onSelectFunctionType() {
+ this.currentRule.value = "";
+ this.currentRule.sourceName = "";
+ this.listOfValuesToAssign = [];
+ this.currentRule.sourceType = this.updateCurrentSourceType(this.currentRule.sourceType);
+ this.loadSourceTypesData();
this.updateSourceTypesRelatedValues();
}
- initSourceTypes() {
- this.sourceTypes.push({
- label: this.SOURCE_TYPES.STATIC.label,
- value: this.SOURCE_TYPES.STATIC.value,
- options: [],
- assignedLabel: this.SOURCE_TYPES.STATIC.label,
- type: this.SOURCE_TYPES.STATIC.value
- });
+ onSelectSourceType() {
+ this.currentRule.value = "";
+ this.updateSourceTypesRelatedValues();
+ }
+
+ loadSourceTypesData() {
+ this.sourceTypes = [];
this.sourceTypes.push({
label: this.input.compositeServiceName,
value: this.input.compositeServiceName,
- assignedLabel: this.SOURCE_TYPES.SERVICE_PROPERTY.label,
- type: this.SOURCE_TYPES.SERVICE_PROPERTY.value,
- options: this.input.parentServiceInputs
+ assignedLabel: this.currentRule.sourceType == this.SOURCE_TYPES.SERVICE_PROPERTY.value
+ ? this.SOURCE_TYPES.SERVICE_PROPERTY.label : this.SOURCE_TYPES.SERVICE_INPUT.label,
+ type: this.currentRule.sourceType == this.SOURCE_TYPES.SERVICE_PROPERTY.value
+ ? this.SOURCE_TYPES.SERVICE_PROPERTY.value : this.SOURCE_TYPES.SERVICE_INPUT.value,
+ options: this.loadSourceTypeBySelectedFunction().get(this.currentRule.sourceType)
});
- _.forEach(this.input.selectedInstanceSiblings, (sib) =>
- this.sourceTypes.push({
- label: sib.name,
- value: sib.name,
- options: sib.properties || [],
- assignedLabel: this.SOURCE_TYPES.SERVICE_PROPERTY.label,
- type: this.SOURCE_TYPES.SERVICE_PROPERTY.value
- })
- );
+
+ if (this.currentRule.sourceType === this.SOURCE_TYPES.SERVICE_INPUT.value) {
+ this.currentRule.sourceName = this.input.compositeServiceName;
+ } else {
+ if (this.input.selectedInstanceSiblings && this.isPropertyFunctionSelected) {
+ _.forEach(this.input.selectedInstanceSiblings, (sib) =>
+ this.sourceTypes.push({
+ label: sib.name,
+ value: sib.name,
+ options: sib.properties || [],
+ assignedLabel: this.SOURCE_TYPES.SERVICE_PROPERTY.label,
+ type: this.SOURCE_TYPES.SERVICE_PROPERTY.value
+ })
+ );
+ }
+ }
+ }
+
+ loadSourceTypeBySelectedFunction = (): any => {
+ let parentDataMap = new Map();
+ parentDataMap.set(this.SOURCE_TYPES.SERVICE_PROPERTY.value, this.input.parentServiceProperties);
+ parentDataMap.set(this.SOURCE_TYPES.SERVICE_INPUT.value , this.input.parentServiceInputs);
+ return parentDataMap;
}
syncRuleData() {
@@ -151,6 +201,7 @@ export class ServiceDependenciesEditorComponent {
(t) => t.value === this.currentRule.sourceName && t.type === this.currentRule.sourceType
);
if (selectedSourceType) {
+ this.listOfSourceOptions = [];
this.listOfSourceOptions = selectedSourceType.options || [];
this.assignedValueLabel = selectedSourceType.assignedLabel || this.SOURCE_TYPES.STATIC.label;
this.filterOptionsByType();
@@ -166,19 +217,15 @@ export class ServiceDependenciesEditorComponent {
}
}
- onServicePropertyChanged() {
- this.currentRule.value = '';
- this.updateSelectedPropertyObj();
- this.updateOperatorTypesList();
- this.filterOptionsByType();
- }
-
- onSelectSourceType() {
- this.currentRule.value = '';
- this.currentRule.sourceType = this.currentRule.sourceName === this.SOURCE_TYPES.STATIC.value ?
- this.SOURCE_TYPES.STATIC.value :
- this.SOURCE_TYPES.SERVICE_PROPERTY.value;
- this.updateSourceTypesRelatedValues();
+ private updateCurrentSourceType = (sourceType: string): string => {
+ switch (sourceType) {
+ case this.SOURCE_TYPES.STATIC.value:
+ return this.SOURCE_TYPES.STATIC.value;
+ case this.SOURCE_TYPES.SERVICE_PROPERTY.value:
+ return this.SOURCE_TYPES.SERVICE_PROPERTY.value;
+ case this.SOURCE_TYPES.SERVICE_INPUT.value:
+ return this.SOURCE_TYPES.SERVICE_INPUT.value;
+ }
}
filterOptionsByType() {
@@ -214,7 +261,9 @@ export class ServiceDependenciesEditorComponent {
newProp.value = JSON.stringify(this.currentRule.value);
this.propertiesUtils.initValueObjectRef(newProp);
console.log("TEST" + newProp.value);
- setTimeout(() => {this.selectedPropertyObj = newProp})
+ setTimeout(() => {
+ this.selectedPropertyObj = newProp})
+ this.selectedPropertyObj = newProp;
}
}
@@ -222,6 +271,10 @@ export class ServiceDependenciesEditorComponent {
return this.currentRule.sourceType === this.SOURCE_TYPES.STATIC.value
}
+ isPropertyFunctionSelected(): boolean {
+ return this.currentRule.sourceType === this.SOURCE_TYPES.SERVICE_PROPERTY.value;
+ }
+
isComplexListMapType(): boolean {
return this.selectedPropertyObj && this.selectedPropertyObj.derivedDataType > 0;
}
@@ -231,4 +284,5 @@ export class ServiceDependenciesEditorComponent {
this.currentRule.value = JSON.stringify(value);
this.onValueChange(this.selectedPropertyObj.valueObjIsValid);
}
+
}