diff options
Diffstat (limited to 'catalog-ui/src/app/ng2/services')
3 files changed, 70 insertions, 18 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> { diff --git a/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts b/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts index a77133e09f..647cc927f7 100644 --- a/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts +++ b/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts @@ -92,6 +92,7 @@ export class ComponentGenericResponse implements Serializable<ComponentGenericR this.toscaArtifacts = new ArtifactGroupModel(response.toscaArtifacts); } if(response.interfaces) { + this.interfaces = CommonUtils.initInterfaces(response.interfaces); this.interfaceOperations = CommonUtils.initInterfaceOperations(response.interfaces); } if(response.metadata) { diff --git a/catalog-ui/src/app/ng2/services/workflow.service.ts b/catalog-ui/src/app/ng2/services/workflow.service.ts index 1fc5c7843b..36d56d6fa7 100644 --- a/catalog-ui/src/app/ng2/services/workflow.service.ts +++ b/catalog-ui/src/app/ng2/services/workflow.service.ts @@ -3,7 +3,17 @@ import { Response } from "@angular/http"; import { Observable } from "rxjs/Observable"; import { HttpService } from "./http.service"; import { SdcConfigToken, ISdcConfig } from "../config/sdc-config.config"; -import { Component } from "app/models"; +import { Component, CreateOperationResponse } from "app/models"; + +interface WorkflowOutputParameter { + name: string, + type: string, + mandatory: boolean +} + +interface WorkflowInputParameter extends WorkflowOutputParameter { + property: string; +} @Injectable() export class WorkflowServiceNg2 { @@ -20,9 +30,9 @@ export class WorkflowServiceNg2 { this.catalogBaseUrl = sdcConfig.api.POST_workflow_artifact; } - public associateWorkflowArtifact(component: Component, operationId: string, workflowId: string, workflowVersionId: string, artifactUuid: string): Observable<any> { - return this.http.post(this.baseUrl + '/workflows/' + workflowId + '/versions/' + workflowVersionId + '/artifact-deliveries', { - endpoint: this.catalogBaseUrl + '/' + component.getTypeUrl() + component.uuid + '/interfaces/' + operationId + '/artifacts/' + artifactUuid, + public associateWorkflowArtifact(component: Component, operation: CreateOperationResponse): Observable<any> { + return this.http.post(this.baseUrl + '/workflows/' + operation.workflowId + '/versions/' + operation.workflowVersionId + '/artifact-deliveries', { + endpoint: this.catalogBaseUrl + '/' + component.getTypeUrl() + component.uuid + '/interfaces/' + operation.interfaceId + '/operations/' + operation.uniqueId + '/artifacts/' + operation.artifactUUID, method: 'POST' }) .map((res:Response) => { @@ -40,7 +50,7 @@ export class WorkflowServiceNg2 { public getWorkflowVersions(workflowId: string, filterCertified: boolean = true): Observable<any> { return this.http.get(this.baseUrl + '/workflows/' + workflowId + '/versions' + (filterCertified ? '?state=' + this.VERSION_STATE_CERTIFIED : '')) .map((res:Response) => { - return res.json().items; + return _.map(res.json().items, version => version); }); } |