From 60c65f2110f65221bc3a71b2887667e78c53c53e Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Wed, 22 Mar 2017 17:44:16 +0000
Subject: [PATCH] #3527 fix - Added pack/license actions and a lot of bugfixing
---
securis/src/main/webapp/src/app/resources/licenses.ts | 76 +++++++++++++++++++++++++++-----------
1 files changed, 54 insertions(+), 22 deletions(-)
diff --git a/securis/src/main/webapp/src/app/resources/licenses.ts b/securis/src/main/webapp/src/app/resources/licenses.ts
index a82d910..87de7bd 100644
--- a/securis/src/main/webapp/src/app/resources/licenses.ts
+++ b/securis/src/main/webapp/src/app/resources/licenses.ts
@@ -1,26 +1,9 @@
import { LocaleService } from '../common/i18n';
import { Observable } from 'rxjs/Rx';
import { Injectable } from '@angular/core';
-import { Http, RequestOptions } from '@angular/http';
+import { Http, RequestOptions, ResponseContentType, Response } from '@angular/http';
import { SeCurisResourceServices } from './base';
-
-var lic_example = {
- id: 101,
- activation_code: 'f3e2d27e-7f81-4ac7-87ba-b9e38b4fdbb8',
- code: 'CITR01-436-1',
- code_suffix: 1,
- created_by_id: '_client',
- creation_timestamp: 1445898088000,
- email: 'GQuercia@trican.ca',
- expiration_date: 1487523828000,
- full_name: 'George Quercia',
- licenseData: '{"appCode":"CICS","appName":"CurisIntegrity","licenseCode":"CITR01-436-1","activationCode":"f3e2d27e-7f81-4ac7-87ba-b9e38b4fdbb8","expirationDate":1487523828416,"arch":"amd64","osName":"Windows 7","macAddresses":["C4-D9-87-5D-53-72","C4-D9-87-5D-53-76","FC-15-B4-EB-70-F9"],"crcLogo":"10f6379e0e1c00ebc403160307e3c5d0aba0727c9cae0bf1ac7cd19d84fdc80f","metadata":{"a2Mode":"false","datasetPrefix":"TR","extendedMode":"false","maxConcurrentInstances":"-1","maxInstances":"3","maxUsers":"0","maxWellLifeLines":"50","timeThreshold":"0"},"signature":"cjyLYFyhXpWWsMNnG6ER9mtCREgw02aQDnXPSQQWZtiLWbu/GyHZzK+1msLhwuKMGYG6I90s5wp82HVIqhIheHOsov3JfnHgNtYzf3BdkqUinwPFuDqPqkXz5Sjb6bouWkmvTI1TN/s4U2DJOXVnYN4FnYl0/dBTcU9RP4NZlQxMu6oFuRrZSMfdMCxEJYZAU62SWgTSurkdmHhFgwRjIwsOXRWHYsr6vGT//yILI7UvMGbMc6dRCGwyJLPNi4nXwF9PRMLinB7fYK8HxKylTJx2O7bvWCZd6EOdwi6gRI/0HhOqZ7E4DzBDrqEnsHeuH4L47DfRdIMGDnA492F+mg=="}',
- modification_timestamp: 1484931828000,
- pack_code: 'CITR01',
- pack_id: 12,
- request_data: '{"appCode":"CICS","activationCode":"f3e2d27e-7f81-4ac7-87ba-b9e38b4fdbb8","arch":"amd64","osName":"Windows 7","macAddresses":["C4-D9-87-5D-53-72","C4-D9-87-5D-53-76","FC-15-B4-EB-70-F9"],"crcLogo":"10f6379e0e1c00ebc403160307e3c5d0aba0727c9cae0bf1ac7cd19d84fdc80f"}',
- status: 'AC'
-}
+import * as saveAsFile from "file-saver";
export const LIC_STATUS = {
CREATED: 'CR',
@@ -41,6 +24,7 @@
'CA': '#a21717'
};
+
/**
* These transitions could be get from server, class License.Status, but
* we copy them for simplicity, this info won't change easily
@@ -56,6 +40,37 @@
cancel: [LIC_STATUS.REQUESTED, LIC_STATUS.EXPIRED, LIC_STATUS.PREACTIVE, LIC_STATUS.ACTIVE],
'delete': [LIC_STATUS.CREATED, LIC_STATUS.CANCELLED, LIC_STATUS.BLOCKED]
}
+
+export const LICENSE_ACTIONS : any[] = [{
+/* command: 'add_request',
+ icon: 'add_to_photos',
+ name: 'Add request'
+ },{ */
+ command: 'activate',
+ icon: 'play_circle_outline',
+ name: 'Activate'
+ },{
+ command: 'send',
+ icon: 'send',
+ name: 'Send'
+ },{
+ command: 'download',
+ icon: 'file_download',
+ name: 'Download'
+ },{
+ command: 'block',
+ icon: 'do_not_disturb_on',
+ name: 'Block'
+ },{
+ command: 'unblock',
+ icon: 'do_not_disturb_off',
+ name: 'Unblock'
+ },{
+ command: 'cancel',
+ icon: 'cancel',
+ name: 'Cancel'
+ }]
+
@Injectable()
export class LicensesService extends SeCurisResourceServices {
@@ -73,19 +88,36 @@
return super.action(id, "activate");
}
+ public block(id: number) {
+ return super.action(id, "block");
+ }
+
+ public unblock(id: number) {
+ return super.action(id, "unblock");
+ }
+
+ public send(id: number) {
+ return super.action(id, "send");
+ }
+
public cancel(id: number) {
return super.action(id, "cancel");
}
- public putonhold(id: number) {
- return super.action(id, "putonhold");
+ public download(id: number) {
+ let url = `${this.resource}/${id}/download`;
+ return this.http.get(url).map((response : Response) => {
+ let filename = JSON.parse(response.headers.get('Content-Disposition').match(/".*"$/g)[0]);
+ let content = JSON.stringify(response.json(), null, 2);
+ saveAsFile( new Blob([ content ], { type : 'application/octet-stream' }), filename);
+ return Observable.of(true);
+ }).catch(err => super.processErrorResponse(err));
}
public isActionAvailable(action:string, lic:any) {
var validStatuses = LIC_ACTIONS_BY_STATUS[action];
return lic && validStatuses && validStatuses.indexOf(lic.status) !== -1;
}
-
getStatusName(statusCode: string): string {
return this.$L.get(`pack.status.${statusCode}`, this.$L.get('Unknown'));
--
Gitblit v1.3.2