From 85e2a65874fcd41771b30ebfff93f86edd4f32b3 Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Mon, 01 Dec 2014 14:59:34 +0000
Subject: [PATCH] #396 fix - Added automated license code generation and other minor fixes
---
securis/src/main/webapp/js/licenses.js | 37 +++++++++++++++++++++++++------------
1 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/securis/src/main/webapp/js/licenses.js b/securis/src/main/webapp/js/licenses.js
index 5df0f34..5e24c67 100644
--- a/securis/src/main/webapp/js/licenses.js
+++ b/securis/src/main/webapp/js/licenses.js
@@ -12,7 +12,7 @@
}
var app = angular.module('securis');
- app.service('Packs', ['$L','$resource', 'toaster', function($L, $resource, toaster) {
+ app.service('Packs', ['$L','$resource', '$http', 'toaster', function($L, $resource, $http, toaster) {
var PACK_STATUS = {
CREATED: 'CR',
ACTIVE: 'AC',
@@ -117,6 +117,14 @@
var _error = _createErrorCallback(pack, $L.get('Put on hold'), _onerror);
packResource.putonhold({id: pack.id}, _success, _error);
}
+ this.nextliccode = function(packId, _onsuccess, _onerror) {
+ console.log('Get next code: ' + packId);
+ var _error = function(data, status, headers, config) {
+ console.log(headers);
+ toaster.pop('error', $L.get('Getting next code suffix'), $L.get("Error getting license code, pack ID: '{0}'. Reason: {1}", packId, $L.get(headers('X-SECURIS-ERROR-MSG'))));
+ }
+ $http.get("/securis/pack/"+packId+"/next_license_code").success(_onsuccess).error(_error);
+ }
this.cancel = function(pack, extra_data, _onsuccess, _onerror) {
console.log('Cancellation on pack: ' + pack.id);
var _success = _createSuccessCallback($L.get('Cancellation'), $L.get("Pack '{0}' {1} successfully", pack.code, $L.get("cancelled")), _onsuccess);
@@ -133,7 +141,7 @@
}]);
- app.service('Licenses', ['$L', '$resource', 'toaster', function($L, $resource, toaster) {
+ app.service('Licenses', ['$L', '$resource', 'toaster', 'Packs', function($L, $resource, toaster, Packs) {
var LIC_STATUS = {
CREATED: 'CR',
ACTIVE: 'AC',
@@ -225,7 +233,14 @@
}
var _error = function(error) {
console.log(error);
- toaster.pop('error', 'Licenses', $L.get("Error {0} license '{1}'. Reason: {2}", isNew ? $L.get("creating") : $L.get("updating"), license.code, $L.get(error.headers('X-SECURIS-ERROR-MSG'))));
+ toaster.pop('error', 'Licenses', $L.get("Error {0} license '{1}'. Reason: {2}", isNew ? $L.get("creating") : $L.get("updating"), license.code, $L.get(error.headers('X-SECURIS-ERROR-MSG'))), 5000);
+ if (error.headers('X-SECURIS-ERROR-CODE') === '1301') {
+ Packs.nextliccode(license.pack_id, function(data) {
+ console.log('New code: ' + data);
+ license.code = data;
+ toaster.pop('info', 'Licenses', $L.get("New license code, {0}, has been generated, please try again", license.code), 5000);
+ });
+ }
}
licenseResource.save(license, _success, _error);
}
@@ -622,9 +637,10 @@
'$resource',
'toaster',
'Licenses',
+ 'Packs',
'$store',
'$L',
- function($scope, $http, $resource, toaster, Licenses, $store, $L) {
+ function($scope, $http, $resource, toaster, Licenses, Packs, $store, $L) {
$scope.Licenses = Licenses;
$scope.$on('pack_changed', function(evt, message) {
$scope.licenses = Licenses.getLicensesList($scope.currentPack);
@@ -708,8 +724,12 @@
$scope.license = {
pack_id: $scope.currentPack.id
}
+ Packs.nextliccode($scope.currentPack.id, function(data) {
+ console.log('New code: ' + data);
+ $scope.license.code = data;
+ });
setTimeout(function() {
- $('#licenseForm * #code').focus();
+ $('#licenseForm * #email').focus();
}, 0);
}
@@ -816,13 +836,6 @@
$scope.cancel = function() {
$scope.showForm = false;
- }
-
- $scope.showStatus = function(lic) {
-
- }
- $scope.showStatusLong = function(license) {
-
}
} ]);
--
Gitblit v1.3.2