From: imamSidero Date: Tue, 29 Aug 2023 10:39:37 +0000 (+0100) Subject: Provide UI support to upload csar to update service X-Git-Tag: 1.13.4~4 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=sdc.git;a=commitdiff_plain;h=ec5c8fddfb0ba0e40b19cd438533114652448d0f Provide UI support to upload csar to update service Upload capability is porvided in tosca artifact to update the service Issue-ID: SDC-4605 Signed-off-by: Imam hussain Change-Id: I075250f91e6e68f007298d1b982db86244a696db --- diff --git a/catalog-ui/src/app/ng2/http-interceptor/headers-interceptor.ts b/catalog-ui/src/app/ng2/http-interceptor/headers-interceptor.ts index 00e2fd8fcd..d548d425a2 100644 --- a/catalog-ui/src/app/ng2/http-interceptor/headers-interceptor.ts +++ b/catalog-ui/src/app/ng2/http-interceptor/headers-interceptor.ts @@ -14,11 +14,19 @@ export class HeadersInterceptor implements HttpInterceptor { constructor(private injector: Injector, private cookieService: Cookie2Service, private httpHelperService: HttpHelperService) {} intercept(req: HttpRequest, next: HttpHandler): Observable> { - let authReq = req.clone({ headers: req.headers.set(this.cookieService.getUserIdSuffix(), this.cookieService.getUserId()) - .set('Content-Type', 'application/json; charset=UTF-8') - .set(this.cookieService.getUserIdSuffix(), this.cookieService.getUserId()) - .set(this.cookieService.getUserIdSuffix(), this.cookieService.getUserId()) - }); + let authReq: HttpRequest; + if (req.body instanceof FormData) { + authReq = req.clone({ headers: req.headers.set(this.cookieService.getUserIdSuffix(), this.cookieService.getUserId()) + .set(this.cookieService.getUserIdSuffix(), this.cookieService.getUserId()) + .set(this.cookieService.getUserIdSuffix(), this.cookieService.getUserId()) + }); + } else { + authReq = req.clone({ headers: req.headers.set(this.cookieService.getUserIdSuffix(), this.cookieService.getUserId()) + .set('Content-Type', 'application/json; charset=UTF-8') + .set(this.cookieService.getUserIdSuffix(), this.cookieService.getUserId()) + .set(this.cookieService.getUserIdSuffix(), this.cookieService.getUserId()) + }); + } const uuidValue = this.httpHelperService.getUuidValue(authReq.url); if (uuidValue !== '') { diff --git a/catalog-ui/src/app/ng2/pages/workspace/tosca-artifacts/tosca-artifact-page.component.ts b/catalog-ui/src/app/ng2/pages/workspace/tosca-artifacts/tosca-artifact-page.component.ts index e6d820ecd5..c18d22ba07 100644 --- a/catalog-ui/src/app/ng2/pages/workspace/tosca-artifacts/tosca-artifact-page.component.ts +++ b/catalog-ui/src/app/ng2/pages/workspace/tosca-artifacts/tosca-artifact-page.component.ts @@ -70,11 +70,15 @@ export class ToscaArtifactPageComponent implements OnInit { this.isLoading = true; switch (artifactType) { case (ArtifactType.TOSCA.TOSCA_CSAR): - this.Notification.error({ - message: "Feature not implemented yet", - title: "Error" + this.componentService.putServiceToscaModel(this.componentId, this.componentType, file).subscribe((response)=> { + this.Notification.success({ + message: "Service " + response.name + " has been updated", + title: "Success" + }); + this.isLoading = false; + }, () => { + this.isLoading = false; }); - this.isLoading = false; break; case (ArtifactType.TOSCA.TOSCA_TEMPLATE): this.componentService.putServiceToscaTemplate(this.componentId, this.componentType, file).subscribe((response)=> { 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 0386a1577a..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 @@ -80,6 +80,12 @@ export class TopologyTemplateService { 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); }