add basic download for current viewed package 63/102563/1
authorshaaban Altanany <shaaban.eltanany.ext@orange.com>
Fri, 28 Feb 2020 09:27:44 +0000 (11:27 +0200)
committershaaban Altanany <shaaban.eltanany.ext@orange.com>
Fri, 28 Feb 2020 09:27:44 +0000 (11:27 +0200)
Issue-ID: CCSDK-2126

Signed-off-by: shaaban Altanany <shaaban.eltanany.ext@orange.com>
Change-Id: I8690018634b55734d3b9dcf66794c44c4d266c92

cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.html
cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts
cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.service.ts
cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/package.store.ts [deleted file]
cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.ts
cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab/scripts-tab.component.ts

index 6194a9b..0cd5673 100644 (file)
@@ -20,7 +20,7 @@
 
 
 
-        <div class="container-fluid body-container">                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
+        <div class="container-fluid body-container">
 
             <div class="container">
                <!-- <div class="creat-action-container">
                                     <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>
index 1fcc35f..c67331c 100644 (file)
@@ -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']);
+    }
+
 }
index 239dd63..164d766 100644 (file)
@@ -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 (file)
index 49de59e..0000000
+++ /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);
-    }*/
-
-
-}
index b999257..63c10ad 100644 (file)
@@ -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
+    ) {
 
     }
 
index bce14c9..36cccc8 100644 (file)
@@ -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[]) {