rsanchez
2017-03-22 60c65f2110f65221bc3a71b2887667e78c53c53e
securis/src/main/webapp/src/app/forms/pack.form.component.ts
....@@ -1,7 +1,7 @@
11 import { Http } from '@angular/http';
22 import { ToastsManager } from 'ng2-toastr/ng2-toastr';
33
4
-import { PacksService, PACK_STATUS } from '../resources/packs';
4
+import { PacksService, PACK_STATUS, PACK_ACTIONS } from '../resources/packs';
55 import { LicenseTypesService } from '../resources/license_types';
66 import { LocaleService } from '../common/i18n';
77 import { TdDataTableService, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core';
....@@ -21,7 +21,7 @@
2121
2222 organizations : IComboOption[];
2323 licensetypes : IComboOption[];
24
-
24
+ pack_menu_options = PACK_ACTIONS;
2525 constructor(private http: Http,
2626 private licenseTypes: LicenseTypesService,
2727 private packs: PacksService,
....@@ -65,11 +65,27 @@
6565 );
6666 }
6767
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
+
6878 changeOrg(event: any) {
69
- console.log(event);
7079 console.log(this.data.organization_id);
7180 }
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
+ }
7389
7490 ngAfterViewInit(): void {
7591 this.init();