2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021 Nordix Foundation
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 * SPDX-License-Identifier: Apache-2.0
17 * ============LICENSE_END=========================================================
20 import {Component} from '@angular/core';
22 ComponentMetadata, DataTypeModel, PropertyBEModel
24 import {TopologyTemplateService} from "../../../services/component-services/topology-template.service";
25 import {WorkspaceService} from "../../workspace/workspace.service";
26 import {PropertiesService} from "../../../services/properties.service";
27 import {PROPERTY_DATA} from "../../../../utils/constants";
28 import {DataTypeService} from "../../../services/data-type.service";
31 selector: 'input-list',
32 templateUrl: './input-list.component.html',
33 styleUrls: ['./input-list.component.less'],
36 export class InputListComponent {
41 inputs: Array<PropertyBEModel> = [];
43 private dataTypeProperties: Array<PropertyBEModel> = [];
44 private componentMetadata: ComponentMetadata;
46 constructor(private topologyTemplateService: TopologyTemplateService,
47 private workspaceService: WorkspaceService,
48 private propertiesService: PropertiesService,
49 private dataTypeService: DataTypeService) {
53 this.componentMetadata = this.workspaceService.metadata;
54 this.propertyType = this.propertiesService.getCheckedPropertyType();
55 this.loadInputValues(this.propertyType);
58 private loadInputValues(propertyType: string): void {
59 this.isLoading = true;
60 this.topologyTemplateService.getComponentInputsValues(this.componentMetadata.componentType, this.componentMetadata.uniqueId)
61 .subscribe((response) => {
62 response.inputs.forEach((inputProperty: any) => {
63 if (propertyType === inputProperty.type) {
64 this.inputs.push(inputProperty);
65 } else if (PROPERTY_DATA.SIMPLE_TYPES.indexOf(inputProperty.type) === -1 && inputProperty.type !== propertyType) {
66 this.buildInputDataForComplexType(inputProperty, propertyType);
72 this.isLoading = false;
76 private buildInputDataForComplexType(inputProperty: PropertyBEModel, propertyType: string) {
77 let dataTypeFound: DataTypeModel = this.dataTypeService.getDataTypeByModelAndTypeName(this.componentMetadata.model, inputProperty.type);
78 if (dataTypeFound && dataTypeFound.properties) {
79 dataTypeFound.properties.forEach(dataTypeProperty => {
80 let inputData = inputProperty.name + "->" + dataTypeProperty.name;
81 dataTypeProperty.name = inputData;
82 if (this.dataTypeProperties.indexOf(dataTypeProperty) === -1 && dataTypeProperty.type === propertyType) {
83 this.inputs.push(dataTypeProperty);