diff options
author | 2020-09-28 17:24:34 +0200 | |
---|---|---|
committer | 2020-09-28 17:26:41 +0200 | |
commit | 4ea4a4c90d1ecee5430bd99ded79856392fd9ecb (patch) | |
tree | eee4ec5fcfd05e54300d6dfa96d660ccc65db603 /cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard | |
parent | 809ebd8d7974b1a658fb7f7a8a2466ca5d13bf52 (diff) |
refactor package creation service and blob extractor
Issue-ID: CCSDK-2298
Signed-off-by: ShaabanEltanany <shaaban.eltanany.ext@orange.com>
Change-Id: I2a83f8db4d67c8e8114ce7c85f0c227c86046b53
Diffstat (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard')
-rw-r--r-- | cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts | 95 |
1 files changed, 3 insertions, 92 deletions
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 eb121e98e..e86a2c500 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 @@ -7,7 +7,7 @@ import {MetadataTabComponent} from '../package-creation/metadata-tab/metadata-ta import * as JSZip from 'jszip'; import {ConfigurationDashboardService} from './configuration-dashboard.service'; import {TemplateTopology, VlbDefinition} from '../package-creation/mapping-models/definitions/VlbDefinition'; -import {CBAPackage, DslDefinition} from '../package-creation/mapping-models/CBAPacakge.model'; +import {CBAPackage} from '../package-creation/mapping-models/CBAPacakge.model'; import {PackageCreationUtils} from '../package-creation/package-creation.utils'; import {PackageCreationModes} from '../package-creation/creationModes/PackageCreationModes'; import {PackageCreationBuilder} from '../package-creation/creationModes/PackageCreationBuilder'; @@ -89,7 +89,6 @@ export class ConfigurationDashboardComponent extends ComponentCanDeactivate impl } - private refreshCurrentPackage(id?) { this.id = this.route.snapshot.paramMap.get('id'); console.log(this.id); @@ -109,80 +108,10 @@ export class ConfigurationDashboardComponent extends ComponentCanDeactivate impl this.viewedPackage.artifactName + '/' + this.viewedPackage.artifactVersion).subscribe(response => { const blob = new Blob([response], {type: 'application/octet-stream'}); this.currentBlob = blob; - this.extractBlobToStore(blob, this.viewedPackage); - }); - } - - 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) => { - 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, bluePrintDetailModel); - } else if (filename.includes('TOSCA-Metadata/')) { - const metaDataTabInfo: MetaDataTabModel = this.getMetaDataTabInfo(fileData); - this.setMetaData(metaDataTabInfo, bluePrintDetailModel); - } - } - }); - }); + this.packageCreationExtractionService.extractBlobToStore(blob); }); } - setScripts(filename: string, fileData: any) { - this.packageCreationStore.addScripts(filename, fileData); - } - - setImports(filename: string, fileData: any, bluePrintDetailModels: BluePrintDetailModel) { - console.log(filename); - if (filename.includes(bluePrintDetailModels.artifactName)) { - let definition = new VlbDefinition(); - definition = fileData as VlbDefinition; - definition = JSON.parse(fileData); - const dslDefinition = new DslDefinition(); - dslDefinition.content = this.packageCreationUtils.transformToJson(definition.dsl_definitions); - const mapOfCustomKeys = new Map<string, string>(); - for (const metadataKey in definition.metadata) { - if (!this.entryDefinitionKeys.includes(metadataKey + '')) { - mapOfCustomKeys.set(metadataKey + '', definition.metadata[metadataKey + '']); - } - } - this.packageCreationStore.changeDslDefinition(dslDefinition); - this.packageCreationStore.setCustomKeys(mapOfCustomKeys); - if (definition.topology_template) { - const content = {}; - const workflow = 'workflows'; - content[workflow] = definition.topology_template.workflows; - const nodeTemplates = 'node_templates'; - content[nodeTemplates] = definition.topology_template.node_templates; - this.designerStore.saveSourceContent(JSON.stringify(content)); - this.packageCreationStore.addTopologyTemplate(definition.topology_template); - } - - } - this.packageCreationStore.addDefinition(filename, fileData); - - } - - setTemplates(filename: string, fileData: any) { - this.packageCreationStore.addTemplate(filename, fileData); - } - - setMapping(fileName: string, fileData: string) { - this.packageCreationStore.addMapping(fileName, fileData); - } - editBluePrint() { this.configurationDashboardService.deletePackage(this.viewedPackage.id).subscribe(res => { this.formTreeData(); @@ -201,26 +130,8 @@ export class ConfigurationDashboardComponent extends ComponentCanDeactivate impl this.filesData.push(this.folder.TREE_DATA); } - setMetaData(metaDataObject: MetaDataTabModel, bluePrintDetailModel: BluePrintDetailModel) { - metaDataObject.description = bluePrintDetailModel.artifactDescription; - this.packageCreationStore.changeMetaData(metaDataObject); - - } - saveMetaData() { this.metadataTabComponent.saveMetaDataToStore(); - - } - - getMetaDataTabInfo(fileData: string) { - const metaDataTabModel = new MetaDataTabModel(); - const arrayOfLines = fileData.split('\n'); - metaDataTabModel.entryFileName = arrayOfLines[3].split(':')[1]; - metaDataTabModel.name = arrayOfLines[4].split(':')[1]; - metaDataTabModel.version = arrayOfLines[5].split(':')[1]; - metaDataTabModel.mode = arrayOfLines[6].split(':')[1]; - metaDataTabModel.templateTags = new Set<string>(arrayOfLines[7].split(':')[1].split(',')); - return metaDataTabModel; } saveBluePrintToDataBase() { @@ -316,7 +227,7 @@ export class ConfigurationDashboardComponent extends ComponentCanDeactivate impl const blobInfo = new Blob([response], {type: 'application/octet-stream'}); this.currentBlob = blobInfo; this.packageCreationStore.clear(); - this.extractBlobToStore(this.currentBlob, this.viewedPackage); + this.packageCreationExtractionService.extractBlobToStore(this.currentBlob); this.isSaveEnabled = true; this.toastService.info('enriched successfully '); }); |