rsanchez
2017-03-15 a6b5178c7295be4525ee0f607e42f72a12a2e3d6
securis/src/main/webapp/src/app/resources/licenses.ts
....@@ -1,3 +1,4 @@
1
+import { LocaleService } from '../common/i18n';
12 import { Observable } from 'rxjs/Rx';
23 import { Injectable } from '@angular/core';
34 import { Http, RequestOptions } from '@angular/http';
....@@ -21,14 +22,6 @@
2122 status: 'AC'
2223 }
2324
24
-export const PACK_STATUS = {
25
- CREATED: 'CR',
26
- ACTIVE: 'AC',
27
- ONHOLD: 'OH',
28
- EXPIRED: 'EX',
29
- CANCELLED: 'CA'
30
-}
31
-
3225 export const LIC_STATUS = {
3326 CREATED: 'CR',
3427 ACTIVE: 'AC',
....@@ -38,6 +31,15 @@
3831 BLOCKED: 'BL',
3932 CANCELLED: 'CA'
4033 }
34
+
35
+export const COLORS_BY_STATUS = {
36
+ 'CR': '#808080',
37
+ 'AC': '#329e5a',
38
+ 'RE': '#2981d4',
39
+ 'EX': '#ea7824',
40
+ 'BL': '#ff0000',
41
+ 'CA': '#a21717'
42
+};
4143
4244 /**
4345 * These transitions could be get from server, class License.Status, but
....@@ -55,11 +57,10 @@
5557 'delete': [LIC_STATUS.CREATED, LIC_STATUS.CANCELLED, LIC_STATUS.BLOCKED]
5658 }
5759
58
-
59
-
6060 @Injectable()
6161 export class LicensesService extends SeCurisResourceServices {
62
- constructor(http: Http) {
62
+ constructor(http: Http,
63
+ private $L: LocaleService) {
6364 super(http, 'license');
6465 }
6566
....@@ -84,5 +85,14 @@
8485 var validStatuses = LIC_ACTIONS_BY_STATUS[action];
8586 return lic && validStatuses && validStatuses.indexOf(lic.status) !== -1;
8687 }
88
+
89
+
90
+ getStatusName(statusCode: string): string {
91
+ return this.$L.get(`pack.status.${statusCode}`, this.$L.get('Unknown'));
92
+ }
93
+
94
+ getStatusColor(statusCode: string): string {
95
+ return COLORS_BY_STATUS[statusCode] || '#cccccc';
96
+ }
8797 }
8898