| .. | .. |
|---|
| 12 | 12 | } |
|---|
| 13 | 13 | |
|---|
| 14 | 14 | var app = angular.module('securis'); |
|---|
| 15 | | - app.service('Packs', ['$L','$resource', 'toaster', function($L, $resource, toaster) { |
|---|
| 15 | + app.service('Packs', ['$L','$resource', '$http', 'toaster', function($L, $resource, $http, toaster) { |
|---|
| 16 | 16 | var PACK_STATUS = { |
|---|
| 17 | 17 | CREATED: 'CR', |
|---|
| 18 | 18 | ACTIVE: 'AC', |
|---|
| .. | .. |
|---|
| 117 | 117 | var _error = _createErrorCallback(pack, $L.get('Put on hold'), _onerror); |
|---|
| 118 | 118 | packResource.putonhold({id: pack.id}, _success, _error); |
|---|
| 119 | 119 | } |
|---|
| 120 | + this.nextliccode = function(packId, _onsuccess, _onerror) { |
|---|
| 121 | + console.log('Get next code: ' + packId); |
|---|
| 122 | + var _error = function(data, status, headers, config) { |
|---|
| 123 | + console.log(headers); |
|---|
| 124 | + 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')))); |
|---|
| 125 | + } |
|---|
| 126 | + $http.get("/securis/pack/"+packId+"/next_license_code").success(_onsuccess).error(_error); |
|---|
| 127 | + } |
|---|
| 120 | 128 | this.cancel = function(pack, extra_data, _onsuccess, _onerror) { |
|---|
| 121 | 129 | console.log('Cancellation on pack: ' + pack.id); |
|---|
| 122 | 130 | var _success = _createSuccessCallback($L.get('Cancellation'), $L.get("Pack '{0}' {1} successfully", pack.code, $L.get("cancelled")), _onsuccess); |
|---|
| .. | .. |
|---|
| 133 | 141 | |
|---|
| 134 | 142 | }]); |
|---|
| 135 | 143 | |
|---|
| 136 | | - app.service('Licenses', ['$L', '$resource', 'toaster', function($L, $resource, toaster) { |
|---|
| 144 | + app.service('Licenses', ['$L', '$resource', 'toaster', 'Packs', function($L, $resource, toaster, Packs) { |
|---|
| 137 | 145 | var LIC_STATUS = { |
|---|
| 138 | 146 | CREATED: 'CR', |
|---|
| 139 | 147 | ACTIVE: 'AC', |
|---|
| .. | .. |
|---|
| 225 | 233 | } |
|---|
| 226 | 234 | var _error = function(error) { |
|---|
| 227 | 235 | console.log(error); |
|---|
| 228 | | - 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')))); |
|---|
| 236 | + 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); |
|---|
| 237 | + if (error.headers('X-SECURIS-ERROR-CODE') === '1301') { |
|---|
| 238 | + Packs.nextliccode(license.pack_id, function(data) { |
|---|
| 239 | + console.log('New code: ' + data); |
|---|
| 240 | + license.code = data; |
|---|
| 241 | + toaster.pop('info', 'Licenses', $L.get("New license code, {0}, has been generated, please try again", license.code), 5000); |
|---|
| 242 | + }); |
|---|
| 243 | + } |
|---|
| 229 | 244 | } |
|---|
| 230 | 245 | licenseResource.save(license, _success, _error); |
|---|
| 231 | 246 | } |
|---|
| .. | .. |
|---|
| 622 | 637 | '$resource', |
|---|
| 623 | 638 | 'toaster', |
|---|
| 624 | 639 | 'Licenses', |
|---|
| 640 | + 'Packs', |
|---|
| 625 | 641 | '$store', |
|---|
| 626 | 642 | '$L', |
|---|
| 627 | | - function($scope, $http, $resource, toaster, Licenses, $store, $L) { |
|---|
| 643 | + function($scope, $http, $resource, toaster, Licenses, Packs, $store, $L) { |
|---|
| 628 | 644 | $scope.Licenses = Licenses; |
|---|
| 629 | 645 | $scope.$on('pack_changed', function(evt, message) { |
|---|
| 630 | 646 | $scope.licenses = Licenses.getLicensesList($scope.currentPack); |
|---|
| .. | .. |
|---|
| 708 | 724 | $scope.license = { |
|---|
| 709 | 725 | pack_id: $scope.currentPack.id |
|---|
| 710 | 726 | } |
|---|
| 727 | + Packs.nextliccode($scope.currentPack.id, function(data) { |
|---|
| 728 | + console.log('New code: ' + data); |
|---|
| 729 | + $scope.license.code = data; |
|---|
| 730 | + }); |
|---|
| 711 | 731 | setTimeout(function() { |
|---|
| 712 | | - $('#licenseForm * #code').focus(); |
|---|
| 732 | + $('#licenseForm * #email').focus(); |
|---|
| 713 | 733 | }, 0); |
|---|
| 714 | 734 | } |
|---|
| 715 | 735 | |
|---|
| .. | .. |
|---|
| 816 | 836 | |
|---|
| 817 | 837 | $scope.cancel = function() { |
|---|
| 818 | 838 | $scope.showForm = false; |
|---|
| 819 | | - } |
|---|
| 820 | | - |
|---|
| 821 | | - $scope.showStatus = function(lic) { |
|---|
| 822 | | - |
|---|
| 823 | | - } |
|---|
| 824 | | - $scope.showStatusLong = function(license) { |
|---|
| 825 | | - |
|---|
| 826 | 839 | } |
|---|
| 827 | 840 | |
|---|
| 828 | 841 | } ]); |
|---|