diff options
author | KAPIL SINGAL <ks220y@att.com> | 2020-09-08 13:10:50 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-09-08 13:10:50 +0000 |
commit | 2891777b8569fc1dc6886a47e2bc27e646bde088 (patch) | |
tree | 4ce9cda6c81346fad677e20baec0fc7da5fbcec7 /cds-ui | |
parent | 57c6cdf3c137da78c9d0d52a4862c1bc6445f923 (diff) | |
parent | dc16c9e10b9f7f403761fe5f767cf48c2f39d73b (diff) |
Merge "adding manual enrichment"
Diffstat (limited to 'cds-ui')
4 files changed, 79 insertions, 28 deletions
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.html index 772923283..0ffd9cb5e 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.html +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.html @@ -755,9 +755,9 @@ </nav> <div class="row mt-4"> <div class="col"> - <div class="tab-content" id="nav-tabContent"> + <div class="tab-content" id="nav-tabContent" (change)="clickEvent()"> <div class="tab-pane fade show active" id="nav-metadata" role="tabpanel" - aria-labelledby="nav-metadata-tab" (change)="clickEvent()"> + aria-labelledby="nav-metadata-tab" > <app-metadata-tab></app-metadata-tab> </div> <div class="tab-pane fade" id="nav-template" role="tabpanel" 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 47e89b39a..029601d67 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 @@ -70,6 +70,7 @@ export class ConfigurationDashboardComponent implements OnInit { } } else { this.metadataClasses = this.metadataClasses.replace('complete', ''); + this.isSaveEnabled = false; } }); @@ -92,27 +93,32 @@ 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.zipFile.loadAsync(blob).then((zip) => { - Object.keys(zip.files).forEach((filename) => { - zip.files[filename].async('string').then((fileData) => { - if (fileData) { - if (filename.includes('Scripts/')) { - this.setScripts(filename, fileData); - } else if (filename.includes('Templates/')) { - if (filename.includes('-mapping.')) { - this.setMapping(filename, fileData); - } else if (filename.includes('-template.')) { - this.setTemplates(filename, fileData); - } - - } else if (filename.includes('Definitions/')) { - this.setImports(filename, fileData, bluePrintDetailModels); - } else if (filename.includes('TOSCA-Metadata/')) { - const metaDataTabInfo: MetaDataTabModel = this.getMetaDataTabInfo(fileData); - this.setMetaData(metaDataTabInfo, bluePrintDetailModels[0]); + this.extractBlobToStore(blob, bluePrintDetailModels); + }); + } + + private extractBlobToStore(blob: Blob, bluePrintDetailModels: BluePrintDetailModel) { + this.zipFile.loadAsync(blob).then((zip) => { + Object.keys(zip.files).forEach((filename) => { + zip.files[filename].async('string').then((fileData) => { + console.log(filename); + if (fileData) { + if (filename.includes('Scripts/')) { + this.setScripts(filename, fileData); + } else if (filename.includes('Templates/')) { + if (filename.includes('-mapping.')) { + this.setMapping(filename, fileData); + } else if (filename.includes('-template.')) { + this.setTemplates(filename, fileData); } + + } else if (filename.includes('Definitions/')) { + this.setImports(filename, fileData, bluePrintDetailModels); + } else if (filename.includes('TOSCA-Metadata/')) { + const metaDataTabInfo: MetaDataTabModel = this.getMetaDataTabInfo(fileData); + this.setMetaData(metaDataTabInfo, bluePrintDetailModels[0]); } - }); + } }); }); }); @@ -239,8 +245,9 @@ export class ConfigurationDashboardComponent implements OnInit { } deployCurrentPackage() { - console.log('happened'); - this.router.navigate(['/packages']); + this.collectZipFileFromStore(); + this.deployPackage(); + } goToDesignerMode(id) { @@ -266,19 +273,21 @@ export class ConfigurationDashboardComponent implements OnInit { enrichBluePrint() { + this.collectZipFileFromStore(); + this.enrichPackage(); + } + + private collectZipFileFromStore() { this.packageCreationStore.state$.subscribe( cbaPackage => { FilesContent.clear(); console.log(cbaPackage); - let packageCreationModes: PackageCreationModes; cbaPackage = PackageCreationModes.mapModeType(cbaPackage); cbaPackage.metaData = PackageCreationModes.setEntryPoint(cbaPackage.metaData); packageCreationModes = PackageCreationBuilder.getCreationMode(cbaPackage); packageCreationModes.execute(cbaPackage, this.packageCreationUtils); this.filesData.push(this.folder.TREE_DATA); - this.enrichPackage(); - }); } @@ -289,8 +298,18 @@ export class ConfigurationDashboardComponent implements OnInit { this.packageCreationStore.enrichBluePrint(blob).subscribe(response => { console.log('success'); const blobInfo = new Blob([response], {type: 'application/octet-stream'}); - saveAs(blobInfo, 'test' + '-' + '1.0.0' + '-CBA.zip'); - this.toastService.info('enriched successfully '); + 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'); + }); }, error => { this.toastService.error('error happened when editing ' + error.message); @@ -298,6 +317,23 @@ export class ConfigurationDashboardComponent implements OnInit { }); } + private deployPackage() { + this.create(); + this.zipFile.generateAsync({type: 'blob'}) + .then(blob => { + this.packageCreationStore.deployBluePrint(blob).subscribe(response => { + console.log('success'); + console.log(response); + + // saveAs(blobInfo, 'test' + '-' + '1.0.0' + '-CBA.zip'); + + }); + }, error => { + this.toastService.error('error happened when deploying ' + error.message); + console.log('Error -' + error.message); + }); + } + clickEvent() { this.isSaveEnabled = true; } 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 952fea3ca..e7ccbb39a 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 @@ -45,6 +45,10 @@ export class PackageCreationService { return this.api.post(BlueprintURLs.enrich, body, {responseType: 'text'}); } + private deployBluePrint(body: any | null, options?: any): Observable<any> { + return this.api.post(BlueprintURLs.deploy, body, {responseType: 'text'}); + } + async checkBluePrintNameAndVersion(name: string, version: string): Promise<boolean> { return await this.packagesListService.checkBluePrintIfItExists(name, version) .then(bluePrintModelsResult => bluePrintModelsResult != null && bluePrintModelsResult.length > 0); @@ -64,6 +68,11 @@ export class PackageCreationService { return this.enrichBlueprint(formData); } + deploy(blob) { + const formData = this.getFormData(blob); + return this.deployBluePrint(formData); + } + private getFormData(blob) { const formData = new FormData(); formData.append('file', blob); @@ -73,4 +82,6 @@ export class PackageCreationService { getTemplateAndMapping(variables: string[]): Observable<ResourceDictionary[]> { return this.api.post(ResourceDictionaryURLs.searchResourceDictionaryByNames, variables); } + + } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.store.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.store.ts index f64e361d4..b60831238 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.store.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.store.ts @@ -106,6 +106,10 @@ export class PackageCreationStore extends Store<CBAPackage> { return this.packageCreationService.enrichPackage(blob); } + deployBluePrint(blob): Observable<BluePrintDetailModel> { + return this.packageCreationService.deploy(blob); + } + addTemplate(filePath: string, fileContent: string) { this.setState({ ...this.state, |