From cef866edcf8a14ede6762297dd9ab04b1f3d0375 Mon Sep 17 00:00:00 2001 From: aribeiro Date: Fri, 15 Oct 2021 13:41:39 +0100 Subject: Support get_input for complex data types Issue-ID: SDC-3760 Signed-off-by: aribeiro Change-Id: I68ceaa47012186533a90f06c2688454f5dde799b --- .../input-list/input-list.component.html | 8 ++--- .../input-list/input-list.component.ts | 35 +++++++++++++++++----- .../properties-assignment.page.component.ts | 4 ++- .../src/app/ng2/services/data-type.service.ts | 9 ++++++ 4 files changed, 44 insertions(+), 12 deletions(-) (limited to 'catalog-ui/src') diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/input-list/input-list.component.html b/catalog-ui/src/app/ng2/pages/properties-assignment/input-list/input-list.component.html index e0804637c6..b61d25cb25 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/input-list/input-list.component.html +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/input-list/input-list.component.html @@ -22,10 +22,10 @@
- +
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/input-list/input-list.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/input-list/input-list.component.ts index 64ebcaa540..0bdd028d93 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/input-list/input-list.component.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/input-list/input-list.component.ts @@ -18,10 +18,14 @@ */ import {Component} from '@angular/core'; -import {InputBEModel, ComponentMetadata} from 'app/models'; +import { + ComponentMetadata, DataTypeModel, PropertyBEModel +} from 'app/models'; import {TopologyTemplateService} from "../../../services/component-services/topology-template.service"; import {WorkspaceService} from "../../workspace/workspace.service"; import {PropertiesService} from "../../../services/properties.service"; +import {PROPERTY_DATA} from "../../../../utils/constants"; +import {DataTypeService} from "../../../services/data-type.service"; @Component({ selector: 'input-list', @@ -32,16 +36,18 @@ import {PropertiesService} from "../../../services/properties.service"; export class InputListComponent { selectInputValue; - inputModel: Array = []; isLoading: boolean; propertyType: string; + inputs: Array = []; + private dataTypeProperties: Array = []; private componentMetadata: ComponentMetadata; constructor(private topologyTemplateService: TopologyTemplateService, private workspaceService: WorkspaceService, - private propertiesService: PropertiesService - ) {} + private propertiesService: PropertiesService, + private dataTypeService: DataTypeService) { + } ngOnInit() { this.componentMetadata = this.workspaceService.metadata; @@ -53,9 +59,11 @@ export class InputListComponent { this.isLoading = true; this.topologyTemplateService.getComponentInputsValues(this.componentMetadata.componentType, this.componentMetadata.uniqueId) .subscribe((response) => { - response.inputs.forEach((input: any) => { - if (input.type === propertyType) { - this.inputModel.push(input); + response.inputs.forEach((inputProperty: any) => { + if (propertyType === inputProperty.type) { + this.inputs.push(inputProperty); + } else if (PROPERTY_DATA.SIMPLE_TYPES.indexOf(inputProperty.type) === -1 && inputProperty.type !== propertyType) { + this.buildInputDataForComplexType(inputProperty, propertyType); } }); }, () => { @@ -64,4 +72,17 @@ export class InputListComponent { this.isLoading = false; }); } + + private buildInputDataForComplexType(inputProperty: PropertyBEModel, propertyType: string) { + let dataTypeFound: DataTypeModel = this.dataTypeService.getDataTypeByModelAndTypeName(this.componentMetadata.model, inputProperty.type); + if (dataTypeFound && dataTypeFound.properties) { + dataTypeFound.properties.forEach(dataTypeProperty => { + let inputData = inputProperty.name + "->" + dataTypeProperty.name; + dataTypeProperty.name = inputData; + if (this.dataTypeProperties.indexOf(dataTypeProperty) === -1 && dataTypeProperty.type === propertyType) { + this.inputs.push(dataTypeProperty); + } + }); + } + } } 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 8e483ea5ef..09fd888755 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 @@ -527,7 +527,9 @@ export class PropertiesAssignmentComponent { propertyInputDetail.inputName = selectInputValue.name; propertyInputDetail.inputType = selectInputValue.type; property.getInputValues.push(propertyInputDetail); - property.value = '{"get_input":"' + selectInputValue.name + '"}'; + property.value = selectInputValue.name.indexOf("->") !== -1 + ? '{"get_input":[' + selectInputValue.name.replace("->", ", ") + ']}' + : '{"get_input":"' + selectInputValue.name+ '"}' ; property.toscaGetFunctionType = ToscaGetFunctionType.GET_INPUT; this.updateInstancePropertiesWithInput(checkedProperties, selectedInstanceData); modal.instance.close(); diff --git a/catalog-ui/src/app/ng2/services/data-type.service.ts b/catalog-ui/src/app/ng2/services/data-type.service.ts index 85c8b898aa..5b08e9323f 100644 --- a/catalog-ui/src/app/ng2/services/data-type.service.ts +++ b/catalog-ui/src/app/ng2/services/data-type.service.ts @@ -39,6 +39,15 @@ export class DataTypeService { this.dataTypes = dataTypeService.getAllDataTypes(); //This should eventually be replaced by an NG2 call to the backend instead of utilizing Angular1 downgraded component. } + public getDataTypeByModelAndTypeName(modelName: string, typeName: string): DataTypeModel { + this.dataTypes = this.dataTypeService.getAllDataTypesFromModel(modelName); + let dataTypeFound = this.dataTypes[typeName]; + if (!dataTypeFound) { + console.log("MISSING Datatype for model " + modelName + " and type: " + typeName); + } + return dataTypeFound; + } + public getDataTypeByTypeName(typeName: string): DataTypeModel { if(!this.dataTypes){ this.dataTypes = this.dataTypeService.getAllDataTypes(); -- cgit 1.2.3-korg