diff options
Diffstat (limited to 'catalog-ui/src')
7 files changed, 127 insertions, 73 deletions
diff --git a/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts b/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts index f9f9286fe5..35e80dc70a 100644 --- a/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts +++ b/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts @@ -134,6 +134,7 @@ export class ServiceDependenciesComponent { isDependent: boolean; isLoading: boolean; parentServiceInputs: InputBEModel[] = []; + parentServiceProperties: PropertyBEModel[] = []; constraintProperties: ConstraintObject[] = []; constraintCapabilities: CapabilitiesConstraintObject[] = []; operatorTypes: any[]; @@ -167,8 +168,10 @@ export class ServiceDependenciesComponent { {label: '<', value: OPERATOR_TYPES.LESS_THAN}, {label: '=', value: OPERATOR_TYPES.EQUAL} ]; - this.topologyTemplateService.getComponentInputsWithProperties(this.compositeService.componentType, this.compositeService.uniqueId).subscribe((result: ComponentGenericResponse) => { + this.topologyTemplateService.getComponentInputsWithProperties(this.compositeService.componentType, this.compositeService.uniqueId) + .subscribe((result: ComponentGenericResponse) => { this.parentServiceInputs = result.inputs; + this.parentServiceProperties = result.properties; }); this.loadNodeFilter(); this.translateService.languageChangedObservable.subscribe((lang) => { @@ -300,6 +303,7 @@ export class ServiceDependenciesComponent { operatorTypes: this.operatorTypes, compositeServiceName: this.compositeService.name, parentServiceInputs: this.parentServiceInputs, + parentServiceProperties: this.parentServiceProperties, selectedInstanceProperties: this.selectedInstanceProperties, selectedInstanceSiblings: this.selectedInstanceSiblings } @@ -406,6 +410,7 @@ export class ServiceDependenciesComponent { operatorTypes: this.operatorTypes, compositeServiceName: this.compositeService.name, parentServiceInputs: this.parentServiceInputs, + parentServiceProperties: this.parentServiceProperties, selectedInstanceProperties: this.selectedInstanceProperties, selectedInstanceSiblings: this.selectedInstanceSiblings } diff --git a/catalog-ui/src/app/ng2/components/logic/substitution-filter/substitution-filter.component.ts b/catalog-ui/src/app/ng2/components/logic/substitution-filter/substitution-filter.component.ts index e0754af549..7671d653e4 100644 --- a/catalog-ui/src/app/ng2/components/logic/substitution-filter/substitution-filter.component.ts +++ b/catalog-ui/src/app/ng2/components/logic/substitution-filter/substitution-filter.component.ts @@ -30,7 +30,6 @@ import {ServiceDependenciesEditorComponent} from 'app/ng2/pages/service-dependen import {ModalService} from 'app/ng2/services/modal.service'; import {TranslateService} from 'app/ng2/shared/translator/translate.service'; import {ComponentMetadata} from '../../../../models/component-metadata'; -import {ServiceInstanceObject} from '../../../../models/service-instance-properties-and-interfaces'; import {TopologyTemplateService} from '../../../services/component-services/topology-template.service'; import {ToscaFilterConstraintType} from "../../../../models/tosca-filter-constraint-type.enum"; @@ -112,7 +111,6 @@ class I18nTexts { export class SubstitutionFilterComponent { modalInstance: ComponentRef<ModalComponent>; isLoading: boolean; - parentServiceInputs: InputBEModel[] = []; operatorTypes: any[]; constraintProperties: ConstraintObject[] = []; PROPERTIES: string = ToscaFilterConstraintType.PROPERTIES; @@ -120,9 +118,10 @@ export class SubstitutionFilterComponent { @Input() readonly: boolean; @Input() compositeService: ComponentMetadata; @Input() currentServiceInstance: ComponentInstance; - @Input() selectedInstanceSiblings: ServiceInstanceObject[]; @Input() selectedInstanceConstraints: ConstraintObject[] = []; @Input() selectedInstanceProperties: PropertyBEModel[] = []; + @Input() parentServiceProperties: PropertyBEModel[] = []; + @Input() parentServiceInputs: InputBEModel[] = []; @Output() updateSubstitutionFilterProperties: EventEmitter<ConstraintObject[]> = new EventEmitter<ConstraintObject[]>(); @Output() updateConstraintListEvent: EventEmitter<ConstraintObject[]> = new EventEmitter<ConstraintObject[]>(); @Output() loadConstraintListEvent: EventEmitter<any> = new EventEmitter(); @@ -176,8 +175,8 @@ export class SubstitutionFilterComponent { operatorTypes: this.operatorTypes, compositeServiceName: this.compositeService.name, parentServiceInputs: this.parentServiceInputs, - selectedInstanceProperties: this.selectedInstanceProperties, - selectedInstanceSiblings: this.selectedInstanceSiblings + parentServiceProperties: this.parentServiceProperties, + selectedInstanceProperties: this.parentServiceProperties, } ); this.modalInstance.instance.open(); @@ -216,8 +215,8 @@ export class SubstitutionFilterComponent { operatorTypes: this.operatorTypes, compositeServiceName: this.compositeService.name, parentServiceInputs: this.parentServiceInputs, - selectedInstanceProperties: this.selectedInstanceProperties, - selectedInstanceSiblings: this.selectedInstanceSiblings + parentServiceProperties: this.parentServiceProperties, + selectedInstanceProperties: this.parentServiceProperties, } ); this.modalInstance.instance.open(); 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); } + } diff --git a/catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts b/catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts index 7b726e4172..20425f810a 100644 --- a/catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts +++ b/catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts @@ -483,8 +483,8 @@ export class TopologyTemplateService { return this.http.delete<any>(this.baseUrl + this.getServerTypeUrl(componentType) + componentMetaDataId + '/componentInstance/' + componentInstanceId + '/' + constraintType + '/' + constraintIndex + '/nodeFilter') } - getComponentPropertiesSubstitutionFilter(componentType: string, componentId: string): Observable<ComponentGenericResponse> { - return this.getComponentDataByFieldsName(componentType, componentId, [COMPONENT_FIELDS.COMPONENT_PROPERTIES]); + getComponentPropertiesAndInputsForSubstitutionFilter(componentType: string, componentId: string): Observable<ComponentGenericResponse> { + return this.getComponentDataByFieldsName(componentType, componentId, [COMPONENT_FIELDS.COMPONENT_PROPERTIES, COMPONENT_FIELDS.COMPONENT_INPUTS]); } createSubstitutionFilterConstraints(componentMetaDataId: string, constraint: ConstraintObject, componentType: string, constraintType: string): Observable<any> { @@ -536,7 +536,6 @@ export class TopologyTemplateService { } protected getComponentDataByFieldsName(componentType: string, componentId: string, fields: string[]): Observable<ComponentGenericResponse> { - console.info("Topology template -> getComponentDataByFieldsName with id:", componentId) let params: HttpParams = new HttpParams(); _.forEach(fields, (field: string): void => { params = params.append(API_QUERY_PARAMS.INCLUDE, field); @@ -544,7 +543,6 @@ export class TopologyTemplateService { // tslint:disable-next-line:object-literal-shorthand return this.http.get<ComponentGenericResponse>(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/filteredDataByParams', {params: params}) .map((res) => { - console.info("Topology template -> getComponentDataByFieldsName response:", res); return componentType === ComponentType.SERVICE ? new ServiceGenericResponse().deserialize(res) : new ComponentGenericResponse().deserialize(res); }); |