Blueprint client backend integration fix 09/92209/1
authorEzhilarasi <ezhrajam@in.ibm.com>
Mon, 29 Jul 2019 14:37:04 +0000 (20:07 +0530)
committerEzhilarasi <ezhrajam@in.ibm.com>
Mon, 29 Jul 2019 14:37:15 +0000 (20:07 +0530)
Blueprint backend data integration fix

Change-Id: If0e0b2c30bf07f06fc728ff26c509f265c5ee303
Issue-ID: CCSDK-1275
Signed-off-by: Ezhilarasi <ezhrajam@in.ibm.com>
cds-ui/client/src/app/common/constants/app-constants.ts
cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts
cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.service.ts
cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.service.ts

index 49c6e60..a01b7b2 100644 (file)
@@ -99,7 +99,7 @@ export const BlueprintURLs = {
    save: '/controllerblueprint/create-blueprint',
    publish: '/controllerblueprint/publish',
    enrich: '/controllerblueprint/enrich-blueprint',
-   download: '/controllerblueprint/download-blueprint/{name}/{version}',
+   download: '/controllerblueprint/download-blueprint/',
    deploy:'/controllerblueprint/deploy-blueprint'
 }
 
index 0a3a8d2..7b2eaeb 100644 (file)
@@ -35,7 +35,7 @@ import { Store } from '@ngrx/store';
 import { Observable } from 'rxjs';
 import { IBlueprintState } from 'src/app/common/core/store/models/blueprintState.model';
 import { LoadBlueprintSuccess, SetBlueprintState } from '../../../../common/core/store/actions/blueprint.action'
-import { ApiService } from 'src/app/common/core/services/api.service';
+
 import { IMetaData } from 'src/app/common/core/store/models/metadata.model';
 import { EditorService } from './editor.service';
 import { SortPipe } from '../../../../common/shared/pipes/sort.pipe';
@@ -130,7 +130,7 @@ export class EditorComponent implements OnInit {
   artifactName: any;
   artifactVersion: any;
 
-  constructor(private store: Store<IAppState>, private apiservice: EditorService,
+  constructor(private store: Store<IAppState>, private editorService: EditorService,
     private alertService: NotificationHandlerService, private loader: LoaderService
     ) 
     {
@@ -244,7 +244,8 @@ export class EditorComponent implements OnInit {
       .then(blob => {
         const formData = new FormData();
         formData.append("file", blob);
-        this.apiservice.enrich("/enrich-blueprint/", formData)
+        // this.editorService.enrich("/enrich-blueprint/", formData)
+        this.editorService.enrich(formData)
           .subscribe(
             (response) => {
               this.zipFile.files = {};
@@ -271,7 +272,8 @@ export class EditorComponent implements OnInit {
       .then(blob => {
         const formData = new FormData();
         formData.append("file", blob);
-        this.apiservice.post("/create-blueprint/", formData)
+        // this.editorService.saveBlueprint("/create-blueprint/", formData)
+        this.editorService.saveBlueprint(formData)
           .subscribe(
             data => {
               this.alertService.success('Success:' + JSON.stringify(data));
@@ -289,7 +291,8 @@ export class EditorComponent implements OnInit {
       .then(blob => {
         const formData = new FormData();
         formData.append("file", blob);
-        this.apiservice.deployPost("/deploy-blueprint/", formData)
+        // this.editorService.deployPost("/deploy-blueprint/", formData)
+        this.editorService.deployPost(formData)
           .subscribe(data => {
             this.alertService.success('Saved Successfully:' + JSON.stringify(data));
           }, error=>{
@@ -305,7 +308,8 @@ export class EditorComponent implements OnInit {
       .then(blob => {
         const formData = new FormData();
         formData.append("file", blob);
-        this.apiservice.post("/publish/", formData)
+        // this.editorService.post("/publish/", formData)
+        this.editorService.publishBlueprint(formData)
           .subscribe(data => {
             this.alertService.success('Published:' + JSON.stringify(data))
           }, error=>{
@@ -326,7 +330,8 @@ export class EditorComponent implements OnInit {
 
   download() {
     console.log(this.artifactName);
-    status = this.apiservice.downloadCBA("/download-blueprint/" + this.artifactName + "/" + this.artifactVersion);
+    // status = this.editorService.downloadCBA("/download-blueprint/" + this.artifactName + "/" + this.artifactVersion);
+    status = this.editorService.downloadCBA("/"+this.artifactName + "/" + this.artifactVersion);
     window.alert(status);
     // .subscribe(response => {
     //   console.log(response);
@@ -338,14 +343,8 @@ export class EditorComponent implements OnInit {
     //     console.log(error);
     //   }
     // );
-
-    // this.create();
-    // var zipFilename = "baseconfiguration.zip";
-    // this.zipFile.generateAsync({ type: "blob" })
-    //   .then(blob => {
-    //     saveAs(blob, zipFilename);
-    //   });
   }
+  
   setEditorMode() {
     switch (this.fileExtension) {
       case "xml":
index ec25244..025fc95 100644 (file)
@@ -25,19 +25,18 @@ import { HttpClient } from '@angular/common/http';
 import { Observable, observable } from 'rxjs';
 import { ApiService } from '../../../../common/core/services/api.service';
 import { saveAs } from 'file-saver';
+import { BlueprintURLs } from '../../../../common/constants/app-constants';
 
 @Injectable()
 export class EditorService {
-    // blueprintUrl = '../../constants/blueprint.json';
-
     constructor(private _http: HttpClient, private api: ApiService) {
     }
 
-    enrich(uri: string, body: FormData): Observable<any> {
-        return this.api.post(uri, body, { responseType: 'blob' });
+    enrich(body: FormData): Observable<any> {
+        return this.api.post(BlueprintURLs.enrich, body, { responseType: 'blob' });
     }
-    downloadCBA(uri: string): string {
-        this.api.get(uri, { responseType: 'blob' })
+    downloadCBA(artifactDetails: string): string {
+        this.api.get(BlueprintURLs.download+artifactDetails, { responseType: 'blob' })
             .subscribe(response => {
                 let blob = new Blob([response], { 'type': "application/octet-stream" });
                 saveAs(blob, "CBA.zip");
@@ -46,13 +45,17 @@ export class EditorService {
         return "Download Success";
 
     }
-    post(uri: string, body: any | null, options?: any): Observable<any> {
+    saveBlueprint(body: any | null, options?: any): Observable<any> {
+
+        return this.api.post(BlueprintURLs.save, body, options);
+    }
+    publishBlueprint(body: any | null, options?: any): Observable<any> {
 
-        return this.api.post(uri, body, options);
+        return this.api.post(BlueprintURLs.publish, body, options);
     }
 
-    deployPost(uri: string, body: any | null, options?: any): Observable<any> {
+    deployPost(body: any | null, options?: any): Observable<any> {
 
-        return this.api.post(uri, body, { responseType: 'text' });
+        return this.api.post(BlueprintURLs.deploy, body, { responseType: 'text' });
     }
 }
\ No newline at end of file
index dd17a30..9ce714d 100644 (file)
@@ -23,6 +23,7 @@ import { Injectable } from '@angular/core';
 import { HttpClient } from '@angular/common/http';
 import { Observable } from 'rxjs';
 import { ApiService } from '../../../../common/core/services/api.service';
+import { BlueprintURLs } from '../../../../common/constants/app-constants';
 
 @Injectable({
   providedIn: 'root'
@@ -31,7 +32,7 @@ export class SearchTemplateService {
 
   constructor(private _http: HttpClient, private api: ApiService) { }
 
-  searchByTags(uri: string, searchText: String): Observable<any>{
-    return this.api.post(uri, searchText);
+  searchByTags(searchText: String): Observable<any>{
+    return this.api.post(BlueprintURLs.searchByTag, searchText);
   }
 }