352f33b910d6ab05c105420ecf9eecb78f20eba3
[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
8 @Component({
9     selector: 'app-packages-list',
10     templateUrl: './package-list.component.html',
11     styleUrls: ['./package-list.component.css']
12 })
13 export class PackageListComponent implements OnInit {
14
15     viewedPackages: BlueprintModel[] = [];
16
17
18     constructor(private packagesStore: PackagesStore, private router: Router
19               , private configurationDashboardService: ConfigurationDashboardService) {
20         console.log('PackageListComponent');
21         this.packagesStore.state$.subscribe(state => {
22             console.log(state);
23             if (state.filteredPackages) {
24                 this.viewedPackages = state.filteredPackages.content;
25             }
26         });
27     }
28
29     ngOnInit() {
30         this.packagesStore.getAll();
31     }
32
33     view(id) {
34         this.router.navigate(['/packages/package', id]);
35     }
36
37     testDispatch(bluePrint: BlueprintModel) {
38         console.log(bluePrint.id);
39     }
40
41     downloadPackage(artifactName: string, artifactVersion: string) {
42         this.configurationDashboardService.downloadResource(artifactName + '/' + artifactVersion).subscribe(response => {
43             const blob = new Blob([response], {type: 'application/octet-stream'});
44             saveAs(blob, artifactName + '-' + artifactVersion + '-CBA.zip');
45         });
46     }
47 }