From 3f48762a391733561bb1ed171ea0a15bf0ea50ee Mon Sep 17 00:00:00 2001 From: vasraz Date: Tue, 30 Aug 2022 18:17:21 +0100 Subject: Allow to select properties in the get_attribute function Signed-off-by: Vasyl Razinkov Change-Id: Ib35d5d1e3d83ed8e87ce45c20e9cc1a641c5bde2 Issue-ID: SDC-4149 --- catalog-ui/src/app/models.ts | 16 +++++++----- .../tosca-get-function.component.ts | 30 +++++++++++----------- .../topology-template.service.ts | 4 +++ 3 files changed, 29 insertions(+), 21 deletions(-) (limited to 'catalog-ui/src/app') diff --git a/catalog-ui/src/app/models.ts b/catalog-ui/src/app/models.ts index 7604b6797b..d2019426b0 100644 --- a/catalog-ui/src/app/models.ts +++ b/catalog-ui/src/app/models.ts @@ -18,10 +18,6 @@ * ============LICENSE_END========================================================= */ -/** - * Created by ob0695 on 2/23/2017. - */ -import from = require("core-js/fn/array/from"); export * from './models/activity'; export * from './models/additional-information'; export * from './models/app-config'; @@ -48,7 +44,6 @@ export * from './models/graph/zones/policy-instance'; export * from './models/graph/zones/zone'; export * from './models/graph/zones/zone-instance'; export * from './models/csar-component'; -//export * from './models/data-type-properties'; export * from './models/properties-inputs/property-be-model'; export * from './models/properties-inputs/property-fe-model'; export * from './models/properties-inputs/property-fe-map'; @@ -57,6 +52,15 @@ export * from './models/properties-inputs/property-declare-api-model'; export * from './models/properties-inputs/property-input-detail'; export * from './models/properties-inputs/input-fe-model'; export * from './models/properties-inputs/simple-flat-property'; +export * from './models/attributes-outputs/attribute-be-model'; +export * from './models/attributes-outputs/attribute-fe-model'; +export * from './models/attributes-outputs/attribute-fe-map'; +export * from './models/attributes-outputs/attribute-output-detail'; +export * from './models/attributes-outputs/attribute-declare-api-model'; +export * from './models/attributes-outputs/derived-fe-attribute'; +export * from './models/attributes-outputs/output-be-model'; +export * from './models/attributes-outputs/output-fe-model'; +export * from './models/attributes-outputs/simple-flat-attribute'; export * from './models/data-types-map'; export * from './models/data-types'; export * from './models/distribution'; @@ -128,4 +132,4 @@ export * from './models/relationship-types'; export * from './models/tosca-presentation'; export * from './models/node-types'; export * from './models/capability-types'; -export * from './models/service-csar'; \ No newline at end of file +export * from './models/service-csar'; diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts index 8f50cc14cd..64d155a55f 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts @@ -18,7 +18,7 @@ */ import {Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges} from '@angular/core'; -import {AttributeModel, ComponentMetadata, DataTypeModel, PropertyBEModel, PropertyModel} from 'app/models'; +import {AttributeBEModel, ComponentMetadata, DataTypeModel, PropertyBEModel, PropertyModel} from 'app/models'; import {TopologyTemplateService} from "../../../../services/component-services/topology-template.service"; import {WorkspaceService} from "../../../workspace/workspace.service"; import {PropertiesService} from "../../../../services/properties.service"; @@ -224,7 +224,7 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges { this.startLoading(); const propertiesObservable: Observable = this.getPropertyObservable(); propertiesObservable.subscribe( (response: ComponentGenericResponse) => { - const properties: Array = this.extractProperties(response); + const properties: Array = this.extractProperties(response); if (!properties || properties.length === 0) { const msgCode = this.getNotFoundMsgCode(); this.dropDownErrorMsg = this.translateService.translate(msgCode, {type: this.propertyTypeToString()}); @@ -267,22 +267,22 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges { return this.property.type; } - private extractProperties(componentGenericResponse: ComponentGenericResponse): Array { + private extractProperties(componentGenericResponse: ComponentGenericResponse): Array { if (this.isGetInput()) { return componentGenericResponse.inputs; } - const propertySource = this.propertySource.value; + const instanceId = this.instanceNameAndIdMap.get(this.propertySource.value); if (this.isGetProperty()) { if (this.isPropertySourceSelf()) { return componentGenericResponse.properties; } - const componentInstanceProperties: PropertyModel[] = componentGenericResponse.componentInstancesProperties[this.instanceNameAndIdMap.get(propertySource)]; - return this.removeSelectedProperty(componentInstanceProperties); + return this.removeSelectedProperty(componentGenericResponse.componentInstancesProperties[instanceId]); } if (this.isPropertySourceSelf()) { - return componentGenericResponse.attributes; + return [...(componentGenericResponse.attributes || []), ...(componentGenericResponse.properties || [])]; } - return componentGenericResponse.componentInstancesAttributes[this.instanceNameAndIdMap.get(propertySource)]; + return [...(componentGenericResponse.componentInstancesAttributes[instanceId] || []), + ...(componentGenericResponse.componentInstancesProperties[instanceId] || [])]; } private isPropertySourceSelf() { @@ -301,9 +301,9 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges { } if (this.isGetAttribute()) { if (this.isPropertySourceSelf()) { - return this.topologyTemplateService.findAllComponentAttributes(this.componentMetadata.componentType, this.componentMetadata.uniqueId); + return this.topologyTemplateService.findAllComponentAttributesAndProperties(this.componentMetadata.componentType, this.componentMetadata.uniqueId); } - return this.topologyTemplateService.findAllComponentInstanceAttributes(this.componentMetadata.componentType, this.componentMetadata.uniqueId); + return this.topologyTemplateService.getComponentInstanceAttributesAndProperties(this.componentMetadata.uniqueId, this.componentMetadata.componentType); } } @@ -322,7 +322,7 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges { this.propertyDropdownList.sort((a, b) => a.propertyLabel.localeCompare(b.propertyLabel)); } - private addPropertiesToDropdown(properties: Array): void { + private addPropertiesToDropdown(properties: Array): void { for (const property of properties) { if (this.hasSameType(property)) { this.addPropertyToDropdown({ @@ -337,8 +337,8 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges { } } - private fillPropertyDropdownWithMatchingChildProperties(inputProperty: PropertyBEModel | AttributeModel, - parentPropertyList: Array = []): void { + private fillPropertyDropdownWithMatchingChildProperties(inputProperty: PropertyBEModel | AttributeBEModel, + parentPropertyList: Array = []): void { const dataTypeFound: DataTypeModel = this.dataTypeService.getDataTypeByModelAndTypeName(this.componentMetadata.model, inputProperty.type); if (!dataTypeFound || !dataTypeFound.properties) { return; @@ -358,7 +358,7 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges { }); } - private hasSameType(property: PropertyBEModel | AttributeModel) { + private hasSameType(property: PropertyBEModel | AttributeBEModel) { if (this.typeHasSchema(this.property.type)) { if (!property.schema || !property.schema.property) { return false; @@ -440,4 +440,4 @@ export interface PropertyDropdownValue { export interface ToscaGetFunctionValidationEvent { isValid: boolean, toscaGetFunction: ToscaGetFunction, -} \ No newline at end of file +} diff --git a/catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts b/catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts index a2abb38f65..c497e013b4 100644 --- a/catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts +++ b/catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts @@ -163,6 +163,10 @@ export class TopologyTemplateService { return this.getComponentDataByFieldsName(componentType, componentUniqueId, [COMPONENT_FIELDS.COMPONENT_ATTRIBUTES]); } + findAllComponentAttributesAndProperties(componentType: string, componentUniqueId: string): Observable { + return this.getComponentDataByFieldsName(componentType, componentUniqueId, [COMPONENT_FIELDS.COMPONENT_ATTRIBUTES, COMPONENT_FIELDS.COMPONENT_PROPERTIES]); + } + getCapabilitiesAndRequirements(componentType: string, componentId: string): Observable { return this.getComponentDataByFieldsName(componentType, componentId, [COMPONENT_FIELDS.COMPONENT_REQUIREMENTS, COMPONENT_FIELDS.COMPONENT_CAPABILITIES]); } -- cgit 1.2.3-korg