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
| | 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 { Location } from '@angular/common';
| | import { ToastsManager } from 'ng2-toastr/ng2-toastr';
| |
| | import { LocaleService } from '../common/i18n';
| | import { LicensesService, LICENSE_ACTIONS } from '../resources/licenses';
| | import { PacksService } from '../resources/packs';
| | import { LicenseFormComponent } from '../forms/license.form.component';
| | import { ListingBase } from './base';
| |
| | 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/listing/license.list.component.html'
| | })
| | export class LicenseListComponent extends ListingBase implements AfterViewInit {
| | 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: '' }
| | ];
| |
| | license_menu_options = LICENSE_ACTIONS;
| |
| | licenseAction(action: string, license: any) {
| | return this.licenses[action](license.id).subscribe(
| | (actionResponse : any) => {
| | this.toaster.success(this.$L.get('Action "{}" executed successfully', action));
| | this.reload(this.pack.id);
| | },
| | (err : any) => this.toaster.error(this.$L.get('Action "{}" failed', action))
| | );
| | }
| |
| | reload(packId: number) : void {
| | this.licenses.getByPack(packId).subscribe(
| | list => {
| | this.data = list;
| | this.refresh();
| | },
| | err => console.error(err)
| | );
| | }
| |
| | isActionAvailable(action: string, license : any) : boolean {
| | return this.licenses.isActionAvailable(action, license);
| | }
| |
| | constructor( _dataTableService: TdDataTableService,
| | private media: TdMediaService,
| | private $L: LocaleService,
| | private router: Router,
| | private location: Location,
| | private toaster: ToastsManager,
| | private route: ActivatedRoute,
| | private dialog: MdDialog,
| | private licenseForm: LicenseFormComponent,
| | private licenses: LicensesService,
| | private packs: PacksService) {
| | super(_dataTableService);
| | }
| |
| | ngOnInit(): void {
| | }
| |
| | goBack() : void {
| | this.router.navigate([`packs`]);
| | }
| |
| | isLicenseExpired(lic: any): boolean {
| | return lic.expiration_date < (new Date().getTime());
| | }
| |
| | create() : void {
| | this.router.navigate([`packs/${this.pack.id}/licenses/create`]);
| | }
| |
| | edit(licId: number | string) : void {
| | this.router.navigate([`packs/${this.pack.id}/licenses/edit/${licId}`]);
| | }
| |
| | ngAfterViewInit(): void {
| | this.media.broadcast();
| | this.route.params.subscribe(params => {
| | var packId = +params['packId']; // (+) converts string 'id' to a number
| | this.reload(packId);
| | this.packs.get(packId).subscribe(
| | packData => {
| | this.pack = packData;
| | },
| | err => console.error(err)
| | );
| | });
| | }
| | }
|
|