1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
| | import { LocaleService } from './common/i18n';
| | import { ActivatedRoute, Router } from '@angular/router';
| | import { MdDialog, MdDialogConfig } from '@angular/material';
| | import { TdDataTableService, TdPagingBarComponent, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core';
| | import { IPageChangeEvent } from '@covalent/core';
| | import { Component, AfterViewInit, ViewChild } from '@angular/core';
| | import { TdMediaService } from '@covalent/core';
| | import { LicensesService } from './resources/licenses';
| | import { PacksService } from './resources/packs';
| | import { Location } from '@angular/common';
| |
| | import { LicenseFormComponent } from './forms/license.form.component';
| |
| | var lic_example = { activation_code: '19fa8d30-29cb-4b59-81b5-3837af8204b6',
| | code: 'CISA02-494-1',
| | code_suffix: 1,
| | created_by_id: '_client',
| | creation_timestamp: 1447848747000,
| | email: 'ccalvo@curisit.net',
| | expiration_date: 1450440747000,
| | full_name: 'César SA',
| | id: 110,
| | licenseData: '{"appCode":"CISA","appName":"CurisIntegrity SA","licenseCode":"CISA02-494-1","activationCode":"19fa8d30-29cb-4b59-81b5-3837af8204b6","expirationDate":1450440746790,"arch":"x86_64","osName":"Mac OS X","macAddresses":["60-03-08-95-AE-D0","B6-2B-33-E9-64-2D"],"crcLogo":"10f6379e0e1c00ebc403160307e3c5d0aba0727c9cae0bf1ac7cd19d84fdc80f","metadata":{"maxWellLifeLines":"50","simulationModes":"A1,A2,N1,QL"},"signature":"Tejun4bNbknxOyEmPaO/fGfGhv4URhVON/7bESxbODFWMJYKQqOPHrDiSUMlf6RbfWSVg2Dry8bY1WX881QGjTkBaHeDJKCy1EaJBwJ2nv9TYSMOiRj0eqMNYWE9/oLpvufHylAkPUpZwXVkSzTxmN+RvWa2Xt4Fu7xN+4PDHV4t7PSq7QwsFlD9ArgYC6Vx+zuL9WZANBtJ2gU/gKOE0CU0KjsB49RGQSFS/G27+H/YuDkCiQq7PC7VdVwYONQ2HO91fyPvInIrzDC5+sWHcUAqSCop//8klMy03hWl6VvAlaSP7kNM3KadyqXIJ3tx4Jwm1W+gBb3tngHzVCpYmw=="}',
| | modification_timestamp: 1447848747000,
| | pack_code: 'CISA02',
| | pack_id: 18,
| | request_data: '{"appCode":"CISA","activationCode":"19fa8d30-29cb-4b59-81b5-3837af8204b6","arch":"x86_64","osName":"Mac OS X","macAddresses":["60-03-08-95-AE-D0","B6-2B-33-E9-64-2D"],"crcLogo":"10f6379e0e1c00ebc403160307e3c5d0aba0727c9cae0bf1ac7cd19d84fdc80f"}',
| | status: 'AC' }
| |
| | const DIALOG_OPTIONS : MdDialogConfig = {
| | height: '80%', // can be px or %
| | width: '45%', // can be px or %
| | }
| |
| | @Component({
| | selector: 'license-list',
| | templateUrl: 'src/app/license.list.component.html'
| | })
| | export class LicenseListComponent implements AfterViewInit {
| | data: any[] = [];
| | @ViewChild('pagingBar') pagingBar : TdPagingBarComponent ;
| |
| | pack: any = null;
| | columns: ITdDataTableColumn[] = [
| | { name: 'code', label: 'Code', tooltip: 'License code' },
| | { name: 'full_name', label: 'User name' },
| | { name: 'email', label: 'User email' },
| | { name: 'expiration_date', label: 'Expiration date' },
| | { name: 'status', label: 'Status' },
| | { name: 'menu', label: '' }
| | ];
| |
| | filteredData: any[] = this.data;
| | filteredTotal: number = this.data.length;
| |
| | searchTerm: string = '';
| | fromRow: number = 1;
| | currentPage: number = 1;
| | pageSize: number = 10;
| | sortBy: string = 'expiration_date';
| | sortOrder: TdDataTableSortingOrder = TdDataTableSortingOrder.Descending;
| | filteredItems = this.data.length;
| | license_menu_options : any[] = [{
| | icon: 'edit',
| | command: 'edit',
| | name: 'Edit'
| | },{
| | icon: 'cancel',
| | command: 'cancel',
| | name: 'Cancel'
| | }]
| |
| | licenseAction(action: any) {
| | console.log(action.command);
| | }
| |
| | isActionAvailable(pack : any) : boolean {
| | return true;
| | }
| |
| | constructor(private _dataTableService: TdDataTableService,
| | private media: TdMediaService,
| | private $L: LocaleService,
| | private router: Router,
| | private location: Location,
| | private route: ActivatedRoute,
| | private dialog: MdDialog,
| | private licenseForm: LicenseFormComponent,
| | private licenses: LicensesService,
| | private packs: PacksService) {
| | }
| |
| | ngOnInit(): void {
| | this.route.params.subscribe(params => {
| | var packId = +params['id']; // (+) converts string 'id' to a number
| | this.licenses.getByPack(packId).subscribe(
| | list => {
| | this.data = list;
| | this.filter();
| | },
| | err => console.error(err)
| | );
| | this.packs.get(packId).subscribe(
| | packData => {
| | this.pack = packData;
| | },
| | err => console.error(err)
| | );
| | });
| | }
| |
| | goBack() : void {
| | this.location.back();
| | }
| |
| | isLicenseExpired(lic: any): boolean {
| | return lic.expiration_date < (new Date().getTime());
| | }
| |
| | createLicense() : void {
| | let ref = this.dialog.open(LicenseFormComponent, DIALOG_OPTIONS);
| |
| | ref.componentInstance.isNew = true;
| | ref.componentInstance.data = {};
| | ref.afterClosed().subscribe(result => {
| | this.filter();
| | });
| |
| | }
| |
| | editLicense(lic: any) : void {
| | let ref = this.dialog.open(LicenseFormComponent, DIALOG_OPTIONS);
| | ref.componentInstance.isNew = false;
| | ref.componentInstance.data = lic;
| | ref.afterClosed().subscribe(result => {
| | this.filter();
| | });
| | }
| |
| |
| | sort(sortEvent: ITdDataTableSortChangeEvent): void {
| | this.sortBy = sortEvent.name;
| | this.sortOrder = sortEvent.order;
| | this.filter();
| | }
| |
| | search(searchTerm: string): void {
| | this.searchTerm = searchTerm;
| | this.filter();
| | }
| |
| | page(pagingEvent: IPageChangeEvent): void {
| | this.fromRow = pagingEvent.fromRow;
| | this.currentPage = pagingEvent.page;
| | this.pageSize = pagingEvent.pageSize;
| | this.filter();
| | }
| |
| | loadData() {
| |
| | }
| |
| | filter(): void {
| | let newData: any[] = this.data;
| | newData = this._dataTableService.filterData(newData, this.searchTerm, true);
| | this.filteredTotal = newData.length;
| | this.filteredItems = newData.length;
| | newData = this._dataTableService.sortData(newData, this.sortBy, this.sortOrder);
| | newData = this._dataTableService.pageData(newData, this.fromRow, this.currentPage * this.pageSize);
| | this.filteredData = newData;
| | }
| |
| | ngAfterViewInit(): void {
| | this.media.broadcast();
| |
| | }
| | }
|
|