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 import {ToastrService} from 'ngx-toastr';
12 selector: 'app-packages-list',
13 templateUrl: './package-list.component.html',
14 styleUrls: ['./package-list.component.css']
16 export class PackageListComponent implements OnInit {
18 viewedPackages: BlueprintModel[] = [];
22 private packagesStore: PackagesStore,
23 private router: Router,
24 private configurationDashboardService: ConfigurationDashboardService,
25 private ngxLoader: NgxUiLoaderService,
26 private tourService: TourService,
27 private toastService: ToastrService
29 console.log('PackageListComponent');
32 this.packagesStore.state$.subscribe(state => {
34 if (state.filteredPackages) {
35 this.viewedPackages = state.filteredPackages.content;
42 this.packagesStore.getAll();
46 this.router.navigate(['/packages/package', id]);
49 testDispatch(bluePrint: BlueprintModel) {
50 console.log(bluePrint.id);
53 downloadPackage(artifactName: string, artifactVersion: string) {
54 this.configurationDashboardService.downloadResource(artifactName + '/' + artifactVersion).subscribe(response => {
55 const blob = new Blob([response], {type: 'application/octet-stream'});
56 saveAs(blob, artifactName + '-' + artifactVersion + '-CBA.zip');
60 viewDesigner(id: string) {
61 this.router.navigate(['/packages/designer', id]);
64 deletePackage(id: string) {
65 this.configurationDashboardService.deletePackage(id).subscribe(res => {
66 this.toastService.info('package deleted successfully ');
67 this.router.navigate(['/packages']);
68 this.packagesStore.getAll();
70 this.toastService.error('error deleting package' + err.message);