From 94c288b4f8d353c44b64e40c0863c7fce6782293 Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Thu, 24 Sep 2015 17:26:14 +0000
Subject: [PATCH] #2756 fix - chnaged API to allow activation by code and other UI changes

---
 securis/src/main/webapp/js/licenses.js |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/securis/src/main/webapp/js/licenses.js b/securis/src/main/webapp/js/licenses.js
index 712f7e8..fc4faed 100644
--- a/securis/src/main/webapp/js/licenses.js
+++ b/securis/src/main/webapp/js/licenses.js
@@ -724,7 +724,10 @@
 	                                		email: true
 	                                	}
 	                                	$scope.maxlength = {
+	                                		activation_code: 36,
 	                                		code: 50,
+	                                		full_name: 100,
+	                                		email: 100,
 	                                		request_data: 500,
 	                                		comments: 1024
 	                                	}
@@ -787,7 +790,8 @@
 	                                		$scope.isNew = true;
 	                                		$scope.showForm = true;
 	                                		$scope.license = {
-	                                				pack_id: $scope.currentPack.id
+	                                				pack_id: $scope.currentPack.id,
+	                                				activation_code: $scope.createUUID()
 	                                		}
 	                                		Packs.nextliccode($scope.currentPack.id, function(data) {
 	                    						console.log('New code: ' + data);
@@ -797,12 +801,26 @@
 	                                			$('#licenseForm * #email').focus();
 	                                		}, 0);
 	                                	}
+	                                	$scope.createUUID = function () {
+	                                	    // http://www.ietf.org/rfc/rfc4122.txt
+	                                	    var s = new Array(36);
+	                                	    var hexDigits = "0123456789abcdef";
+	                                	    for (var i = 0; i < 36; i++) {
+	                                	        s[i] = hexDigits.substr(Math.random() * 0x10 | 0, 1);
+	                                	    }
+	                                	    s[14] = "4";  // bits 12-15 of the time_hi_and_version field to 0010
+	                                	    s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);  // bits 6-7 of the clock_seq_hi_and_reserved to 01
+	                                	    s[8] = s[13] = s[18] = s[23] = "-";
 
+	                                	    var uuid = s.join("");
+	                                	    return uuid;
+	                                	}
 	                                	$scope.editLicense = function(selectedlicense) {
 	                                		$scope.isNew = false;
 	                                		$scope.showForm = true;
 	                                		$scope.license = selectedlicense;
 	                                		$scope.license.status_name = Licenses.getStatusName($scope.license.status); 
+	                                		$scope.license.activation_code = $scope.license.activation_code || $scope.createUUID();
 
 	                                		setTimeout(function() {
 	                                			$('#licenseForm * #code').focus();

--
Gitblit v1.3.2