diff options
author | shaaban Altanany <shaaban.eltanany.ext@orange.com> | 2020-02-26 10:05:02 +0200 |
---|---|---|
committer | shaaban Altanany <shaaban.eltanany.ext@orange.com> | 2020-02-26 15:34:55 +0200 |
commit | ac31d2159014a84de91b6c7baeb29adf90284c10 (patch) | |
tree | 318eec8bed0c51529d4d746dede6fb8e2737bc2b /cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/package.store.ts | |
parent | c99df5dd491c9f18044ec483e696739080e80950 (diff) |
add view feature and decompress zip file
-decompress package zip file
-getting content and file names
Issue-ID: CCSDK-2120
Signed-off-by: shaaban Altanany <shaaban.eltanany.ext@orange.com>
Change-Id: If930b257a9dd7b8e094958aad006ff3769810cb3
Diffstat (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/package.store.ts')
-rw-r--r-- | cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/package.store.ts | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/package.store.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/package.store.ts index efbaef8bd..cf2d42db7 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/package.store.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/package.store.ts @@ -21,16 +21,17 @@ limitations under the License. import {Injectable} from '@angular/core'; import {Store} from '../../../../common/core/stores/Store'; -import {BluePrintDetailModel} from '../model/BluePrint.detail.model'; import {ConfigurationDashboardService} from './configuration-dashboard.service'; import {PackageDashboardState} from '../model/package-dashboard.state'; - +import {BlueprintURLs} from '../../../../common/constants/app-constants'; +import * as JSZip from 'jszip'; @Injectable({ providedIn: 'root' }) export class PackageStore extends Store<PackageDashboardState> { + private zipFile: JSZip = new JSZip(); constructor(private configurationDashboardService: ConfigurationDashboardService) { super(new PackageDashboardState()); @@ -44,15 +45,41 @@ export class PackageStore extends Store<PackageDashboardState> { configuration: bluePrintDetailModels[0] }); }); - /* bluePrintDetailModels.forEach( - bluePrintDetailModel => { - this.setState({ - ...this.state, - configuration: bluePrintDetailModel - }); - });*/ + } + + public downloadResource(path: string) { + this.configurationDashboardService.downloadResource(BlueprintURLs.download + path).subscribe(response => { + const blob = new Blob([response], {type: 'application/octet-stream'}); + 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/')) { + this.setTemplates(filename, fileData); + } else if (filename.includes('definitions/')) { + this.setImports(filename, fileData); + } + } + }); + }); + }); + }); + } + + private setScripts(filename: string, fileData: any) { + this.setState({ + ...this.state, + scripts: this.state.scripts.setScripts(name, fileData) + }); + } + private setImports(filename: string, fileData: any) { } + private setTemplates(filename: string, fileData: any) { + + } } |