aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/services/component-services/component.service.ts
diff options
context:
space:
mode:
authorArielk <Ariel.Kenan@amdocs.com>2019-01-13 18:31:13 +0200
committerAvi Gaffa <avi.gaffa@amdocs.com>2019-01-14 11:10:24 +0000
commit86a37526357337a9143c1f5e27c0976e68b15d1d (patch)
tree7d531c531d0ef73d4c8c6c8f84c6eaeb18854bdb /catalog-ui/src/app/ng2/services/component-services/component.service.ts
parent5b9d9a134778d4dc7bf45474ba13be6ba0c46282 (diff)
Interface operation screen enhancements
Change-Id: I2b510a4bf27ddf5730ed044cf77aebd955ad5862 Issue-ID: SDC-2044 Signed-off-by: Arielk <Ariel.Kenan@amdocs.com>
Diffstat (limited to 'catalog-ui/src/app/ng2/services/component-services/component.service.ts')
-rw-r--r--catalog-ui/src/app/ng2/services/component-services/component.service.ts67
1 files changed, 54 insertions, 13 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 26b0291156..97e62daba7 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
@@ -24,9 +24,9 @@ import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';
import {Response, URLSearchParams} from '@angular/http';
-import { Component, InputBEModel, InstancePropertiesAPIMap, FilterPropertiesAssignmentData, OperationModel, CreateOperationResponse} from "app/models";
+import { Component, InputBEModel, InstancePropertiesAPIMap, FilterPropertiesAssignmentData, OperationModel, BEOperationModel, CreateOperationResponse} from "app/models";
import {downgradeInjectable} from '@angular/upgrade/static';
-import {COMPONENT_FIELDS} from "app/utils";
+import {COMPONENT_FIELDS, CommonUtils} 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";
@@ -122,38 +122,79 @@ export class ComponentServiceNg2 {
return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_PROPERTIES]);
}
- getInterfaceOperations(component:Component):Observable<ComponentGenericResponse> {
+ getInterfaces(component:Component):Observable<ComponentGenericResponse> {
return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_INTERFACE_OPERATIONS]);
}
getInterfaceOperation(component:Component, operation:OperationModel):Observable<OperationModel> {
- return this.http.get(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/interfaceOperations/' + operation.uniqueId)
- .map((res:Response) => res.json());
+ return this.http.get(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/interfaces/' + operation.interfaceId + '/operations/' + operation.uniqueId)
+ .map((res:Response) => {
+ return res.json();
+ });
}
createInterfaceOperation(component:Component, operation:OperationModel):Observable<CreateOperationResponse> {
const operationList = {
- 'interfaceOperations': {
- [operation.operationType]: operation
+ 'interfaces': {
+ [operation.interfaceType]: {
+ 'type': operation.interfaceType,
+ 'operations': {
+ [operation.name]: new BEOperationModel(operation)
+ }
+ }
}
};
return this.http.post(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/interfaceOperations', operationList)
- .map((res:Response) => res.json());
+ .map((res:Response) => {
+ const interf = _.find(res.json().interfaces, (interf: any) => interf.type === operation.interfaceType);
+ const newOperation = _.find(interf.operations, (op:OperationModel) => op.name === operation.name);
+ return new CreateOperationResponse({
+ ...newOperation,
+ interfaceType: interf.type,
+ interfaceId: interf.uniqueId
+ });
+ });
}
updateInterfaceOperation(component:Component, operation:OperationModel):Observable<CreateOperationResponse> {
const operationList = {
- 'interfaceOperations': {
- [operation.operationType]: operation
+ 'interfaces': {
+ [operation.interfaceType]: {
+ 'type': operation.interfaceType,
+ 'operations': {
+ [operation.name]: new BEOperationModel(operation)
+ }
+ }
}
};
return this.http.put(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/interfaceOperations', operationList)
- .map((res:Response) => res.json());
+ .map((res:Response) => {
+ const interf = _.find(res.json().interfaces, (interf: any) => interf.type === operation.interfaceType);
+ const newOperation = _.find(interf.operations, (op:OperationModel) => op.name === operation.name);
+ return new CreateOperationResponse({
+ ...newOperation,
+ interfaceType: interf.type,
+ interfaceId: interf.uniqueId
+ });
+ });
}
deleteInterfaceOperation(component:Component, operation:OperationModel):Observable<OperationModel> {
- return this.http.delete(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/interfaceOperations/' + operation.uniqueId)
- .map((res:Response) => res.json());
+ return this.http.delete(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/interfaces/' + operation.interfaceId + '/operations/' + operation.uniqueId)
+ .map((res:Response) => {
+ return res.json();
+ });
+ }
+
+ getInterfaceTypes(component:Component):Observable<{[id:string]: Array<string>}> {
+ return this.http.get(this.baseUrl + 'interfaceLifecycleTypes')
+ .map((res:Response) => {
+ const interfaceMap = {};
+ _.forEach(res.json(), (interf:any) => {
+ interfaceMap[interf.toscaPresentation.type] = _.keys(interf.toscaPresentation.operations);
+ });
+ return interfaceMap;
+ });
}
getCapabilitiesAndRequirements(componentType: string, componentId:string):Observable<ComponentGenericResponse> {