diff options
author | franciscovila <javier.paradela.vila@est.tech> | 2023-03-21 16:54:46 +0000 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2023-05-25 09:26:35 +0000 |
commit | 468d0770593e167990df815e45cde717bd845d18 (patch) | |
tree | f4f6fd1838bdca5afa60295726acdd41de677980 /catalog-ui/src/app | |
parent | 871b9813322801509a566b49a1cdcc65c052de29 (diff) |
Support TOSCA functions in operation inputs
Issue-ID: SDC-4442
Signed-off-by: franciscovila <javier.paradela.vila@est.tech>
Change-Id: I1e6135da6f41d512a7758d5494df12da874d7146
Diffstat (limited to 'catalog-ui/src/app')
4 files changed, 29 insertions, 8 deletions
diff --git a/catalog-ui/src/app/models/tosca-get-function.ts b/catalog-ui/src/app/models/tosca-get-function.ts index 67d9b0a836..784c7ea407 100644 --- a/catalog-ui/src/app/models/tosca-get-function.ts +++ b/catalog-ui/src/app/models/tosca-get-function.ts @@ -71,22 +71,34 @@ export class ToscaGetFunction implements ToscaFunction, ToscaFunctionParameter { private buildGetInputFunctionValue(): Object { if (this.propertyPathFromSource.length === 1) { - return {[this.functionType.toLowerCase()]: [this.propertyPathFromSource[0], this.toscaIndexList]}; + if (this.toscaIndexList) { + return {[this.functionType.toLowerCase()]: [this.propertyPathFromSource[0], this.toscaIndexList]}; + } + return {[this.functionType.toLowerCase()]: [this.propertyPathFromSource[0]]}; } return {[this.functionType.toLowerCase()]: [this.propertyPathFromSource, this.toscaIndexList]}; } private buildFunctionValueWithPropertySource(): Object { if (this.propertySource == PropertySource.SELF) { + if (this.toscaIndexList) { + return { + [this.functionType.toLowerCase()]: [PropertySource.SELF, ...this.propertyPathFromSource, this.toscaIndexList] + }; + } return { - [this.functionType.toLowerCase()]: [PropertySource.SELF, ...this.propertyPathFromSource, this.toscaIndexList] + [this.functionType.toLowerCase()]: [PropertySource.SELF, ...this.propertyPathFromSource] }; } if (this.propertySource == PropertySource.INSTANCE) { + if (this.toscaIndexList) { + return { + [this.functionType.toLowerCase()]: [this.sourceName, ...this.propertyPathFromSource, this.toscaIndexList] + }; + } return { - [this.functionType.toLowerCase()]: [this.sourceName, ...this.propertyPathFromSource,this.toscaIndexList] + [this.functionType.toLowerCase()]: [this.sourceName, ...this.propertyPathFromSource] }; } } - }
\ No newline at end of file diff --git a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.html b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.html index 44db3b0d00..3824d75055 100644 --- a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.html +++ b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.html @@ -102,7 +102,7 @@ [name]="property.name" [type]="getDataType(property.type)" [dataTypeMap]="dataTypeMap" - [valueObjRef]="valueObjRef[property.name]" + [valueObjRef]="valueObjRef ? valueObjRef[property.name] : undefined" [schema]="property.schema" [nestingLevel]="nestingLevel + 1" [isViewOnly]="isViewOnly" diff --git a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.html b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.html index 8ab1b97cda..cf9a04ae0a 100644 --- a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.html +++ b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.html @@ -130,6 +130,8 @@ [dataTypeMap]="dataTypeMap" [isViewOnly]="isViewOnly" [allowDeletion]="true" + [componentInstanceMap]="componentInstanceMap" + [showToscaFunctionOption]="true" (onValueChange)="onInputValueChange($event)" (onDelete)="onInputDelete($event)" > diff --git a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts index ab9cad0a39..4ceaa78148 100644 --- a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts +++ b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts @@ -138,8 +138,10 @@ export class InterfaceOperationHandlerComponent { private initCustomToscaFunctions() { this.customToscaFunctions = []; this.topologyTemplateService.getDefaultCustomFunction().toPromise().then((data) => { - for (let customFunction of data) { - this.customToscaFunctions.push(new CustomToscaFunction(customFunction)); + if (data) { + for (let customFunction of data) { + this.customToscaFunctions.push(new CustomToscaFunction(customFunction)); + } } }); } @@ -299,7 +301,12 @@ export class InterfaceOperationHandlerComponent { changedInput.value = JSON.stringify(changedInput.value); } const inputOperationParameter = this.inputs.find(value => value.name == changedInput.name); + inputOperationParameter.toscaFunction = null; inputOperationParameter.value = changedInput.value; + if (changedInput.isToscaFunction()) { + inputOperationParameter.toscaFunction = changedInput.toscaFunction; + inputOperationParameter.value = changedInput.toscaFunction.buildValueString(); + } } onArtifactPropertyValueChange(changedProperty: InputOperationParameter) { @@ -345,7 +352,7 @@ export class InterfaceOperationHandlerComponent { const input1 = currentInputs.find(value => value.name === inputName); const indexOfInput = currentInputs.indexOf(input1); if (indexOfInput === -1) { - console.error(`Could delete input '${inputName}'. Input not found.`); + console.error(`Could not delete input '${inputName}'. Input not found.`); return; } currentInputs.splice(currentInputs.indexOf(input1), 1); |