diff options
Diffstat (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard')
2 files changed, 35 insertions, 32 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 a25f43444..766e0b120 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 @@ -1,7 +1,7 @@ -import {Component, OnInit} from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; -import {PackageStore} from './package.store'; -import {BluePrintDetailModel} from '../model/BluePrint.detail.model'; +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { PackageStore } from './package.store'; +import { BluePrintDetailModel } from '../model/BluePrint.detail.model'; @Component({ @@ -13,23 +13,22 @@ export class ConfigurationDashboardComponent implements OnInit { viewedPackage: BluePrintDetailModel = new BluePrintDetailModel(); constructor(private route: ActivatedRoute, private configurationStore: PackageStore) { - - const id = this.route.snapshot.paramMap.get('id'); - this.configurationStore.getPagedPackages(id); - - } - + // test ngOnInit() { - this.configurationStore.state$.subscribe( - el => { - if (el && el.configuration) { - this.viewedPackage = el.configuration; + const id = this.route.snapshot.paramMap.get('id'); + this.configurationStore.getPagedPackages(id).subscribe( + (bluePrintDetailModels) => { + console.log('-------------xxxxxxxxxxx----------------'); + console.log(bluePrintDetailModels); + this.configurationStore.setConfiguration(bluePrintDetailModels); + + console.log('----------------- id ' + id); + if (bluePrintDetailModels) { this.configurationStore.downloadResource( - this.viewedPackage.artifactName + '/' + this.viewedPackage.artifactVersion); + bluePrintDetailModels[0].artifactName + '/' + bluePrintDetailModels[0].artifactVersion); } - } - ); + }); } } 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 cf2d42db7..4669ef12d 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 @@ -19,11 +19,11 @@ limitations under the License. ============LICENSE_END============================================ */ -import {Injectable} from '@angular/core'; -import {Store} from '../../../../common/core/stores/Store'; -import {ConfigurationDashboardService} from './configuration-dashboard.service'; -import {PackageDashboardState} from '../model/package-dashboard.state'; -import {BlueprintURLs} from '../../../../common/constants/app-constants'; +import { Injectable } from '@angular/core'; +import { Store } from '../../../../common/core/stores/Store'; +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({ @@ -38,23 +38,20 @@ export class PackageStore extends Store<PackageDashboardState> { } getPagedPackages(id: string) { - this.configurationDashboardService.getBluePrintModel(id).subscribe( - (bluePrintDetailModels) => { - this.setState({ - ...this.state, - configuration: bluePrintDetailModels[0] - }); - }); + return this.configurationDashboardService.getBluePrintModel(id); } public downloadResource(path: string) { + console.log('download resource xx'); this.configurationDashboardService.downloadResource(BlueprintURLs.download + path).subscribe(response => { - const blob = new Blob([response], {type: 'application/octet-stream'}); + console.log('try to download '); + const blob = new Blob([response], { type: 'application/octet-stream' }); this.zipFile.loadAsync(blob).then((zip) => { Object.keys(zip.files).forEach((filename) => { + console.log(filename); zip.files[filename].async('string').then((fileData) => { if (fileData) { - if (filename.includes('scripts/')) { + if (filename.includes('Scripts/')) { this.setScripts(filename, fileData); } else if (filename.includes('templates/')) { this.setTemplates(filename, fileData); @@ -68,10 +65,17 @@ export class PackageStore extends Store<PackageDashboardState> { }); } + setConfiguration(bluePrintDetailModels) { + this.setState({ + ...this.state, + configuration: bluePrintDetailModels[0] + }); + } + private setScripts(filename: string, fileData: any) { this.setState({ ...this.state, - scripts: this.state.scripts.setScripts(name, fileData) + scripts: this.state.scripts.setScripts(filename, fileData) }); } |