From aa948a8d914d3e30018a52bbbec4c7dbe408e9da Mon Sep 17 00:00:00 2001 From: MichaelMorris Date: Thu, 4 Aug 2022 11:13:54 +0100 Subject: Property assignment view policy tosca function Enable setting policy properties to a TOSCA function value expression in the property assignment view Signed-off-by: MichaelMorris Issue-ID: SDC-4122 Change-Id: Idd6b08c31995f5f421213075a3981f58edca2f9c --- .../properties-assignment.page.component.ts | 25 +++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 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 6474b15df0..557365592f 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,18 @@ export class PropertiesAssignmentComponent { * Select Tosca function value from defined values */ selectToscaFunctionAndValues = (): void => { - const selectedInstanceData: ComponentInstance | GroupInstance = this.getSelectedInstance(); + const selectedInstanceData: ComponentInstance | GroupInstance | PolicyInstance = this.getSelectedInstance(); if (!selectedInstanceData) { return; } this.openToscaGetFunctionModal(); } - private getSelectedInstance(): ComponentInstance | GroupInstance { + private getSelectedInstance(): ComponentInstance | GroupInstance | PolicyInstance { const instancesIds = this.keysPipe.transform(this.instanceFePropertiesMap, []); const instanceId: string = instancesIds[0]; - return this.instances.find(instance => instance.uniqueId == instanceId && instance instanceof ComponentInstance || instance instanceof GroupInstance); + return this.instances.find(instance => + instance.uniqueId == instanceId && instance instanceof ComponentInstance || instance instanceof GroupInstance || instance instanceof PolicyInstance); } private buildCheckedInstanceProperty(): PropertyBEModel { @@ -582,6 +583,8 @@ export class PropertiesAssignmentComponent { this.updateInstanceProperty(checkedInstanceProperty); } else if (this.selectedInstanceData instanceof GroupInstance) { this.updateGroupInstanceProperty(checkedInstanceProperty); + } else if (this.selectedInstanceData instanceof PolicyInstance) { + this.updatePolicyInstanceProperty(checkedInstanceProperty); } } @@ -592,6 +595,8 @@ export class PropertiesAssignmentComponent { this.updateInstanceProperty(checkedProperty); } else if (this.selectedInstanceData instanceof GroupInstance) { this.updateGroupInstanceProperty(checkedProperty); + } else if (this.selectedInstanceData instanceof PolicyInstance) { + this.updatePolicyInstanceProperty(checkedProperty); } } @@ -623,6 +628,20 @@ export class PropertiesAssignmentComponent { }); } + updatePolicyInstanceProperty(instanceProperty: PropertyBEModel) { + this.loadingProperties = true; + this.componentInstanceServiceNg2.updateComponentPolicyInstanceProperties(this.component.componentType, this.component.uniqueId, + this.selectedInstanceData.uniqueId, [instanceProperty]) + .subscribe(() => { + this.changeSelectedInstance(this.getSelectedInstance()); + }, (error) => { + this.loadingProperties = false; + console.error(error); + }, () => { + this.loadingProperties = false; + }); + } + /*** DECLARE PROPERTIES/INPUTS ***/ declareProperties = (): void => { console.debug("==>" + this.constructor.name + ": declareProperties"); -- cgit 1.2.3-korg