3cecd33fd55e5a8cb09d251cda5c462978829f85
[ccsdk/cds.git] /
1 import { Component, OnInit } from '@angular/core';
2 import { BlueprintModel } from '../../model/BluePrint.model';
3 import { PackagesStore } from '../../packages.store';
4 import { Router } from '@angular/router';
5 import { ConfigurationDashboardService } from '../../configuration-dashboard/configuration-dashboard.service';
6 import { saveAs } from 'file-saver';
7 import { NgxUiLoaderService } from 'ngx-ui-loader';
8 import { TourService } from 'ngx-tour-md-menu';
9
10 @Component({
11     selector: 'app-packages-list',
12     templateUrl: './package-list.component.html',
13     styleUrls: ['./package-list.component.css']
14 })
15 export class PackageListComponent implements OnInit {
16
17     viewedPackages: BlueprintModel[] = [];
18
19
20     constructor(
21         private packagesStore: PackagesStore,
22         private router: Router,
23         private configurationDashboardService: ConfigurationDashboardService,
24         private ngxLoader: NgxUiLoaderService,
25         private tourService: TourService,
26     ) {
27         console.log('PackageListComponent');
28
29
30
31         this.packagesStore.state$.subscribe(state => {
32             console.log(state);
33             if (state.filteredPackages) {
34                 this.viewedPackages = state.filteredPackages.content;
35             }
36         });
37     }
38
39
40     ngOnInit() {
41         this.packagesStore.getAll();
42
43
44
45
46     }
47
48     view(id) {
49         this.router.navigate(['/packages/package', id]);
50     }
51
52     testDispatch(bluePrint: BlueprintModel) {
53         console.log(bluePrint.id);
54     }
55
56     downloadPackage(artifactName: string, artifactVersion: string) {
57         this.configurationDashboardService.downloadResource(artifactName + '/' + artifactVersion).subscribe(response => {
58             const blob = new Blob([response], { type: 'application/octet-stream' });
59             saveAs(blob, artifactName + '-' + artifactVersion + '-CBA.zip');
60         });
61     }
62 }