diff options
author | MichaelMorris <michael.morris@est.tech> | 2022-07-19 13:28:40 +0100 |
---|---|---|
committer | MichaelMorris <michael.morris@est.tech> | 2022-07-19 13:31:51 +0100 |
commit | efdde52c76b16160fa3244834838f13977bb53c5 (patch) | |
tree | bd096bf9ada070e6cffc8ac14aab75090b6a12ad /catalog-ui | |
parent | 68733163804ed2efed8223a04ab0a7a0714a8b33 (diff) |
Support tosca functions for group instances
Issue-ID: SDC-4090
Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech>
Change-Id: I91650050fed57a4243df157034cb68ecd8421413
Signed-off-by: MichaelMorris <michael.morris@est.tech>
Diffstat (limited to 'catalog-ui')
-rw-r--r-- | catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts | 34 |
1 files 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 <ComponentInstance> this.instances.find(instance => instance.uniqueId == instanceId && instance instanceof ComponentInstance); + return <ComponentInstance | GroupInstance> 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); |