From 5ede965c0c3dd365be4efde0699d5ec976a614c3 Mon Sep 17 00:00:00 2001 From: Ezhilarasi Date: Mon, 29 Jul 2019 20:07:04 +0530 Subject: Blueprint client backend integration fix Blueprint backend data integration fix Change-Id: If0e0b2c30bf07f06fc728ff26c509f265c5ee303 Issue-ID: CCSDK-1275 Signed-off-by: Ezhilarasi --- .../modify-template/editor/editor.component.ts | 27 +++++++++++----------- .../modify-template/editor/editor.service.ts | 23 ++++++++++-------- .../search-template/search-template.service.ts | 5 ++-- 3 files changed, 29 insertions(+), 26 deletions(-) (limited to 'cds-ui/client/src/app/feature-modules/blueprint') diff --git a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts index 0a3a8d2ef..7b2eaeb17 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts +++ b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts @@ -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, private apiservice: EditorService, + constructor(private store: Store, 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": diff --git a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.service.ts b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.service.ts index ec2524422..025fc95d4 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.service.ts +++ b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.service.ts @@ -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 { - return this.api.post(uri, body, { responseType: 'blob' }); + enrich(body: FormData): Observable { + 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 { + saveBlueprint(body: any | null, options?: any): Observable { + + return this.api.post(BlueprintURLs.save, body, options); + } + publishBlueprint(body: any | null, options?: any): Observable { - return this.api.post(uri, body, options); + return this.api.post(BlueprintURLs.publish, body, options); } - deployPost(uri: string, body: any | null, options?: any): Observable { + deployPost(body: any | null, options?: any): Observable { - return this.api.post(uri, body, { responseType: 'text' }); + return this.api.post(BlueprintURLs.deploy, body, { responseType: 'text' }); } } \ No newline at end of file diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.service.ts b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.service.ts index dd17a30d2..9ce714dc9 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.service.ts +++ b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.service.ts @@ -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{ - return this.api.post(uri, searchText); + searchByTags(searchText: String): Observable{ + return this.api.post(BlueprintURLs.searchByTag, searchText); } } -- cgit 1.2.3-korg