| .. | .. |
|---|
| 1 | 1 | import { Http } from '@angular/http'; |
|---|
| 2 | 2 | import { ToastsManager } from 'ng2-toastr/ng2-toastr'; |
|---|
| 3 | 3 | |
|---|
| 4 | | -import { PacksService, PACK_STATUS } from '../resources/packs'; |
|---|
| 4 | +import { PacksService, PACK_STATUS, PACK_ACTIONS } from '../resources/packs'; |
|---|
| 5 | 5 | import { LicenseTypesService } from '../resources/license_types'; |
|---|
| 6 | 6 | import { LocaleService } from '../common/i18n'; |
|---|
| 7 | 7 | import { TdDataTableService, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core'; |
|---|
| .. | .. |
|---|
| 21 | 21 | |
|---|
| 22 | 22 | organizations : IComboOption[]; |
|---|
| 23 | 23 | licensetypes : IComboOption[]; |
|---|
| 24 | | - |
|---|
| 24 | + pack_menu_options = PACK_ACTIONS; |
|---|
| 25 | 25 | constructor(private http: Http, |
|---|
| 26 | 26 | private licenseTypes: LicenseTypesService, |
|---|
| 27 | 27 | private packs: PacksService, |
|---|
| .. | .. |
|---|
| 65 | 65 | ); |
|---|
| 66 | 66 | } |
|---|
| 67 | 67 | |
|---|
| 68 | + packAction(action: string) { |
|---|
| 69 | + return this.packs[action](this.data.id).subscribe( |
|---|
| 70 | + (actionResponse : any) => { |
|---|
| 71 | + this.toaster.success(this.$L.get('Action "{}" executed successfully', action)); |
|---|
| 72 | + this.reload(); |
|---|
| 73 | + }, |
|---|
| 74 | + (err : any) => this.toaster.error(this.$L.get('Action "{}" failed', action)) |
|---|
| 75 | + ); |
|---|
| 76 | + } |
|---|
| 77 | + |
|---|
| 68 | 78 | changeOrg(event: any) { |
|---|
| 69 | | - console.log(event); |
|---|
| 70 | 79 | console.log(this.data.organization_id); |
|---|
| 71 | 80 | } |
|---|
| 72 | | - |
|---|
| 81 | + |
|---|
| 82 | + canBeDeleted(event: any) : boolean{ |
|---|
| 83 | + return !this.isNew && this.packs.isActionAvailable('delete', this.data); |
|---|
| 84 | + } |
|---|
| 85 | + |
|---|
| 86 | + convertToEpoch(str: string) : number { |
|---|
| 87 | + return new Date(str).getTime(); |
|---|
| 88 | + } |
|---|
| 73 | 89 | |
|---|
| 74 | 90 | ngAfterViewInit(): void { |
|---|
| 75 | 91 | this.init(); |
|---|