diff options
author | aribeiro <anderson.ribeiro@est.tech> | 2021-10-15 13:41:39 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2021-10-19 13:53:09 +0000 |
commit | cef866edcf8a14ede6762297dd9ab04b1f3d0375 (patch) | |
tree | d6ce40b7f5924f3c3cddf3bf10acdb789ff58ea3 /catalog-ui/src/app/ng2 | |
parent | 5a59bf1544c7c9d1eee0cdddcbedc8c0d1d1bb8c (diff) |
Support get_input for complex data types
Issue-ID: SDC-3760
Signed-off-by: aribeiro <anderson.ribeiro@est.tech>
Change-Id: I68ceaa47012186533a90f06c2688454f5dde799b
Diffstat (limited to 'catalog-ui/src/app/ng2')
4 files changed, 44 insertions, 12 deletions
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 @@ <form class="w-sdc-form"> <div class="i-sdc-form-item"> <label class="i-sdc-form-label required">Input Value</label> - <select [(ngModel)]="selectInputValue" name="selectInputValue"> - <option *ngFor="let index of inputModel" - [ngValue]="index">{{index.name}}</option> - </select> + <select [(ngModel)]="selectInputValue" name="selectInputValue"> + <option *ngFor="let input of inputs" + [ngValue]="input">{{input.name}}</option> + </select> </div> </form> </div> 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<InputBEModel> = []; isLoading: boolean; propertyType: string; + inputs: Array<PropertyBEModel> = []; + private dataTypeProperties: Array<PropertyBEModel> = []; 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(); |