From efdde52c76b16160fa3244834838f13977bb53c5 Mon Sep 17 00:00:00 2001 From: MichaelMorris Date: Tue, 19 Jul 2022 13:28:40 +0100 Subject: [PATCH] Support tosca functions for group instances Issue-ID: SDC-4090 Signed-off-by: KrupaNagabhushan Change-Id: I91650050fed57a4243df157034cb68ecd8421413 Signed-off-by: MichaelMorris --- .../properties-assignment.page.component.ts | 34 ++++++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) 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 2ae5ce8c09..6474b15df0 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 @@ -511,17 +511,17 @@ export class PropertiesAssignmentComponent { * Select Tosca function value from defined values */ selectToscaFunctionAndValues = (): void => { - const selectedInstanceData: ComponentInstance = this.getSelectedComponentInstance(); + const selectedInstanceData: ComponentInstance | GroupInstance = this.getSelectedInstance(); if (!selectedInstanceData) { return; } this.openToscaGetFunctionModal(); } - private getSelectedComponentInstance(): ComponentInstance { + private getSelectedInstance(): ComponentInstance | GroupInstance { const instancesIds = this.keysPipe.transform(this.instanceFePropertiesMap, []); const instanceId: string = instancesIds[0]; - return this.instances.find(instance => instance.uniqueId == instanceId && instance instanceof ComponentInstance); + return this.instances.find(instance => instance.uniqueId == instanceId && instance instanceof ComponentInstance || instance instanceof GroupInstance); } private buildCheckedInstanceProperty(): PropertyBEModel { @@ -578,13 +578,21 @@ export class PropertiesAssignmentComponent { checkedInstanceProperty.getInputValues = null; checkedInstanceProperty.value = null; checkedInstanceProperty.toscaFunction = null; - this.updateInstanceProperty(checkedInstanceProperty); + if (this.selectedInstanceData instanceof ComponentInstance) { + this.updateInstanceProperty(checkedInstanceProperty); + } else if (this.selectedInstanceData instanceof GroupInstance) { + this.updateGroupInstanceProperty(checkedInstanceProperty); + } } private updateCheckedInstancePropertyFunctionValue(toscaFunction: ToscaFunction) { const checkedProperty: PropertyBEModel = this.buildCheckedInstanceProperty(); checkedProperty.toscaFunction = toscaFunction; - this.updateInstanceProperty(checkedProperty); + if (this.selectedInstanceData instanceof ComponentInstance) { + this.updateInstanceProperty(checkedProperty); + } else if (this.selectedInstanceData instanceof GroupInstance) { + this.updateGroupInstanceProperty(checkedProperty); + } } updateInstanceProperty(instanceProperty: PropertyBEModel) { @@ -592,7 +600,21 @@ export class PropertiesAssignmentComponent { this.componentInstanceServiceNg2.updateInstanceProperties(this.component.componentType, this.component.uniqueId, this.selectedInstanceData.uniqueId, [instanceProperty]) .subscribe(() => { - this.changeSelectedInstance(this.getSelectedComponentInstance()); + this.changeSelectedInstance(this.getSelectedInstance()); + }, (error) => { + this.loadingProperties = false; + console.error(error); + }, () => { + this.loadingProperties = false; + }); + } + + updateGroupInstanceProperty(instanceProperty: PropertyBEModel) { + this.loadingProperties = true; + this.componentInstanceServiceNg2.updateComponentGroupInstanceProperties(this.component.componentType, this.component.uniqueId, + this.selectedInstanceData.uniqueId, [instanceProperty]) + .subscribe(() => { + this.changeSelectedInstance(this.getSelectedInstance()); }, (error) => { this.loadingProperties = false; console.error(error); -- 2.16.6