From 0c61108fca142e7e6a9d59453e3b14f2b402e89d Mon Sep 17 00:00:00 2001 From: aribeiro Date: Fri, 21 Aug 2020 18:04:52 +0100 Subject: Enable node_filter update action Issue-ID: SDC-3257 Signed-off-by: aribeiro Change-Id: Id8ae9a7bfe941aa11891f472e830b4ca59b3e839 --- .../service-dependencies.component.html | 12 +++---- .../service-dependencies.component.ts | 40 ++++++++++------------ .../service-dependencies-tab.component.ts | 2 +- .../responses/component-generic-response.ts | 6 ++-- 4 files changed, 28 insertions(+), 32 deletions(-) (limited to 'catalog-ui/src/app') diff --git a/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.html b/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.html index f093143054..4238a4e96f 100644 --- a/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.html +++ b/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.html @@ -18,13 +18,13 @@
+ *ngFor="let constraint of constraintObjects; let i = index">
- {{rule.servicePropertyName + ' ' + getSymbol(rule.constraintOperator) + ' ' - + (rule.sourceName ? rule.sourceName + ':' : '') + rule.value}} + tooltip="{{constraint.servicePropertyName + ' ' + getSymbol(constraint.constraintOperator) + ' ' + + (constraint.sourceName ? constraint.sourceName + ':' : '') + constraint.value}}"> + {{constraint.servicePropertyName + ' ' + getSymbol(constraint.constraintOperator) + ' ' + + (constraint.sourceName ? constraint.sourceName + ':' : '') + constraint.value}}
@@ -41,4 +41,4 @@
-
\ No newline at end of file + 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 495782494c..55c933c38d 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 @@ -123,7 +123,7 @@ export class ServiceDependenciesComponent { isDependent: boolean; isLoading: boolean; parentServiceInputs: InputBEModel[] = []; - rulesList: ConstraintObject[] = []; + constraintObjects: ConstraintObject[] = []; operatorTypes: any[]; @Input() readonly: boolean; @@ -150,7 +150,7 @@ export class ServiceDependenciesComponent { this.topologyTemplateService.getComponentInputsWithProperties(this.compositeService.componentType, this.compositeService.uniqueId).subscribe((result: ComponentGenericResponse) => { this.parentServiceInputs = result.inputs; }); - this.loadRules(); + this.loadNodeFilter(); this.translateService.languageChangedObservable.subscribe((lang) => { I18nTexts.translateTexts(this.translateService); }); @@ -163,18 +163,13 @@ export class ServiceDependenciesComponent { } if (changes.selectedInstanceConstraints && changes.selectedInstanceConstraints.currentValue !== changes.selectedInstanceConstraints.previousValue) { this.selectedInstanceConstraints = changes.selectedInstanceConstraints.currentValue; - this.loadRules(); + this.loadNodeFilter(); } } private getActualDirectiveValue = (): string => { return this.currentServiceInstance.directives.length > 0 ? this.currentServiceInstance.directives[0] : ""; } - - private isServiceProxy = (): boolean => { - return this.currentServiceInstance.isServiceProxy(); - } - public openRemoveDependencyModal = (): ComponentRef => { const actionButton: ButtonModel = new ButtonModel(I18nTexts.modalApprove, 'blue', this.onUncheckDependency); const cancelButton: ButtonModel = new ButtonModel(I18nTexts.modalCancel, 'grey', this.onCloseRemoveDependencyModal); @@ -191,21 +186,22 @@ export class ServiceDependenciesComponent { return this.modalServiceNg2.createCustomModal(modalModel); } - loadRules() { - this.rulesList = this.selectedInstanceConstraints && this.selectedInstanceConstraints.map((co: ConstraintObject) => ({ - servicePropertyName: co.servicePropertyName, - constraintOperator: co.constraintOperator, - sourceType: co.sourceType, - sourceName: co.sourceName !== 'SELF' ? co.sourceName : this.compositeService.name, - value: co.value, - })); + private loadNodeFilter = (): void => { + this.topologyTemplateService.getServiceFilterConstraints(this.compositeService.componentType, this.compositeService.uniqueId).subscribe((response) => { + if (response.nodeFilterforNode) { + const nodeFilterResponse: ConstraintObject[] = response.nodeFilterforNode[this.currentServiceInstance.uniqueId].properties; + if (nodeFilterResponse) { + this.constraintObjects = nodeFilterResponse; + } + } + }); } onUncheckDependency = () => { this.modalServiceNg2.closeCurrentModal(); this.isLoading = true; const isDepOrig = this.isDependent; - const rulesListOrig = this.rulesList; + const rulesListOrig = this.constraintObjects; this.currentServiceInstance.unmarkAsDependent(this.getActualDirectiveValue()); this.updateComponentInstance(isDepOrig, rulesListOrig); } @@ -218,16 +214,16 @@ export class ServiceDependenciesComponent { onOptionsSelected(event: any) { const newDirectiveValue = event.target.value; if (newDirectiveValue.toLowerCase() !== this.getActualDirectiveValue()) { - const rulesListOrig = this.rulesList; + const rulesListOrig = this.constraintObjects; this.setDirectiveValue(newDirectiveValue); - this.rulesList = []; + this.constraintObjects = []; this.updateComponentInstance(this.isDependent, rulesListOrig); } } private onRemoveDirective() { this.openRemoveDependencyModal().instance.open(); - this.rulesList = []; + this.constraintObjects = []; } private setDirectiveValue(newDirectiveValue: string) { @@ -257,7 +253,7 @@ export class ServiceDependenciesComponent { this.isLoading = false; }, (err) => { this.isDependent = isDependentOrigVal; - this.rulesList = rulesListOrig; + this.constraintObjects = rulesListOrig; this.isLoading = false; console.log('An error has occurred.'); }); @@ -293,7 +289,7 @@ export class ServiceDependenciesComponent { ServiceDependenciesEditorComponent, { serviceRuleIndex: index, - serviceRules: _.map(this.rulesList, (rule) => new ConstraintObjectUI(rule)), + serviceRules: _.map(this.constraintObjects, (rule) => new ConstraintObjectUI(rule)), currentServiceName: this.currentServiceInstance.name, operatorTypes: this.operatorTypes, compositeServiceName: this.compositeService.name, diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/service-dependencies-tab/service-dependencies-tab.component.ts b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/service-dependencies-tab/service-dependencies-tab.component.ts index 5171e3b607..fb0898d53e 100644 --- a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/service-dependencies-tab/service-dependencies-tab.component.ts +++ b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/service-dependencies-tab/service-dependencies-tab.component.ts @@ -61,7 +61,7 @@ export class ServiceDependenciesTabComponent { public loadConstraints = (): void => { this.topologyTemplateService.getServiceFilterConstraints(this.metaData.componentType, this.metaData.uniqueId).subscribe((response) => { - this.componentInstancesConstraints = response.nodeFilterData; + this.componentInstancesConstraints = response.nodeFilterforNode; }); } diff --git a/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts b/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts index 2c502d9fd5..c6be9c369a 100644 --- a/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts +++ b/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts @@ -56,7 +56,7 @@ export class ComponentGenericResponse implements Serializable; public additionalInformation:any; public derivedList:Array; - public nodeFilterData: Array; + public nodeFilterforNode: Array; public substitutionFilterForTopologyTemplate: Array; deserialize (response): ComponentGenericResponse { @@ -120,8 +120,8 @@ export class ComponentGenericResponse implements Serializable