From 6e998ce32f75614c90963954c62bde64df747c64 Mon Sep 17 00:00:00 2001 From: ShaabanEltanany Date: Sun, 13 Sep 2020 12:28:48 +0200 Subject: improve manual enrichment Issue-ID: CCSDK-2542 Signed-off-by: ShaabanEltanany Change-Id: I3ec0bdc702f7e424896bd57c4560ab60349bbc37 --- .../configuration-dashboard.component.ts | 32 +++++++++------------- .../package-creation/package-creation.service.ts | 2 +- 2 files changed, 14 insertions(+), 20 deletions(-) (limited to 'cds-ui') diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts index 71afa155d..eb699af75 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts @@ -98,11 +98,11 @@ export class ConfigurationDashboardComponent implements OnInit { bluePrintDetailModels[0].artifactName + '/' + bluePrintDetailModels[0].artifactVersion).subscribe(response => { const blob = new Blob([response], {type: 'application/octet-stream'}); this.currentBlob = blob; - this.extractBlobToStore(blob, bluePrintDetailModels); + this.extractBlobToStore(blob, bluePrintDetailModels[0]); }); } - private extractBlobToStore(blob: Blob, bluePrintDetailModels: BluePrintDetailModel) { + private extractBlobToStore(blob: Blob, bluePrintDetailModel: BluePrintDetailModel) { this.zipFile.loadAsync(blob).then((zip) => { Object.keys(zip.files).forEach((filename) => { zip.files[filename].async('string').then((fileData) => { @@ -118,10 +118,10 @@ export class ConfigurationDashboardComponent implements OnInit { } } else if (filename.includes('Definitions/')) { - this.setImports(filename, fileData, bluePrintDetailModels); + this.setImports(filename, fileData, bluePrintDetailModel); } else if (filename.includes('TOSCA-Metadata/')) { const metaDataTabInfo: MetaDataTabModel = this.getMetaDataTabInfo(fileData); - this.setMetaData(metaDataTabInfo, bluePrintDetailModels[0]); + this.setMetaData(metaDataTabInfo, bluePrintDetailModel); } } }); @@ -134,7 +134,8 @@ export class ConfigurationDashboardComponent implements OnInit { } setImports(filename: string, fileData: any, bluePrintDetailModels: BluePrintDetailModel) { - if (filename.includes(bluePrintDetailModels[0].artifactName)) { + console.log(filename); + if (filename.includes(bluePrintDetailModels.artifactName)) { let definition = new VlbDefinition(); definition = fileData as VlbDefinition; definition = JSON.parse(fileData); @@ -293,22 +294,15 @@ export class ConfigurationDashboardComponent implements OnInit { this.packageCreationService.enrichPackage(blob).subscribe(response => { console.log('success'); const blobInfo = new Blob([response], {type: 'application/octet-stream'}); - this.configurationDashboardService.getPagedPackages(this.id).subscribe( - (bluePrintDetailModels) => { - if (bluePrintDetailModels) { - this.packageCreationStore.clear(); - this.extractBlobToStore(blob, bluePrintDetailModels); - this.isSaveEnabled = true; - this.toastService.info('enriched successfully '); - } - }); - - // saveAs(blobInfo, 'test' + '-' + '1.0.0' + '-CBA.zip'); - + this.currentBlob = blobInfo; + this.packageCreationStore.clear(); + this.extractBlobToStore(this.currentBlob, this.viewedPackage); + this.isSaveEnabled = true; + this.toastService.info('enriched successfully '); }); }, error => { - this.toastService.error('error happened when editing ' + error.message); - console.log('Error -' + error.message); + this.toastService.error('error happened when enrich ' + error.message); + console.error('Error -' + error.message); }); } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.service.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.service.ts index e7ccbb39a..bd8360a14 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.service.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.service.ts @@ -42,7 +42,7 @@ export class PackageCreationService { } private enrichBlueprint(body: any | null, options?: any): Observable { - return this.api.post(BlueprintURLs.enrich, body, {responseType: 'text'}); + return this.api.post(BlueprintURLs.enrich, body, { responseType: 'blob' }); } private deployBluePrint(body: any | null, options?: any): Observable { -- cgit 1.2.3-korg