X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=catalog-ui%2Fsrc%2Fapp%2Fng2%2Fservices%2Fcomponent-services%2Ftopology-template.service.ts;h=0af8c737de9342bf9fd3b38c610b3b07dbac6be8;hb=ec5c8fddfb0ba0e40b19cd438533114652448d0f;hp=49f273c7161babbe041d26080fe744183177ba76;hpb=c2fa1b7e8d43a236219d1f6ad2831de1af296cb4;p=sdc.git 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 49f273c716..0af8c737de 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 @@ -6,6 +6,7 @@ * SDC * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modification Copyright (C) 2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,27 +23,28 @@ */ import * as _ from "lodash"; -import {Injectable, Inject} from '@angular/core'; +import {Inject, Injectable} from '@angular/core'; import {Observable} from 'rxjs/Observable'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/toPromise'; import { + ArtifactModel, + AttributeModel, + Capability, Component, + FilterPropertiesAssignmentData, + IFileDownload, InputBEModel, InstancePropertiesAPIMap, - FilterPropertiesAssignmentData, - ArtifactModel, + OperationModel, PropertyModel, - IFileDownload, - AttributeModel, - Capability, Requirement, BEOperationModel, InterfaceModel + Requirement } from "app/models"; -import {ArtifactGroupType, COMPONENT_FIELDS} from "app/utils"; +import {API_QUERY_PARAMS, ArtifactGroupType, COMPONENT_FIELDS} from "app/utils"; import {ComponentGenericResponse} from "../responses/component-generic-response"; import {InstanceBePropertiesMap} from "../../../models/properties-inputs/property-fe-map"; -import {API_QUERY_PARAMS} from "app/utils"; import {ComponentType, ServerTypeUrl, SERVICE_FIELDS} from "../../../utils/constants"; -import {SdcConfigToken, ISdcConfig} from "../../config/sdc-config.config"; +import {ISdcConfig, SdcConfigToken} from "../../config/sdc-config.config"; import {IDependenciesServerResponse} from "../responses/dependencies-server-response"; import {AutomatedUpgradeGenericResponse} from "../responses/automated-upgrade-response"; import {IAutomatedUpgradeRequestObj} from "../../pages/automated-upgrade/automated-upgrade.service"; @@ -50,28 +52,17 @@ import {ComponentInstance} from "../../../models/componentsInstances/componentIn import {CommonUtils} from "../../../utils/common-utils"; import {RelationshipModel} from "../../../models/graph/relationship"; import {ServiceGenericResponse} from "../responses/service-generic-response"; -import { HttpClient, HttpParams, HttpHeaders } from "@angular/common/http"; -import { HttpHelperService } from "../http-hepler.service"; -import { - Component as TopologyTemplate, - FullComponentInstance, - Service, - OperationModel, -} from 'app/models'; -import { ConsumptionInput } from "../../components/logic/service-consumption/service-consumption.component"; -import { ConstraintObject } from "../../components/logic/service-dependencies/service-dependencies.component"; -import { ComponentMetadata } from "../../../models/component-metadata"; -import { PolicyInstance } from "../../../models/graph/zones/policy-instance"; -import { PropertyBEModel } from "../../../models/properties-inputs/property-be-model"; +import {HttpClient, HttpHeaders, HttpParams} from "@angular/common/http"; +import {HttpHelperService} from "../http-hepler.service"; +import {ConsumptionInput} from "../../components/logic/service-consumption/service-consumption.component"; +import {PolicyInstance} from "../../../models/graph/zones/policy-instance"; +import {PropertyBEModel} from "../../../models/properties-inputs/property-be-model"; import {map} from "rxjs/operators"; -import {CapabilitiesConstraintObject} from "../../components/logic/capabilities-constraint/capabilities-constraint.component"; -import { - BEInterfaceOperationModel, - ComponentInstanceInterfaceModel, - InterfaceOperationModel -} from "../../../models/interfaceOperation"; +import {BEInterfaceOperationModel, InterfaceOperationModel} from "../../../models/interfaceOperation"; import {AttributeBEModel} from "../../../models/attributes-outputs/attribute-be-model"; import {InstanceAttributesAPIMap} from "../../../models/attributes-outputs/attribute-fe-map"; +import {FilterConstraint} from "../../../models/filter-constraint"; +import {CustomToscaFunction, DefaultCustomFunctions} from "../../../models/default-custom-functions"; /* 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*/ @@ -85,6 +76,16 @@ export class TopologyTemplateService { this.baseUrl = sdcConfig.api.root + sdcConfig.api.component_api_root; } + putServiceToscaTemplate(componentId: string, componentType: string, file) { + return this.http.put(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/toscaTemplate', file) + } + + putServiceToscaModel(componentId: string, componentType: string, file) { + let uploadData:FormData = new FormData(); + uploadData.append('upload', file); + return this.http.put(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/toscaModel', uploadData); + } + getFullComponent(componentType: string, uniqueId: string): Observable { return this.http.get(this.baseUrl + this.getServerTypeUrl(componentType) + uniqueId); } @@ -97,6 +98,10 @@ export class TopologyTemplateService { return this.getComponentDataByFieldsName(type, uniqueId, [COMPONENT_FIELDS.COMPONENT_INSTANCES_PROPERTIES, COMPONENT_FIELDS.COMPONENT_INSTANCES_ATTRIBUTES]); } + getComponentInstanceAttributesAndPropertiesAndInputs(uniqueId: string, type: string): Observable { + return this.getComponentDataByFieldsName(type, uniqueId, [COMPONENT_FIELDS.COMPONENT_INSTANCES_PROPERTIES, COMPONENT_FIELDS.COMPONENT_INSTANCES_ATTRIBUTES, COMPONENT_FIELDS.COMPONENT_INPUTS]); + } + async getComponentAttributes(componentType: string, componentId: string): Promise { return this.getComponentDataByFieldsName(componentType, componentId, [COMPONENT_FIELDS.COMPONENT_ATTRIBUTES]).toPromise(); } @@ -158,7 +163,19 @@ export class TopologyTemplateService { } getComponentProperties(component: Component): Observable { - return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_PROPERTIES]); + return this.findAllComponentProperties(component.componentType, component.uniqueId); + } + + findAllComponentProperties(componentType: string, componentUniqueId: string): Observable { + return this.getComponentDataByFieldsName(componentType, componentUniqueId, [COMPONENT_FIELDS.COMPONENT_PROPERTIES]); + } + + findAllComponentAttributes(componentType: string, componentUniqueId: string): Observable { + 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 { @@ -385,7 +402,7 @@ export class TopologyTemplateService { } updateProperty = (componentType: string, componentId: string, property: PropertyModel): Observable => { - var propertiesList:PropertyBEModel[] = [property]; + const propertiesList: PropertyBEModel[] = [property]; return this.http.put(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/properties', propertiesList) .map((response) => { return new PropertyModel(response[Object.keys(response)[0]]); @@ -462,24 +479,28 @@ export class TopologyTemplateService { return this.getComponentDataByFieldsName(componentType, componentId, [COMPONENT_FIELDS.COMPONENT_INSTANCES_PROPERTIES]); } + findAllComponentInstanceAttributes(componentType: string, componentId: string): Observable { + return this.getComponentDataByFieldsName(componentType, componentId, [COMPONENT_FIELDS.COMPONENT_INSTANCES_ATTRIBUTES]); + } + getComponentInstanceCapabilityProperties(componentType: string, componentId: string): Observable { return this.getComponentDataByFieldsName(componentType, componentId, [COMPONENT_FIELDS.COMPONENT_CAPABILITIES, COMPONENT_FIELDS.COMPONENT_CAPABILITIES_PROPERTIES]); } - createServiceFilterConstraints(componentMetaDataId: string, componentInstanceId: string, constraint: ConstraintObject, componentType: string, constraintType: string): Observable { + createServiceFilterConstraints(componentMetaDataId: string, componentInstanceId: string, constraint: FilterConstraint, componentType: string, constraintType: string): Observable { return this.http.post(this.baseUrl + this.getServerTypeUrl(componentType) + componentMetaDataId + '/componentInstance/' + componentInstanceId + '/' + constraintType + '/nodeFilter', constraint); } - createServiceFilterCapabilitiesConstraints(componentMetaDataId: string, componentInstanceId: string, constraint: CapabilitiesConstraintObject, componentType: string, constraintType: string): Observable { + createServiceFilterCapabilitiesConstraints(componentMetaDataId: string, componentInstanceId: string, constraint: FilterConstraint, componentType: string, constraintType: string): Observable { return this.http.post(this.baseUrl + this.getServerTypeUrl(componentType) + componentMetaDataId + '/componentInstance/' + componentInstanceId + '/' + constraintType + '/nodeFilter', constraint); } - updateServiceFilterConstraints(componentMetaDataId: string, componentInstanceId: string, constraints: ConstraintObject, componentType: string, constraintType: string, constraintIndex: number):Observable{ - return this.http.put(this.baseUrl + this.getServerTypeUrl(componentType) + componentMetaDataId + '/componentInstance/' + componentInstanceId + '/' + constraintType + '/' + constraintIndex + '/nodeFilter', constraints) + updateServiceFilterConstraints(componentMetaDataId: string, componentInstanceId: string, constraint: FilterConstraint, componentType: string, constraintType: string, constraintIndex: number):Observable{ + return this.http.put(this.baseUrl + this.getServerTypeUrl(componentType) + componentMetaDataId + '/componentInstance/' + componentInstanceId + '/' + constraintType + '/' + constraintIndex + '/nodeFilter', constraint) } - updateServiceFilterCapabilitiesConstraint(componentMetaDataId: string, componentInstanceId: string, constraints: CapabilitiesConstraintObject, componentType: string, constraintType: string, constraintIndex: number):Observable{ + updateServiceFilterCapabilitiesConstraint(componentMetaDataId: string, componentInstanceId: string, constraints: FilterConstraint, componentType: string, constraintType: string, constraintIndex: number):Observable{ return this.http.put(this.baseUrl + this.getServerTypeUrl(componentType) + componentMetaDataId + '/componentInstance/' + componentInstanceId + '/' + constraintType + '/' + constraintIndex + '/nodeFilter', constraints) } @@ -491,12 +512,14 @@ export class TopologyTemplateService { return this.getComponentDataByFieldsName(componentType, componentId, [COMPONENT_FIELDS.COMPONENT_PROPERTIES, COMPONENT_FIELDS.COMPONENT_INPUTS]); } - createSubstitutionFilterConstraints(componentMetaDataId: string, constraint: ConstraintObject, componentType: string, constraintType: string): Observable { + createSubstitutionFilterConstraints(componentMetaDataId: string, constraint: FilterConstraint, componentType: string, constraintType: string): Observable { return this.http.post(this.baseUrl + this.getServerTypeUrl(componentType) + componentMetaDataId + '/substitutionFilter/' + constraintType, constraint); } - updateSubstitutionFilterConstraints(componentMetaDataId: string, constraint: ConstraintObject[], componentType: string, constraintType: string): Observable{ - return this.http.put(this.baseUrl + this.getServerTypeUrl(componentType) + componentMetaDataId + '/substitutionFilter/' + constraintType, constraint); + updateSubstitutionFilterConstraint(componentId: string, constraint: FilterConstraint, componentType: string, constraintType: string, + index: number): Observable { + const url = `${this.baseUrl}${this.getServerTypeUrl(componentType)}${componentId}/substitutionFilter/${constraintType}/${index}`; + return this.http.put(url, constraint); } deleteSubstitutionFilterConstraints(componentMetaDataId: string, constraintIndex: number, componentType: string, constraintType: string): Observable{ @@ -644,4 +667,9 @@ export class TopologyTemplateService { .getServerTypeUrl(componentMetaDataType) + componentMetaDataId + '/componentInstance/' + componentInstanceId + '/interfaceOperation', operationList); } + getDefaultCustomFunction(type='ALL'): Observable { + return this.http.get(this.baseUrl + "customToscaFunctions/" + type) + .pipe(map(response => response && response.defaultCustomToscaFunction ? response.defaultCustomToscaFunction : [])); + } + }