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
| | import { Router } from '@angular/router';
| | import { MdDialog } from '@angular/material';
| | import { TdDataTableService, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core';
| | import { IPageChangeEvent } from '@covalent/core';
| | import { Component, AfterViewInit } from '@angular/core';
| | import { TdMediaService } from '@covalent/core';
| | import { LicensesService } from './resources/licenses';
| | 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' }
| |
| | @Component({
| | selector: 'license-list',
| | templateUrl: 'src/app/license.list.component.html'
| | })
| | export class LicenseListComponent implements AfterViewInit {
| | data: any[] = [];
| | columns: ITdDataTableColumn[] = [
| | { name: 'code', label: 'Code', tooltip: 'License pack code' },
| | { name: 'application_name', label: 'App name' },
| | { name: 'licensetype_code', label: 'License type' },
| | { name: 'organization_name', label: 'Organization' },
| | { name: 'used_licenses', label: 'Lics', tooltip: 'Initial/Available pack licenses' },
| | { 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 = 'application_name';
| | 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 router: Router,
| | private dialog: MdDialog,
| | private licenseForm: LicenseFormComponent,
| | private licenses: LicensesService) {
| | this.licenses.get().subscribe(
| | list => {
| | this.data = list;
| | this.filter();
| | },
| | err => console.error(err)
| | );
| | }
| |
| | ngOnInit(): void {
| | this.filter();
| | }
| |
| | createPack() : void {
| | var ref = this.dialog.open(LicenseFormComponent, {
| | height: '50%', // can be px or %
| | width: '40%', // can be px or %
| | });
| | ref.componentInstance.isNew = true;
| | ref.afterClosed().subscribe(result => {
| | console.log(result);
| | this.filter();
| | });
| | }
| |
| | editLicense(lic: any) : void {
| | var ref = this.dialog.open(LicenseFormComponent, {
| | height: '50%', // can be px or %
| | width: '40%', // can be px or %
| | });
| | ref.componentInstance.isNew = false;
| | ref.componentInstance.data = lic;
| | ref.afterClosed().subscribe(result => {
| | console.log(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();
| |
| | }
| | }
|
|