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.ngxLoader.start();
43 this.packagesStore.getAll();
47 this.router.navigate(['/packages/package', id]);
50 testDispatch(bluePrint: BlueprintModel) {
51 console.log(bluePrint.id);
54 downloadPackage(artifactName: string, artifactVersion: string) {
55 this.configurationDashboardService.downloadResource(artifactName + '/' + artifactVersion).subscribe(response => {
56 const blob = new Blob([response], {type: 'application/octet-stream'});
57 saveAs(blob, artifactName + '-' + artifactVersion + '-CBA.zip');
61 viewDesigner(id: string) {
62 this.router.navigate(['/packages/designer', id, {actionName: ''}]);
65 deletePackage(id: string) {
66 this.configurationDashboardService.deletePackage(id).subscribe(res => {
67 this.toastService.success('Package Deleted Successfully ');
68 this.router.navigate(['/packages']);
69 this.packagesStore.getAll();
71 this.toastService.error('Error occured during deleting package ' + err.message);