aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/services/component-services
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-02-16 17:37:57 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-02-17 15:57:55 +0000
commit26e5029d922779fd7e786c1a31b6b37492132388 (patch)
tree8e8e68a6913749e1405fce951bc7816d4fa35ba3 /catalog-ui/src/app/ng2/services/component-services
parentf2c0a4118c3c0b6360b639622766543bd754b59c (diff)
Implement Attributes/Outputs FE
Change-Id: I014bb0ebc07f3fea4266a4f295172eadee546705 Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3448
Diffstat (limited to 'catalog-ui/src/app/ng2/services/component-services')
-rw-r--r--catalog-ui/src/app/ng2/services/component-services/component.service.ts46
-rw-r--r--catalog-ui/src/app/ng2/services/component-services/service.service.ts2
-rw-r--r--catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts48
3 files changed, 91 insertions, 5 deletions
diff --git a/catalog-ui/src/app/ng2/services/component-services/component.service.ts b/catalog-ui/src/app/ng2/services/component-services/component.service.ts
index 3093e632fc..d406cf05f6 100644
--- a/catalog-ui/src/app/ng2/services/component-services/component.service.ts
+++ b/catalog-ui/src/app/ng2/services/component-services/component.service.ts
@@ -43,6 +43,7 @@ import { PolicyInstance } from "../../../models/graph/zones/policy-instance";
import { ConstraintObject } from "../../components/logic/service-dependencies/service-dependencies.component";
import { Requirement } from "../../../models/requirement";
import { Capability } from "../../../models/capability";
+import { OutputBEModel } from "app/models/attributes-outputs/output-be-model";
/*
PLEASE DO NOT USE THIS SERVICE IN ANGULAR2! Use the topology-template.service instead
@@ -59,7 +60,7 @@ export class ComponentServiceNg2 {
protected getComponentDataByFieldsName(componentType:string, componentId:string, fields:Array<string>):Observable<ComponentGenericResponse> {
let params: HttpParams = new HttpParams();
- _.forEach(fields, (field:string):void => {
+ fields.forEach((field:string):void => {
params = params.append(API_QUERY_PARAMS.INCLUDE, field);
});
@@ -109,6 +110,10 @@ export class ComponentServiceNg2 {
return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_INSTANCES, COMPONENT_FIELDS.COMPONENT_POLICIES, COMPONENT_FIELDS.COMPONENT_NON_EXCLUDED_GROUPS]);
}
+ getComponentResourceAttributesData(component:Component):Observable<ComponentGenericResponse> {
+ return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_INSTANCES, COMPONENT_FIELDS.COMPONENT_NON_EXCLUDED_GROUPS]);
+ }
+
getComponentResourceInstances(component:Component):Observable<ComponentGenericResponse> {
return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_INSTANCES]);
}
@@ -208,8 +213,15 @@ export class ComponentServiceNg2 {
return this.http.get<any>(this.baseUrl + 'interfaceLifecycleTypes')
.map((res: any) => {
const interfaceMap = {};
- _.forEach(res, (interf: any) => {
- interfaceMap[interf.toscaPresentation.type] = _.keys(interf.toscaPresentation.operations);
+ if (!res) {
+ return interfaceMap;
+ }
+ Object.keys(res).forEach(interfaceName => {
+ const interface1 = res[interfaceName];
+ if (!interface1.toscaPresentation.operations) {
+ return;
+ }
+ interfaceMap[interface1.toscaPresentation.type] = Object.keys(interface1.toscaPresentation.operations);
});
return interfaceMap;
});
@@ -297,7 +309,6 @@ export class ComponentServiceNg2 {
return this.http.post(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/archive', {})
}
-
deleteInput(component:Component, input:InputBEModel):Observable<InputBEModel> {
return this.http.delete<InputBEModel>(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/delete/' + input.uniqueId + '/input')
@@ -306,6 +317,14 @@ export class ComponentServiceNg2 {
})
}
+ deleteOutput(component:Component, output:OutputBEModel):Observable<OutputBEModel> {
+
+ return this.http.delete<OutputBEModel>(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/delete/' + output.uniqueId + '/output')
+ .map((res) => {
+ return new OutputBEModel(res);
+ })
+ }
+
updateComponentInputs(component:Component, inputs:InputBEModel[]):Observable<InputBEModel[]> {
return this.http.post<InputBEModel[]>(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/update/inputs', inputs)
@@ -314,9 +333,26 @@ export class ComponentServiceNg2 {
})
}
+ updateComponentOutputs(component:Component, outputs:OutputBEModel[]):Observable<OutputBEModel[]> {
+
+ return this.http.post<OutputBEModel[]>(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/update/outputs', outputs)
+ .map((res) => {
+ return res.map((output) => new OutputBEModel(output));
+ })
+ }
+
filterComponentInstanceProperties(component:Component, filterData:FilterPropertiesAssignmentData):Observable<InstanceBePropertiesMap> {//instance-property-be-map
let params: HttpParams = new HttpParams();
- _.forEach(filterData.selectedTypes, (type:string) => {
+ filterData.selectedTypes.forEach((type:string) => {
+ params = params.append('resourceType', type);
+ });
+
+ return this.http.get<InstanceBePropertiesMap>(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/filteredproperties/' + filterData.propertyName, {params: params});
+ }
+
+ filterComponentInstanceAttributes(component:Component, filterData:FilterPropertiesAssignmentData):Observable<InstanceBePropertiesMap> {//instance-property-be-map
+ let params: HttpParams = new HttpParams();
+ filterData.selectedTypes.forEach((type:string) => {
params = params.append('resourceType', type);
});
diff --git a/catalog-ui/src/app/ng2/services/component-services/service.service.ts b/catalog-ui/src/app/ng2/services/component-services/service.service.ts
index 9460a32323..05384c9eec 100644
--- a/catalog-ui/src/app/ng2/services/component-services/service.service.ts
+++ b/catalog-ui/src/app/ng2/services/component-services/service.service.ts
@@ -89,7 +89,9 @@ export class ServiceServiceNg2 extends ComponentServiceNg2 {
COMPONENT_FIELDS.COMPONENT_INSTANCES_INTERFACES,
COMPONENT_FIELDS.COMPONENT_INSTANCES_PROPERTIES,
COMPONENT_FIELDS.COMPONENT_INSTANCES_INPUTS,
+ COMPONENT_FIELDS.COMPONENT_INSTANCES_OUTPUTS,
COMPONENT_FIELDS.COMPONENT_INPUTS,
+ COMPONENT_FIELDS.COMPONENT_OUTPUTS,
COMPONENT_FIELDS.COMPONENT_INSTANCES,
COMPONENT_FIELDS.COMPONENT_CAPABILITIES
]);
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<ComponentGenericResponse> {
+ 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<ComponentGenericResponse> {
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<any> {
+ 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<AttributeBEModel> {
+ const serverObject = {};
+ serverObject[attributeModel.name] = attributeModel;
+ return this.http.post<AttributeBEModel>(this.baseUrl + 'services/' + componentId + '/attributes', serverObject)
+ .map((res) => {
+ const attribute: AttributeBEModel = new AttributeBEModel(res);
+ return attribute;
+ });
+ }
+
getServiceProperties(componentId: string): Observable<PropertyBEModel[]> {
return this.http.get<any>(this.baseUrl + 'services/' + componentId + '/properties')
.map((res) => {
@@ -216,6 +238,16 @@ export class TopologyTemplateService {
});
}
+ getServiceAttributes(componentId: string): Observable<AttributeBEModel[]> {
+ return this.http.get<any>(this.baseUrl + 'services/' + componentId + '/attributes')
+ .map((res) => {
+ if (!res) {
+ return new Array<AttributeBEModel>();
+ }
+ return CommonUtils.initAttributes(res);
+ });
+ }
+
updateServiceProperties(componentId: string, properties: PropertyBEModel[]) {
return this.http.put<any>( this.baseUrl + 'services/' + componentId + '/properties', properties)
.map((res) => {
@@ -225,6 +257,15 @@ export class TopologyTemplateService {
});
}
+ updateServiceAttributes(componentId: string, attributes: AttributeBEModel[]) {
+ return this.http.put<any>( 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<string> {
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<string> {
+ return this.http.delete(this.baseUrl + 'services/' + componentId + '/attributes/' + attribute.uniqueId )
+ .map((res: Response) => {
+ return attribute.uniqueId;
+ });
+ }
+
getDependencies(componentType: string, componentId: string): Observable<IDependenciesServerResponse[]> {
return this.http.get<IDependenciesServerResponse[]>(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/dependencies');
}