rsanchez
2017-03-15 a6b5178c7295be4525ee0f607e42f72a12a2e3d6
securis/src/main/webapp/src/app/license.list.component.ts
....@@ -1,10 +1,13 @@
1
-import { Router } from '@angular/router';
1
+import { LocaleService } from './common/i18n';
2
+import { ActivatedRoute, Router } from '@angular/router';
23 import { MdDialog, MdDialogConfig } from '@angular/material';
34 import { TdDataTableService, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core';
45 import { IPageChangeEvent } from '@covalent/core';
56 import { Component, AfterViewInit } from '@angular/core';
67 import { TdMediaService } from '@covalent/core';
78 import { LicensesService } from './resources/licenses';
9
+import { PacksService } from './resources/packs';
10
+
811 import { LicenseFormComponent } from './forms/license.form.component';
912
1013 var lic_example = { activation_code: '19fa8d30-29cb-4b59-81b5-3837af8204b6',
....@@ -34,12 +37,13 @@
3437 })
3538 export class LicenseListComponent implements AfterViewInit {
3639 data: any[] = [];
40
+ pack: any = null;
3741 columns: ITdDataTableColumn[] = [
38
- { name: 'code', label: 'Code', tooltip: 'License pack code' },
39
- { name: 'application_name', label: 'App name' },
40
- { name: 'licensetype_code', label: 'License type' },
41
- { name: 'organization_name', label: 'Organization' },
42
- { name: 'used_licenses', label: 'Lics', tooltip: 'Initial/Available pack licenses' },
42
+ { name: 'code', label: 'Code', tooltip: 'License code' },
43
+ { name: 'full_name', label: 'User name' },
44
+ { name: 'email', label: 'User email' },
45
+ { name: 'expiration_date', label: 'Expiration date' },
46
+ { name: 'status', label: 'Status' },
4347 { name: 'menu', label: '' }
4448 ];
4549
....@@ -50,7 +54,7 @@
5054 fromRow: number = 1;
5155 currentPage: number = 1;
5256 pageSize: number = 10;
53
- sortBy: string = 'application_name';
57
+ sortBy: string = 'expiration_date';
5458 sortOrder: TdDataTableSortingOrder = TdDataTableSortingOrder.Descending;
5559 filteredItems = this.data.length;
5660 license_menu_options : any[] = [{
....@@ -73,21 +77,36 @@
7377
7478 constructor(private _dataTableService: TdDataTableService,
7579 private media: TdMediaService,
80
+ private $L: LocaleService,
7681 private router: Router,
82
+ private route: ActivatedRoute,
7783 private dialog: MdDialog,
7884 private licenseForm: LicenseFormComponent,
79
- private licenses: LicensesService) {
80
- this.licenses.get().subscribe(
81
- list => {
82
- this.data = list;
83
- this.filter();
84
- },
85
- err => console.error(err)
86
- );
85
+ private licenses: LicensesService,
86
+ private packs: PacksService) {
8787 }
8888
8989 ngOnInit(): void {
90
- this.filter();
90
+ this.route.params.subscribe(params => {
91
+ var packId = +params['id']; // (+) converts string 'id' to a number
92
+ this.licenses.getByPack(packId).subscribe(
93
+ list => {
94
+ this.data = list;
95
+ this.filter();
96
+ },
97
+ err => console.error(err)
98
+ );
99
+ this.packs.get(packId).subscribe(
100
+ packData => {
101
+ this.pack = packData;
102
+ },
103
+ err => console.error(err)
104
+ );
105
+ });
106
+ }
107
+
108
+ isLicenseExpired(lic: any): boolean {
109
+ return lic.expiration_date < (new Date().getTime());
91110 }
92111
93112 createLicense() : void {