From 26e5029d922779fd7e786c1a31b6b37492132388 Mon Sep 17 00:00:00 2001 From: vasraz Date: Tue, 16 Feb 2021 17:37:57 +0000 Subject: Implement Attributes/Outputs FE Change-Id: I014bb0ebc07f3fea4266a4f295172eadee546705 Signed-off-by: Vasyl Razinkov Issue-ID: SDC-3448 --- .../topology-template.service.ts | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts') 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 953f0a1960..0249912862 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 @@ -70,6 +70,8 @@ import { ComponentInstanceInterfaceModel, InterfaceOperationModel } from "../../../models/interfaceOperation"; +import {AttributeBEModel} from "../../../models/attributes-outputs/attribute-be-model"; +import {InstanceAttributesAPIMap} from "../../../models/attributes-outputs/attribute-fe-map"; /* we need to use this service from now, we will remove component.service when we finish remove the angular1. The service is duplicated since we can not use downgrades service with NGXS*/ @@ -126,6 +128,11 @@ export class TopologyTemplateService { [COMPONENT_FIELDS.COMPONENT_INPUTS, COMPONENT_FIELDS.COMPONENT_INSTANCES, COMPONENT_FIELDS.COMPONENT_INSTANCES_PROPERTIES, COMPONENT_FIELDS.COMPONENT_PROPERTIES]); } + getComponentOutputsWithAttributes(componentType: string, componentId: string): Observable { + return this.getComponentDataByFieldsName(componentType, componentId, + [COMPONENT_FIELDS.COMPONENT_OUTPUTS, COMPONENT_FIELDS.COMPONENT_INSTANCES, COMPONENT_FIELDS.COMPONENT_INSTANCES_ATTRIBUTES, COMPONENT_FIELDS.COMPONENT_ATTRIBUTES,COMPONENT_FIELDS.COMPONENT_INSTANCES_OUTPUTS]); + } + getComponentDeploymentArtifacts(component: Component): Observable { return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_DEPLOYMENT_ARTIFACTS]); } @@ -164,6 +171,11 @@ export class TopologyTemplateService { return this.http.post(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/create/inputs', inputs); } + createOutput(component: Component, outputsToCreate: InstanceAttributesAPIMap, isSelf: boolean): Observable { + const outputs = isSelf ? { serviceProperties: outputsToCreate.componentInstanceAttributes } : outputsToCreate; + return this.http.post(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/create/outputs', outputs); + } + restoreComponent(componentType: string, componentId: string) { return this.http.post(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/restore', {}); } @@ -206,6 +218,16 @@ export class TopologyTemplateService { }); } + createServiceAttribute(componentId: string, attributeModel: AttributeBEModel): Observable { + const serverObject = {}; + serverObject[attributeModel.name] = attributeModel; + return this.http.post(this.baseUrl + 'services/' + componentId + '/attributes', serverObject) + .map((res) => { + const attribute: AttributeBEModel = new AttributeBEModel(res); + return attribute; + }); + } + getServiceProperties(componentId: string): Observable { return this.http.get(this.baseUrl + 'services/' + componentId + '/properties') .map((res) => { @@ -216,6 +238,16 @@ export class TopologyTemplateService { }); } + getServiceAttributes(componentId: string): Observable { + return this.http.get(this.baseUrl + 'services/' + componentId + '/attributes') + .map((res) => { + if (!res) { + return new Array(); + } + return CommonUtils.initAttributes(res); + }); + } + updateServiceProperties(componentId: string, properties: PropertyBEModel[]) { return this.http.put( this.baseUrl + 'services/' + componentId + '/properties', properties) .map((res) => { @@ -225,6 +257,15 @@ export class TopologyTemplateService { }); } + updateServiceAttributes(componentId: string, attributes: AttributeBEModel[]) { + return this.http.put( this.baseUrl + 'services/' + componentId + '/attributes', attributes) + .map((res) => { + const resJson = res; + return _.map(resJson, + (resValue: AttributeBEModel) => new AttributeBEModel(resValue)); + }); + } + deleteServiceProperty(componentId: string, property: PropertyBEModel): Observable { return this.http.delete(this.baseUrl + 'services/' + componentId + '/properties/' + property.uniqueId ) .map((res: Response) => { @@ -242,6 +283,13 @@ export class TopologyTemplateService { }); } + deleteServiceAttribute(componentId: string, attribute: AttributeBEModel): Observable { + return this.http.delete(this.baseUrl + 'services/' + componentId + '/attributes/' + attribute.uniqueId ) + .map((res: Response) => { + return attribute.uniqueId; + }); + } + getDependencies(componentType: string, componentId: string): Observable { return this.http.get(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/dependencies'); } -- cgit 1.2.3-korg