From 3d5b80b9035b9832f86326858b4c6c2cecd952a3 Mon Sep 17 00:00:00 2001 From: Arielk Date: Mon, 13 May 2019 15:30:27 +0300 Subject: operation artifact optional and fixes Change-Id: Ibce96d60248b26716ed518747444836b437f209f Issue-ID: SDC-2249 Signed-off-by: Arielk --- .../component-services/component.service.ts | 26 +++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'catalog-ui/src/app/ng2/services') 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 c313a3fc2f..445e1231f9 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 @@ -25,7 +25,7 @@ import 'rxjs/add/operator/map'; import 'rxjs/add/operator/toPromise'; import {Response, URLSearchParams, Headers} from '@angular/http'; import { Component, ComponentInstance, InputBEModel, InstancePropertiesAPIMap, FilterPropertiesAssignmentData, - PropertyBEModel, OperationModel, BEOperationModel, Capability, Requirement, PolicyInstance} from "app/models"; + PropertyBEModel, InterfaceModel, OperationModel, BEOperationModel, Capability, Requirement, PolicyInstance} from "app/models"; import {COMPONENT_FIELDS, CommonUtils, SERVICE_FIELDS} from "app/utils"; import {downgradeInjectable} from '@angular/upgrade/static'; import {ComponentGenericResponse} from "../responses/component-generic-response"; @@ -156,12 +156,13 @@ export class ComponentServiceNg2 { }; return this.http.post(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/interfaceOperations', operationList) .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); + const interf:InterfaceModel = _.find(res.json().interfaces, interf => interf.type === operation.interfaceType); + const newOperation:OperationModel = _.find(interf.operations, op => op.name === operation.name); return new OperationModel({ ...newOperation, interfaceType: interf.type, - interfaceId: interf.uniqueId + interfaceId: interf.uniqueId, + artifactFileName: operation.artifactFileName }); }); } @@ -179,12 +180,13 @@ export class ComponentServiceNg2 { }; return this.http.put(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/interfaceOperations', operationList) .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); + const interf:InterfaceModel = _.find(res.json().interfaces, interf => interf.type === operation.interfaceType); + const newOperation:OperationModel = _.find(interf.operations, op => op.name === operation.name); return new OperationModel({ ...newOperation, interfaceType: interf.type, - interfaceId: interf.uniqueId + interfaceId: interf.uniqueId, + artifactFileName: operation.artifactFileName }); }); } @@ -207,12 +209,12 @@ export class ComponentServiceNg2 { }); } - uploadInterfaceOperationArtifact(component:Component, response:OperationModel, UIOperation:OperationModel) { + uploadInterfaceOperationArtifact(component:Component, newOperation:OperationModel, oldOperation:OperationModel) { const payload = { artifactType: "WORKFLOW", - artifactName: UIOperation.artifactFile.name, + artifactName: oldOperation.artifactFileName, description: "Workflow Artifact Description", - payloadData: UIOperation.artifactData + payloadData: oldOperation.artifactData }; const headers = new Headers(); @@ -221,10 +223,12 @@ export class ComponentServiceNg2 { const md5Result = md5(payloadString).toLowerCase(); headers.append('Content-MD5', btoa(md5Result)); - return this.http.post(this.baseUrl + component.getTypeUrl() + component.uuid + '/interfaces/' + response.interfaceId + '/operations/' + response.uniqueId + '/artifacts/' + response.implementation.artifactUUID, + return this.http.post(this.baseUrl + component.getTypeUrl() + component.uuid + '/interfaces/' + newOperation.interfaceId + '/operations/' + newOperation.uniqueId + '/artifacts/' + newOperation.implementation.artifactUUID, payload, {headers} ).map((res: Response) => { + const fileName = res.json().artifactDisplayName || res.json().artifactName; + newOperation.artifactFileName = fileName; return res.json(); }); } -- cgit 1.2.3-korg