diff options
author | shaaban Altanany <shaaban.eltanany.ext@orange.com> | 2020-02-28 11:27:44 +0200 |
---|---|---|
committer | shaaban Altanany <shaaban.eltanany.ext@orange.com> | 2020-02-28 11:27:44 +0200 |
commit | 0dda490e7e26860a33170829ce561dd1d2979ecb (patch) | |
tree | 78e7da020effcf8354005447188b750597660663 | |
parent | b2b847587d7c06db5737a06820d1809b9aeb73e1 (diff) |
add basic download for current viewed package
Issue-ID: CCSDK-2126
Signed-off-by: shaaban Altanany <shaaban.eltanany.ext@orange.com>
Change-Id: I8690018634b55734d3b9dcf66794c44c4d266c92
6 files changed, 50 insertions, 70 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 6194a9bb3..0cd56732d 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 @@ -20,7 +20,7 @@ - <div class="container-fluid body-container"> + <div class="container-fluid body-container"> <div class="container"> <!-- <div class="creat-action-container"> @@ -49,12 +49,12 @@ <div class="package-name-container"> <div class="row"> <div class="col-12 package-name deployed"> - Package Name + {{viewedPackage.artifactName}} <span>.vLB.CDS</span> <i class="icon-deploy"></i> </div> <div class="col-12 package-description"> - Last modified Oct 4, 2019 03:48 PM By Ahmed Abbas + Last modified {{ viewedPackage.createdDate | date:'short' }} By {{viewedPackage.updatedBy}} </div> </div> @@ -63,7 +63,9 @@ </div> </div> <div class="col-4 package-view-button"> - <button class="btn btn-sm btn-outline-secondary"><i class="fa fa-play-circle"></i> Deploy</button> + <button class="btn btn-sm btn-outline-secondary" (click)="deployCurrentPackage()"><i class="fa fa-play-circle"></i> Deploy</button> + <button class="btn btn-sm btn-outline-secondary" (click)="downloadPackage(viewedPackage.artifactName,viewedPackage.artifactVersion)"><i class="fa"></i> Download</button> + <button class="btn btn-sm btn-primary">Designer Mode</button> </div> </div> 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 1fcc35f5a..c67331c3e 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 @@ -11,7 +11,7 @@ import {DslDefinition} 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'; - +import {saveAs} from 'file-saver'; @Component({ selector: 'app-configuration-dashboard', @@ -32,6 +32,8 @@ export class ConfigurationDashboardComponent implements OnInit { private filesData: any = []; private folder: FolderNodeElement = new FolderNodeElement(); + private currentBlob = new Blob(); + constructor(private route: ActivatedRoute, private configurationDashboardService: ConfigurationDashboardService, private packageCreationStore: PackageCreationStore, private packageCreationUtils: PackageCreationUtils, @@ -44,6 +46,7 @@ export class ConfigurationDashboardComponent implements OnInit { this.configurationDashboardService.getPagedPackages(id).subscribe( (bluePrintDetailModels) => { if (bluePrintDetailModels) { + this.viewedPackage = bluePrintDetailModels[0]; this.downloadCBAPackage(bluePrintDetailModels); } }); @@ -54,6 +57,7 @@ export class ConfigurationDashboardComponent implements OnInit { this.configurationDashboardService.downloadResource( 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) => { console.log(filename); @@ -172,4 +176,28 @@ export class ConfigurationDashboardComponent implements OnInit { goBacktoDashboard() { this.router.navigate(['/packages']); } + + downloadPackage(artifactName: string, artifactVersion: string) { + this.configurationDashboardService.downloadResource(artifactName + '/' + artifactVersion).subscribe(response => { + const blob = new Blob([response], {type: 'application/octet-stream'}); + saveAs(blob, artifactName + '-' + artifactVersion + '-CBA.zip'); + }); + } + + deployCurrentPackage() { + console.log('happened'); + /* this.zipFile.generateAsync({type: 'blob'}) + .then(blob => { + const formData = new FormData(); + formData.append('file', this.currentBlob); + this.configurationDashboardService.deployPost(formData) + .subscribe(data => { + }, error => { + }); + this.router.navigate(['/packages']); + }); + */ + this.router.navigate(['/packages']); + } + } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.service.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.service.ts index 239dd6339..164d76601 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.service.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.service.ts @@ -16,6 +16,7 @@ export class ConfigurationDashboardService { private getBluePrintModel(id: string): Observable<BluePrintDetailModel> { return this.api.getOne(BlueprintURLs.getOneBlueprint + '/' + id); } + getPagedPackages(id: string) { return this.getBluePrintModel(id); } @@ -24,4 +25,7 @@ export class ConfigurationDashboardService { return this.api.getCustomized(BlueprintURLs.download + path, {responseType: 'blob'}); } + deployPost(body: any | null): Observable<any> { + return this.api.post(BlueprintURLs.deploy, body, {responseType: 'text'}); + } } 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 deleted file mode 100644 index 49de59e62..000000000 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/package.store.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -============LICENSE_START========================================== -=================================================================== -Copyright (C) 2019 Orange. All rights reserved. -=================================================================== - -Unless otherwise specified, all software contained herein is licensed -under the Apache License, Version 2.0 (the License); -you may not use this software except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -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 * 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()); - } - - /* getPagedPackages(id: string) { - return this.configurationDashboardService.getBluePrintModel(id); - } - - public downloadResource(path: string) { - return this.configurationDashboardService.downloadResource(BlueprintURLs.download + path); - }*/ - - -} diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.ts index b99925716..63c10ad7b 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.ts @@ -2,7 +2,6 @@ import {Component, OnInit} from '@angular/core'; import {PackageCreationService} from '../package-creation.service'; import {MetaDataTabModel} from '../mapping-models/metadata/MetaDataTab.model'; import {PackageCreationStore} from '../package-creation.store'; -import {PackageStore} from '../../configuration-dashboard/package.store'; import {ActivatedRoute} from '@angular/router'; @@ -25,8 +24,8 @@ export class MetadataTabComponent implements OnInit { constructor(private route: ActivatedRoute, private packageCreationService: PackageCreationService, - private packageCreationStore: PackageCreationStore, - private packageStore: PackageStore) { + private packageCreationStore: PackageCreationStore + ) { } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab/scripts-tab.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab/scripts-tab.component.ts index bce14c980..36cccc88c 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab/scripts-tab.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab/scripts-tab.component.ts @@ -1,10 +1,8 @@ -import { Component, OnInit } from '@angular/core'; -import { FileSystemFileEntry, NgxFileDropEntry } from 'ngx-file-drop'; -import { PackageCreationStore } from '../package-creation.store'; -import { PackageCreationUtils } from '../package-creation.utils'; +import {Component, OnInit} from '@angular/core'; +import {FileSystemFileEntry, NgxFileDropEntry} from 'ngx-file-drop'; +import {PackageCreationStore} from '../package-creation.store'; import 'ace-builds/src-noconflict/ace'; import 'ace-builds/webpack-resolver'; -import { PackageStore } from '../../configuration-dashboard/package.store'; @Component({ selector: 'app-scripts-tab', @@ -20,8 +18,6 @@ export class ScriptsTabComponent implements OnInit { constructor( private packageCreationStore: PackageCreationStore, - private packageCreationUtils: PackageCreationUtils, - private packageStore: PackageStore ) { } @@ -34,12 +30,12 @@ export class ScriptsTabComponent implements OnInit { } }); - this.packageStore.state$.subscribe(res => { - // this.scriptsFiles = - console.log('from scripts'); - console.log(res.scripts); - this.scriptsFiles = res.scripts.files; - }); + /* this.packageStore.state$.subscribe(res => { + // this.scriptsFiles = + console.log('from scripts'); + console.log(res.scripts); + this.scriptsFiles = res.scripts.files; + });*/ } public dropped(files: NgxFileDropEntry[]) { |