rsanchez
2014-11-18 fdbc8ca146b8e3aff0425e2faf94c0b4a6e3dd28
securis/src/main/webapp/js/licenses.js
....@@ -1,72 +1,72 @@
11 (function() {
22 'use strict';
3
-
43
54
6
- var HTTP_ERRORS = {
7
- 401: "Unathorized action",
8
- 418: "Application error",
9
- 403: "Forbidden action",
10
- 500: "Server error",
11
- 404: "Element not found"
12
- }
5
+
6
+ var HTTP_ERRORS = {
7
+ 401: "Unathorized action",
8
+ 418: "Application error",
9
+ 403: "Forbidden action",
10
+ 500: "Server error",
11
+ 404: "Element not found"
12
+ }
1313
1414 var app = angular.module('securis');
1515 app.service('Packs', ['$L','$resource', 'toaster', function($L, $resource, toaster) {
1616 var PACK_STATUS = {
17
- CREATED: 'CR',
18
- ACTIVE: 'AC',
19
- ONHOLD: 'OH',
20
- EXPIRED: 'EX',
21
- CANCELLED: 'CA'
17
+ CREATED: 'CR',
18
+ ACTIVE: 'AC',
19
+ ONHOLD: 'OH',
20
+ EXPIRED: 'EX',
21
+ CANCELLED: 'CA'
2222 }
2323 var PACK_STATUSES = {
2424 'CR': $L.get('Created'),
25
- 'AC': $L.get('Active'),
26
- 'OH': $L.get('On Hold'),
27
- 'EX': $L.get('Expired'),
28
- 'CA': $L.get('Cancelled')
29
- };
25
+ 'AC': $L.get('Active'),
26
+ 'OH': $L.get('On Hold'),
27
+ 'EX': $L.get('Expired'),
28
+ 'CA': $L.get('Cancelled')
29
+ };
3030 /**
3131 * These transitions could be get from server, class Pack.Status, but we
3232 * copy them for simplicity, this info won't change easily
3333 */
3434 var PACK_ACTIONS_BY_STATUS = {
35
- activate: [PACK_STATUS.CREATED, PACK_STATUS.EXPIRED, PACK_STATUS.ONHOLD],
36
- putonhold: [PACK_STATUS.ACTIVE],
37
- cancel: [PACK_STATUS.EXPIRED, PACK_STATUS.ONHOLD, PACK_STATUS.ACTIVE],
38
- 'delete': [PACK_STATUS.CREATED, PACK_STATUS.CANCELLED]
39
- }
40
-
35
+ activate: [PACK_STATUS.CREATED, PACK_STATUS.EXPIRED, PACK_STATUS.ONHOLD],
36
+ putonhold: [PACK_STATUS.ACTIVE],
37
+ cancel: [PACK_STATUS.EXPIRED, PACK_STATUS.ONHOLD, PACK_STATUS.ACTIVE],
38
+ 'delete': [PACK_STATUS.CREATED, PACK_STATUS.CANCELLED]
39
+ }
40
+
4141 var packResource = $resource('pack/:packId/:action',
4242 {
43
- packId : '@id',
44
- action : '@action'
43
+ packId : '@id',
44
+ action : '@action'
4545 },
4646 {
47
- activate: {
48
- method: "POST",
49
- params: {action: "activate"}
50
- },
51
- putonhold: {
52
- method: "POST",
53
- params: {action: "putonhold"}
54
- },
55
- cancel: {
56
- method: "POST",
57
- params: {action: "cancel"}
58
- }
59
- }
60
- );
47
+ activate: {
48
+ method: "POST",
49
+ params: {action: "activate"}
50
+ },
51
+ putonhold: {
52
+ method: "POST",
53
+ params: {action: "putonhold"}
54
+ },
55
+ cancel: {
56
+ method: "POST",
57
+ params: {action: "cancel"}
58
+ }
59
+ }
60
+ );
6161 this.getStatusColor = function(status) {
6262 var COLORS_BY_STATUS = {
6363 'CR': '#808080',
64
- 'AC': '#329e5a',
65
- 'OH': '#9047c7',
66
- 'EX': '#ea7824',
67
- 'CA': '#a21717'
68
- };
69
-
64
+ 'AC': '#329e5a',
65
+ 'OH': '#9047c7',
66
+ 'EX': '#ea7824',
67
+ 'CA': '#a21717'
68
+ };
69
+
7070 return COLORS_BY_STATUS[status];
7171 },
7272 this.getStatusName = function(status) {
....@@ -79,15 +79,15 @@
7979 toaster.pop('success', 'Packs', $L.get("Pack '{0}' {1} successfully", pack.code, isNew ? $L.get("created") : $L.get("updated")));
8080 }
8181 var _error = function(error) {
82
- console.log(error);
82
+ console.log(error);
8383 toaster.pop('error', 'Packs', $L.get("Error {0} pack '{1}'. Reason: {2}", isNew ? $L.get("creating") : $L.get("updating"), pack.code, $L.get(error.headers('X-SECURIS-ERROR-MSG'))));
8484 }
8585 packResource.save(pack, _success, _error);
8686 }
8787
8888 this.isActionAvailable = function(action, pack) {
89
- var validStatuses = PACK_ACTIONS_BY_STATUS[action];
90
- return pack && validStatuses && validStatuses.indexOf(pack.status) !== -1;
89
+ var validStatuses = PACK_ACTIONS_BY_STATUS[action];
90
+ return pack && validStatuses && validStatuses.indexOf(pack.status) !== -1;
9191 }
9292 var _createSuccessCallback = function(actionName, message, _innerCallback) {
9393 return function() {
....@@ -97,8 +97,8 @@
9797 }
9898 var _createErrorCallback = function(pack, actionName, _innerCallback) {
9999 return function(error) {
100
- console.log(error);
101
- _innerCallback && _innerCallback();
100
+ console.log(error);
101
+ _innerCallback && _innerCallback();
102102 toaster.pop('error', actionName, $L.get("Error on action '{0}', pack '{1}'. Reason: {2}", actionName, pack.code, $L.get(error.headers('X-SECURIS-ERROR-MSG'))));
103103 }
104104 }
....@@ -132,85 +132,86 @@
132132 }
133133
134134 }]);
135
-
135
+
136136 app.service('Licenses', ['$L', '$resource', 'toaster', function($L, $resource, toaster) {
137137 var LIC_STATUS = {
138
- CREATED: 'CR',
139
- ACTIVE: 'AC',
140
- REQUESTED: 'RE',
141
- PREACTIVE: 'PA',
142
- EXPIRED: 'EX',
143
- CANCELLED: 'CA'
138
+ CREATED: 'CR',
139
+ ACTIVE: 'AC',
140
+ REQUESTED: 'RE',
141
+ PREACTIVE: 'PA',
142
+ EXPIRED: 'EX',
143
+ CANCELLED: 'CA'
144144 }
145
-
145
+
146146 var LIC_STATUSES = {
147147 'CR': $L.get('Created'),
148
- 'AC': $L.get('Active'),
149
- 'PA': $L.get('Pre-active'),
150
- 'RE': $L.get('Requested'),
151
- 'EX': $L.get('Expired'),
152
- 'CA': $L.get('Cancelled')
153
- };
148
+ 'AC': $L.get('Active'),
149
+ 'PA': $L.get('Pre-active'),
150
+ 'RE': $L.get('Requested'),
151
+ 'EX': $L.get('Expired'),
152
+ 'CA': $L.get('Cancelled')
153
+ };
154154
155155 /**
156156 * These transitions could be get from server, class License.Status, but
157157 * we copy them for simplicity, this info won't change easily
158158 */
159159 var LIC_ACTIONS_BY_STATUS = {
160
- activate: [LIC_STATUS.CREATED, LIC_STATUS.REQUESTED, LIC_STATUS.PREACTIVE],
161
- send: [LIC_STATUS.ACTIVE, LIC_STATUS.PREACTIVE],
162
- download: [LIC_STATUS.ACTIVE, LIC_STATUS.PREACTIVE],
163
- block: [LIC_STATUS.CANCELLED],
164
- unblock: [LIC_STATUS.CANCELLED],
165
- cancel: [LIC_STATUS.REQUESTED, LIC_STATUS.EXPIRED, LIC_STATUS.PREACTIVE, LIC_STATUS.ACTIVE],
166
- 'delete': [LIC_STATUS.CREATED, LIC_STATUS.CANCELLED]
167
- }
168
-
169
- var licenseResource = $resource('license/:licenseId/:action', {
170
- licenseId : '@id',
160
+ activate: [LIC_STATUS.CREATED, LIC_STATUS.REQUESTED, LIC_STATUS.PREACTIVE],
161
+ send: [LIC_STATUS.ACTIVE, LIC_STATUS.PREACTIVE],
162
+ download: [LIC_STATUS.ACTIVE, LIC_STATUS.PREACTIVE],
163
+ block: [LIC_STATUS.CANCELLED],
164
+ unblock: [LIC_STATUS.CANCELLED],
165
+ cancel: [LIC_STATUS.REQUESTED, LIC_STATUS.EXPIRED, LIC_STATUS.PREACTIVE, LIC_STATUS.ACTIVE],
166
+ 'delete': [LIC_STATUS.CREATED, LIC_STATUS.CANCELLED]
167
+ }
168
+
169
+ var licenseResource = $resource('license/:licenseId/:action', {
170
+ licenseId : '@id',
171171 action : '@action'
172172 },
173173 {
174
- activate: {
175
- method: "POST",
176
- params: {action: "activate"}
177
- },
178
- cancel: {
179
- method: "POST",
180
- params: {action: "cancel"}
181
- }, // Download a file cannot be done form AJAX, We should do it manually, using $http
182
- download: {
183
- method: "GET",
184
- params: {action: "download"}
185
- },
186
- block: {
187
- method: "POST",
188
- params: {action: "block"}
189
- },
190
- sendEmail: {
191
- method: "POST",
192
- params: {action: "send"}
193
- },
194
- unblock: {
195
- method: "POST",
196
- params: {action: "unblock"}
197
- }
198
- });
174
+ activate: {
175
+ method: "POST",
176
+ params: {action: "activate"}
177
+ },
178
+ cancel: {
179
+ method: "POST",
180
+ params: {action: "cancel"}
181
+ }, // Download a file cannot be done form AJAX, We should do it
182
+ // manually, using $http
183
+ download: {
184
+ method: "GET",
185
+ params: {action: "download"}
186
+ },
187
+ block: {
188
+ method: "POST",
189
+ params: {action: "block"}
190
+ },
191
+ sendEmail: {
192
+ method: "POST",
193
+ params: {action: "send"}
194
+ },
195
+ unblock: {
196
+ method: "POST",
197
+ params: {action: "unblock"}
198
+ }
199
+ });
199200
200201
201
- this.isActionAvailable = function(action, lic) {
202
- var validStatuses = LIC_ACTIONS_BY_STATUS[action];
203
- return lic && validStatuses && validStatuses.indexOf(lic.status) !== -1;
204
- }
205
- this.getStatusColor = function(status) {
202
+ this.isActionAvailable = function(action, lic) {
203
+ var validStatuses = LIC_ACTIONS_BY_STATUS[action];
204
+ return lic && validStatuses && validStatuses.indexOf(lic.status) !== -1;
205
+ }
206
+ this.getStatusColor = function(status) {
206207 var COLORS_BY_STATUS = {
207208 'CR': '#808080',
208
- 'AC': '#329e5a',
209
- 'RE': '#2981d4',
210
- 'EX': '#ea7824',
211
- 'CA': '#a21717'
212
- };
213
-
209
+ 'AC': '#329e5a',
210
+ 'RE': '#2981d4',
211
+ 'EX': '#ea7824',
212
+ 'CA': '#a21717'
213
+ };
214
+
214215 return COLORS_BY_STATUS[status];
215216 },
216217 this.getStatusName = function(status) {
....@@ -223,7 +224,7 @@
223224 toaster.pop('success', 'Licenses', $L.get("License '{0}' {1} successfully", license.code, isNew ? $L.get("created") : $L.get("updated")));
224225 }
225226 var _error = function(error) {
226
- console.log(error);
227
+ console.log(error);
227228 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'))));
228229 }
229230 licenseResource.save(license, _success, _error);
....@@ -237,12 +238,12 @@
237238 }
238239 var _createErrorCallback = function(license, actionName, _innerCallback) {
239240 return function(error) {
240
- console.log(error);
241
- _innerCallback && _innerCallback();
241
+ console.log(error);
242
+ _innerCallback && _innerCallback();
242243 toaster.pop('error', actionName, $L.get("Error on action '{0}', license '{1}'. Reason: {2}", actionName, license.code, $L.get(error.headers('X-SECURIS-ERROR-MSG'))));
243244 }
244245 }
245
-
246
+
246247 this.getLicensesList = function(pack, _onsuccess, _onerror) {
247248 return licenseResource.query({packId: pack.id}, _onsuccess, _onerror);
248249 }
....@@ -274,9 +275,9 @@
274275 console.log('Download license: ' + license.id);
275276 var _success = _createSuccessCallback($L.get('Download'), $L.get("License '{0}' {1} successfully", license.code, $L.get("downloaded")), _onsuccess);
276277 var _error = _createErrorCallback(license, $L.get('Download license file'), _onerror);
277
- //window.open(downloadPath, '_blank', '');
278
+ // window.open(downloadPath, '_blank', '');
278279 var _success2 = function(data, headers) {
279
- //console.log(headers.get("Content-Disposition"));
280
+ // console.log(headers.get("Content-Disposition"));
280281 // attachment; filename="license.lic"
281282 var filename = JSON.parse(headers('Content-Disposition').match(/".*"$/g)[0]);
282283 data.$promise.then(function(content) {
....@@ -300,526 +301,530 @@
300301 licenseResource.delete({licenseId: license.id}, _success, _error);
301302 }
302303 }]);
303
-
304
+
304305 app.directive('fileLoader',
305
- function($timeout, $parse) {
306
- return {
307
- restrict : 'A', // only activate on element attribute
308
- require : '',
309
- link : function(scope, element, attrs) {
310
- console.log('scope.license: ' + scope.$parent.license);
311
- var setter = $parse(attrs.fileLoader).assign;
312
- element.bind('change', function(evt) {
313
- if (!window.FileReader) { // Browser is not
314
- // compatible
315
- BootstrapDialog.alert($L.get("Open your .req file with a text editor and copy&paste the content in the form text field?"));
316
- return;
317
- }
318
- console.log('File selected');
319
- // console.log('scope.license: ' +
320
- // scope.$parent.license);
321
- var field = $parse(attrs.fileLoader);
322
- // console.log('field: ' + field);
323
- var fileList = evt.target.files;
324
- if (fileList != null && fileList[0]) {
325
- var reader = new FileReader();
326
- reader.onerror = function(data) {
327
- setter(scope.$parent, 'ERROR');
328
- scope.$apply();
329
- }
330
- reader.onload = function(data) {
331
- setter(scope.$parent, reader.result);
332
- scope.$apply();
333
- }
334
-
335
- reader.readAsText(fileList[0]);
336
- } else {
337
- setter(scope.$parent, '');
338
- scope.$apply();
339
- }
340
- });
341
-
342
- }
343
- };
344
- });
306
+ function($timeout, $parse) {
307
+ return {
308
+ restrict : 'A', // only activate on element attribute
309
+ require : '',
310
+ link : function(scope, element, attrs) {
311
+ console.log('scope.license: ' + scope.$parent.license);
312
+ var setter = $parse(attrs.fileLoader).assign;
313
+ element.bind('change', function(evt) {
314
+ if (!window.FileReader) { // Browser is not
315
+ // compatible
316
+ BootstrapDialog.alert($L.get("Open your .req file with a text editor and copy&paste the content in the form text field?"));
317
+ return;
318
+ }
319
+ console.log('File selected');
320
+ // console.log('scope.license: ' +
321
+ // scope.$parent.license);
322
+ var field = $parse(attrs.fileLoader);
323
+ // console.log('field: ' + field);
324
+ var fileList = evt.target.files;
325
+ if (fileList != null && fileList[0]) {
326
+ var reader = new FileReader();
327
+ reader.onerror = function(data) {
328
+ setter(scope.$parent, 'ERROR');
329
+ scope.$apply();
330
+ }
331
+ reader.onload = function(data) {
332
+ setter(scope.$parent, reader.result);
333
+ scope.$apply();
334
+ }
335
+
336
+ reader.readAsText(fileList[0]);
337
+ } else {
338
+ setter(scope.$parent, '');
339
+ scope.$apply();
340
+ }
341
+ });
342
+
343
+ }
344
+ };
345
+ });
345346
346347
347348 app.controller('PackAndLicensesCtrl', [
348
- '$scope',
349
- '$http',
350
- 'toaster',
351
- '$store',
352
- '$L',
353
- function($scope, $http, toaster, $store, $L) {
354
- $store.set('location', '/licenses');
355
-
356
- $scope.maxLengthErrorMsg = function(displayname, fieldMaxlength) {
357
- return $L.get("{0} length is too long (max: {1}).", $L.get(displayname), fieldMaxlength);
358
- }
359
- $scope.mandatoryFieldErrorMsg = function(displayname) {
360
- return $L.get("'{0}' is required.", $L.get(displayname));
361
- }
362
- $scope.field1ShouldBeGreaterThanField2 = function(field1, field2) {
363
- return $L.get("{0} should be greater than {1}", $L.get(field1), $L.get(field2));
364
- }
365
- $scope.ellipsis = function(txt, len) {
366
- if (!txt || txt.length <= len) return txt;
367
- return txt.substring(0, len) + '...';
368
- }
369
- $scope.currentPack = $store.get('currentPack');
349
+ '$scope',
350
+ '$http',
351
+ 'toaster',
352
+ '$store',
353
+ '$L',
354
+ function($scope, $http, toaster, $store, $L) {
355
+ $store.set('location', '/licenses');
370356
371
- }]);
372
-
373
- app.controller('PacksCtrl', [
374
- '$scope',
375
- '$http',
376
- '$resource',
377
- 'toaster',
378
- 'Catalogs',
379
- 'Packs',
380
- '$store',
381
- '$L',
382
- function($scope, $http, $resource, toaster, Catalogs, Packs, $store, $L) {
383
- $scope.Packs = Packs;
384
-
385
-
386
- $scope.mandatory = {
387
- code: true,
388
- num_licenses: true,
389
- init_valid_date: true,
390
- end_valid_date: true,
391
- status: true,
392
- organization_id: true,
393
- license_type_id: true
394
- }
395
- $scope.maxlength = {
396
- code: 50,
397
- comments: 1024
398
- }
399
- $scope.refs = {};
400
- Catalogs.init().then(function() {
401
- var refFields = [{resource: 'organization', name: 'organization_id'},{resource: 'licensetype', name: 'license_type_id'}];
402
- Catalogs.loadRefs(function(refs) {
403
- $scope.refs = refs;
404
- }, refFields);
405
- });
406
-
407
- // Used to create the form with the appropriate data
408
- $scope.isNew = undefined;
409
-
410
- // Selected pack from listing
411
- // pack is the edited pack, in creation contains the data for
412
- // the new pack
413
- $scope.pack = null;
414
-
415
- $scope.packs = Packs.getPacksList();
416
-
417
- $scope.save = function() {
418
- Packs.savePackData($scope.pack, $scope.isNew, function() {
419
- if (!$scope.isNew) {
420
- $scope.showForm = false;
421
- } else {
422
- $scope.newPack();
423
- }
424
- $scope.packs = Packs.getPacksList();
425
- });
426
- }
427
-
428
- /**
429
- * Execute an action over the pack, activation, onhold,
430
- * cancellation
431
- */
432
- $scope.execute = function(action, pack) {
433
- var _execute = function(extra_data) {
434
- if (extra_data) {
435
- Packs[action](pack || $scope.pack, extra_data, function() {
436
- if (!$scope.isNew) $scope.showForm = false;
437
- $scope.packs = Packs.getPacksList();
438
- });
439
- } else {
440
- Packs[action](pack || $scope.pack, function() {
441
- if (!$scope.isNew) $scope.showForm = false;
442
- $scope.packs = Packs.getPacksList();
443
- });
444
- }
445
- }
446
- if (action === 'delete') {
447
- BootstrapDialog.confirm($L.get("The pack '{0}' will be deleted, are you sure ?", pack.code), function(answer) {
448
- if (answer) {
449
- _execute();
450
- }
451
- });
452
- } else {
453
- if (action === 'cancel') {
454
- BootstrapDialog.show({
455
- title: $L.get("Pack cancellation"),
456
- type: BootstrapDialog.TYPE_DANGER,
457
- message: function(dialog) {
458
- var $content = $('<div></div>');
459
- var $message = $('<div></div>');
460
- $message.append($('<label/>').text($L.get("The pack '{0}' and all its licenses will be cancelled, this action cannot be undone", pack.code)));
461
- $content.append($message);
462
-
463
- var $message = $('<div style="margin-top:10pt;"/>');
464
- var pageToLoad = dialog.getData('pageToLoad');
465
- $message.append($('<label style="margin-right:5pt;"/>').text($L.get("Cancellation reason:") + " "));
466
- $message.append($('<input type="text" style="width:100%;" maxlength="512" id="_pack_cancellation_reason"/>'));
467
- $content.append($message);
468
- return $content;
469
- },
470
- closable: true,
471
- buttons: [{
472
- id: 'btn-cancel',
473
- label: $L.get('Close'),
474
- cssClass: 'btn-default',
475
- action: function(dialogRef) {
476
- dialogRef.close();
477
- }
478
- }, {
479
- id: 'btn-ok',
480
- label: $L.get('Cancel pack'),
481
- cssClass: 'btn-primary',
482
- action: function(dialogRef){
483
- var reason = $('#_pack_cancellation_reason').val();
484
- console.log('Ready to cancel pack, by reason: ' + reason);
485
- if (!reason) {
486
- $('#_pack_cancellation_reason').focus();
487
- } else {
488
- _execute({reason: reason});
489
- dialogRef.close();
490
- }
491
- }
492
- }]
493
- });
494
- } else {
495
- _execute();
496
- }
497
- }
498
- }
499
-
500
-
501
- $scope.newPack = function() {
502
- $scope.isNew = true;
503
- $scope.showForm = true;
504
- $scope.pack = {
505
- license_preactivation: true,
506
- status: 'CR',
507
- num_licenses: 1,
508
- init_valid_date: new Date(),
509
- default_valid_period: 30,
510
- license_type_id: null,
511
- organization_id: null // !$scope.refs.organization_id
512
- // ||
513
- // !$scope.refs.organization_id.length
514
- // ? null :
515
- // $scope.refs.organization_id[0].id
516
- }
517
- setTimeout(function() {
518
- $('#code').focus();
519
- }, 0);
520
- }
521
-
522
- $scope.editPack = function(selectedPack) {
523
- $scope.isNew = false;
524
- $scope.showForm = true;
525
- if (!(selectedPack.init_valid_date instanceof Date)) {
526
- selectedPack.init_valid_date = new Date(selectedPack.init_valid_date);
527
- }
528
- if (!(selectedPack.end_valid_date instanceof Date)) {
529
- selectedPack.end_valid_date = new Date(selectedPack.end_valid_date);
530
- }
531
-
532
- $scope.pack = selectedPack;
533
-
534
- // $scope.pack.organization_name =
535
- // $scope.getLabelFromId('organization_id',
536
- // $scope.pack.organization_id);
537
- $scope.pack.license_type_name = $scope.getLabelFromId('license_type_id', $scope.pack.license_type_id);
538
- $scope.pack.status_name = Packs.getStatusName($scope.pack.status);
539
-
540
- setTimeout(function() {
541
- $('#code').focus();
542
- }, 0);
543
- }
544
-
545
- $scope.deletePack = function(selectedPack) {
546
- $scope.showForm = false;
547
- BootstrapDialog.confirm($L.get("The pack '{0}' will be deleted, are you sure?", selectedPack.code), function(result){
548
- if(result) {
549
- var promise = packResource.remove({}, {id: selectedPack.id}).$promise;
550
- promise.then(function(data) {
551
- $scope.selectPack(null);
552
- $scope.packs = packResource.query();
553
- toaster.pop('success', Catalogs.getName(), $L.get("Pack '{0}' deleted successfully", selectedPack.code));
554
- },function(error) {
555
- console.log(error);
556
- toaster.pop('error', Catalogs.getName(), $L.get("Error deleting pack, reason: {0}. Details: {1}", $L.get(HTTP_ERRORS[error.status]), error.headers('X-SECURIS-ERROR-MSG')), 10000);
557
- });
558
- }
559
- });
560
- $scope.isNew = false;
561
- }
562
-
563
-
564
- $scope.cancel = function() {
565
- $scope.showForm = false;
566
- }
567
-
568
- $scope.selectPack = function(pack) {
569
- $scope.$parent.currentPack = pack;
570
- $store.put('currentPack', pack);
571
- $scope.$parent.$broadcast('pack_changed', pack);
572
- }
573
-
574
- $scope.getLabelFromId = function(field, myid) {
575
- var label = null;
576
- $scope.refs[field].forEach(function (elem) {
577
- if (elem.id === myid) {
578
- label = elem.label;
579
- }
580
- });
581
- return label;
582
- }
583
-
584
- $scope.createMetadataRow = function() {
585
- if (!$scope.formu.metadata) {
586
- $scope.formu.metadata = [];
587
- }
588
- $scope.formu.metadata.push({key: '', value: '', mandatory: true});
589
- }
590
- $scope.removeMetadataKey = function(row_md) {
591
- $scope.formu.metadata.splice( $scope.formu.metadata.indexOf(row_md), 1 );
592
- }
593
- $scope.updateMetadata = function() {
594
- // Called when Application ID change in current field
595
- var newLTId = $scope.pack['license_type_id'];
596
- if (newLTId) {
597
- // Only if there is a "valid" value selected we should
598
- // update the metadata
599
- Catalogs.getResource('licensetype').get({licenseTypeId: newLTId}).$promise.then(function(lt) {
600
- $scope.pack.metadata = [];
601
- lt.metadata.forEach(function(md) {
602
- $scope.pack.metadata.push({
603
- key: md.key,
604
- value: md.value,
605
- readonly: !!md.value,
606
- mandatory: md.mandatory
607
- });
608
- });
609
- });
610
- }
611
- }
612
- } ]);
613
-
614
- app.controller('LicensesCtrl', [
615
- '$scope',
616
- '$http',
617
- '$resource',
618
- 'toaster',
619
- 'Licenses',
620
- '$store',
621
- '$L',
622
- function($scope, $http, $resource, toaster, Licenses, $store, $L) {
623
- $scope.Licenses = Licenses;
624
- $scope.$on('pack_changed', function(evt, message) {
625
- $scope.licenses = Licenses.getLicensesList($scope.currentPack);
626
- $scope.creationAvailable = $scope.currentPack.status == 'AC';
627
- if ($scope.showForm) {
628
- if ($scope.isNew) {
629
- $scope.license.pack_id = $scope.currentPack.id
630
- } else {
631
- $scope.showForm = false;
632
- }
633
- }
634
- })
635
-
636
- $scope.mandatory = {
637
- code: true,
638
- email: true
639
- }
640
- $scope.maxlength = {
641
- code: 50,
642
- request_data: 500,
643
- comments: 1024
644
- }
645
- $scope.refs = {};
646
-
647
- // Used to create the form with the
648
- // appropriate data
649
- $scope.isNew = undefined;
650
-
651
- // Selected license from listing
652
- // license is the edited license, in
653
- // creation contains the data for
654
- // the new license
655
- $scope.license = null;
656
- if ($scope.currentPack) {
657
- $scope.licenses = Licenses.getLicensesList($scope.currentPack);
658
- }
659
-
660
- $scope.save = function() {
661
- Licenses.saveLicenseData($scope.license, $scope.isNew, function() {
662
- if (!$scope.isNew) {
663
- $scope.showForm = false;
664
- } else {
665
- $scope.newLicense();
666
- }
667
- $scope.licenses = Licenses.getLicensesList($scope.currentPack);
668
- });
669
- }
670
-
671
- $scope.newLicense = function() {
672
- if (!$scope.currentPack) {
673
- BootstrapDialog.show({
674
- title: $L.get('New license'),
675
- type: BootstrapDialog.TYPE_WARNING,
676
- message: $L.get('Please, select a pack before to create a new license'),
677
- buttons: [{
678
- label: 'OK',
679
- action: function(dialog) {
680
- dialog.close();
681
- }
682
- }]
683
- });
684
- return;
685
- }
686
- if (!$scope.creationAvailable) {
687
- BootstrapDialog.show({
688
- title: $L.get('Pack not active'),
689
- type: BootstrapDialog.TYPE_WARNING,
690
- message: $L.get('Current pack is not active, so licenses cannot be created'),
691
- buttons: [{
692
- label: 'OK',
693
- action: function(dialog) {
694
- dialog.close();
695
- }
696
- }]
697
- });
698
- return;
699
- }
700
-
701
- $scope.isNew = true;
702
- $scope.showForm = true;
703
- $scope.license = {
704
- pack_id: $scope.currentPack.id
705
- }
706
- setTimeout(function() {
707
- $('#licenseForm * #code').focus();
708
- }, 0);
709
- }
710
-
711
- $scope.editLicense = function(selectedlicense) {
712
- $scope.isNew = false;
713
- $scope.showForm = true;
714
- $scope.license = selectedlicense;
715
- $scope.license.status_name = Licenses.getStatusName($scope.license.status);
716
-
717
- setTimeout(function() {
718
- $('#licenseForm * #code').focus();
719
- }, 0);
720
- }
721
-
722
- $scope.deletelicense = function(selectedlicense) {
723
- $scope.showForm = false;
724
- BootstrapDialog.confirm($L.get("The license '{0}' will be deleted, are you sure?", selectedlicense.code), function(result){
725
- if(result) {
726
- var promise = licenseResource.remove({}, {id: selectedlicense.id}).$promise;
727
- promise.then(function(data) {
728
- $scope.selectlicense(null);
729
- $scope.licenses = Licenses.getLicensesList($scope.currentPack);
730
- toaster.pop('success', Catalogs.getName(), $L.get("License '{0}' deleted successfully", selectedlicense.code));
731
- },function(error) {
732
- console.log(error);
733
- toaster.pop('error', Catalogs.getName(), $L.get("Error deleting license, reason: {0}. Details: {1}", $L.get(HTTP_ERRORS[error.status]), error.headers('X-SECURIS-ERROR-MSG')), 10000);
734
- });
735
- }
736
- });
737
- $scope.isNew = false;
738
- }
739
-
740
- $scope.execute = function(action, license) {
741
- if (!license) {
742
- license = $scope.license;
357
+ $scope.maxLengthErrorMsg = function(displayname, fieldMaxlength) {
358
+ return $L.get("{0} length is too long (max: {1}).", $L.get(displayname), fieldMaxlength);
743359 }
744
- var _execute = function(extra_data) {
745
- if (extra_data) {
746
- Licenses[action](license, extra_data, function() {
747
- if (!$scope.isNew) $scope.showForm = false;
748
- $scope.licenses = Licenses.getLicensesList($scope.currentPack);
749
- });
750
- } else {
751
- Licenses[action](license, function() {
752
- if (!$scope.isNew) $scope.showForm = false;
753
- $scope.licenses = Licenses.getLicensesList($scope.currentPack);
754
- });
755
- }
756
- }
757
- if (action === 'delete') {
758
- BootstrapDialog.confirm($L.get("The license '{0}' will be deleted, are you sure?", license.code), function(result){
759
- if(result) {
760
- _execute();
761
- }
762
- });
763
- } else {
764
- if (action === 'cancel') {
765
- BootstrapDialog.show({
766
- title: $L.get("License cancellation"),
767
- type: BootstrapDialog.TYPE_DANGER,
768
- message: function(dialog) {
769
- var $content = $('<div></div>');
770
- var $message = $('<div></div>');
771
- var pageToLoad = dialog.getData('pageToLoad');
772
- $message.append($('<label/>').text($L.get("This action cannot be undone.", $scope.pack.code)));
773
- $content.append($message);
360
+ $scope.mandatoryFieldErrorMsg = function(displayname) {
361
+ return $L.get("'{0}' is required.", $L.get(displayname));
362
+ }
363
+ $scope.field1ShouldBeGreaterThanField2 = function(field1, field2) {
364
+ return $L.get("{0} should be greater than {1}", $L.get(field1), $L.get(field2));
365
+ }
366
+ $scope.ellipsis = function(txt, len) {
367
+ if (!txt || txt.length <= len) return txt;
368
+ return txt.substring(0, len) + '...';
369
+ }
370
+ $scope.currentPack = $store.get('currentPack');
774371
775
- var $message = $('<div style="margin-top:10pt;"/>');
776
- $message.append($('<label style="margin-right:5pt;"/>').text($L.get("Cancellation reason:") + " "));
777
- $message.append($('<input type="text" style="width:100%;" maxlength="512" id="_lic_cancellation_reason"/>'));
778
- $content.append($message);
779
- return $content;
780
- },
781
- closable: true,
782
- buttons: [{
783
- id: 'btn-cancel',
784
- label: $L.get('Close'),
785
- cssClass: 'btn-default',
786
- action: function(dialogRef) {
787
- dialogRef.close();
788
- }
789
- }, {
790
- id: 'btn-ok',
791
- label: $L.get('Cancel license'),
792
- cssClass: 'btn-primary',
793
- action: function(dialogRef){
794
- var reason = $('#_lic_cancellation_reason').val();
795
- console.log('Ready to cancel license, by reason: ' + reason);
796
- if (!reason) {
797
- $('#_lic_cancellation_reason').focus();
798
- } else {
799
- _execute({reason: reason});
800
- dialogRef.close();
801
- }
802
- }
803
- }]
804
- });
805
- } else {
806
- _execute();
807
- }
808
- }
809
- }
810
-
372
+ }]);
811373
812
- $scope.cancel = function() {
813
- $scope.showForm = false;
814
- }
815
-
816
- $scope.showStatus = function(lic) {
817
-
818
- }
819
- $scope.showStatusLong = function(license) {
820
-
821
- }
822
-
823
- } ]);
374
+ app.controller('PacksCtrl', [
375
+ '$scope',
376
+ '$http',
377
+ '$resource',
378
+ 'toaster',
379
+ 'Catalogs',
380
+ 'Packs',
381
+ '$store',
382
+ '$L',
383
+ function($scope, $http, $resource, toaster, Catalogs, Packs, $store, $L) {
384
+ $scope.Packs = Packs;
385
+
386
+
387
+ $scope.mandatory = {
388
+ code: true,
389
+ num_licenses: true,
390
+ init_valid_date: true,
391
+ end_valid_date: true,
392
+ status: true,
393
+ organization_id: true,
394
+ license_type_id: true
395
+ }
396
+ $scope.maxlength = {
397
+ code: 50,
398
+ comments: 1024
399
+ }
400
+ $scope.refs = {};
401
+ Catalogs.init().then(function() {
402
+ var refFields = [{resource: 'organization', name: 'organization_id'},{resource: 'licensetype', name: 'license_type_id'}];
403
+ Catalogs.loadRefs(function(refs) {
404
+ $scope.refs = refs;
405
+ }, refFields);
406
+ });
407
+
408
+ // Used to create the form with the
409
+ // appropriate data
410
+ $scope.isNew = undefined;
411
+
412
+ // Selected pack from listing
413
+ // pack is the edited pack, in creation
414
+ // contains the data for
415
+ // the new pack
416
+ $scope.pack = null;
417
+
418
+ $scope.packs = Packs.getPacksList();
419
+
420
+ $scope.save = function() {
421
+ Packs.savePackData($scope.pack, $scope.isNew, function() {
422
+ if (!$scope.isNew) {
423
+ $scope.showForm = false;
424
+ } else {
425
+ $scope.newPack();
426
+ }
427
+ $scope.packs = Packs.getPacksList();
428
+ });
429
+ }
430
+
431
+ /**
432
+ * Execute an action over the pack,
433
+ * activation, onhold, cancellation
434
+ */
435
+ $scope.execute = function(action, pack) {
436
+ var _execute = function(extra_data) {
437
+ if (extra_data) {
438
+ Packs[action](pack || $scope.pack, extra_data, function() {
439
+ if (!$scope.isNew) $scope.showForm = false;
440
+ $scope.packs = Packs.getPacksList();
441
+ });
442
+ } else {
443
+ Packs[action](pack || $scope.pack, function() {
444
+ if (!$scope.isNew) $scope.showForm = false;
445
+ $scope.packs = Packs.getPacksList();
446
+ });
447
+ }
448
+ }
449
+ if (action === 'delete') {
450
+ BootstrapDialog.confirm($L.get("The pack '{0}' will be deleted, are you sure ?", pack.code), function(answer) {
451
+ if (answer) {
452
+ _execute();
453
+ }
454
+ });
455
+ } else {
456
+ if (action === 'cancel') {
457
+ BootstrapDialog.show({
458
+ title: $L.get("Pack cancellation"),
459
+ type: BootstrapDialog.TYPE_DANGER,
460
+ message: function(dialog) {
461
+ var $content = $('<div></div>');
462
+ var $message = $('<div></div>');
463
+ $message.append($('<label/>').text($L.get("The pack '{0}' and all its licenses will be cancelled, this action cannot be undone", pack.code)));
464
+ $content.append($message);
465
+
466
+ var $message = $('<div style="margin-top:10pt;"/>');
467
+ var pageToLoad = dialog.getData('pageToLoad');
468
+ $message.append($('<label style="margin-right:5pt;"/>').text($L.get("Cancellation reason:") + " "));
469
+ $message.append($('<input type="text" style="width:100%;" maxlength="512" id="_pack_cancellation_reason"/>'));
470
+ $content.append($message);
471
+ return $content;
472
+ },
473
+ closable: true,
474
+ buttons: [{
475
+ id: 'btn-cancel',
476
+ label: $L.get('Close'),
477
+ cssClass: 'btn-default',
478
+ action: function(dialogRef) {
479
+ dialogRef.close();
480
+ }
481
+ }, {
482
+ id: 'btn-ok',
483
+ label: $L.get('Cancel pack'),
484
+ cssClass: 'btn-primary',
485
+ action: function(dialogRef){
486
+ var reason = $('#_pack_cancellation_reason').val();
487
+ console.log('Ready to cancel pack, by reason: ' + reason);
488
+ if (!reason) {
489
+ $('#_pack_cancellation_reason').focus();
490
+ } else {
491
+ _execute({reason: reason});
492
+ dialogRef.close();
493
+ }
494
+ }
495
+ }]
496
+ });
497
+ } else {
498
+ _execute();
499
+ }
500
+ }
501
+ }
502
+
503
+
504
+ $scope.newPack = function() {
505
+ $scope.isNew = true;
506
+ $scope.showForm = true;
507
+ $scope.pack = {
508
+ license_preactivation: true,
509
+ status: 'CR',
510
+ num_licenses: 1,
511
+ init_valid_date: new Date(),
512
+ default_valid_period: 30,
513
+ license_type_id: null,
514
+ organization_id: null // !$scope.refs.organization_id
515
+ // ||
516
+ // !$scope.refs.organization_id.length
517
+ // ? null :
518
+ // $scope.refs.organization_id[0].id
519
+ }
520
+ setTimeout(function() {
521
+ $('#code').focus();
522
+ }, 0);
523
+ }
524
+
525
+ $scope.editPack = function(selectedPack) {
526
+ $scope.isNew = false;
527
+ $scope.showForm = true;
528
+ if (!(selectedPack.init_valid_date instanceof Date)) {
529
+ selectedPack.init_valid_date = new Date(selectedPack.init_valid_date);
530
+ }
531
+ if (!(selectedPack.end_valid_date instanceof Date)) {
532
+ selectedPack.end_valid_date = new Date(selectedPack.end_valid_date);
533
+ }
534
+
535
+ $scope.pack = selectedPack;
536
+
537
+ // $scope.pack.organization_name =
538
+ // $scope.getLabelFromId('organization_id',
539
+ // $scope.pack.organization_id);
540
+ $scope.pack.license_type_name = $scope.getLabelFromId('license_type_id', $scope.pack.license_type_id);
541
+ $scope.pack.status_name = Packs.getStatusName($scope.pack.status);
542
+
543
+ setTimeout(function() {
544
+ $('#code').focus();
545
+ }, 0);
546
+ }
547
+
548
+ $scope.deletePack = function(selectedPack) {
549
+ $scope.showForm = false;
550
+ BootstrapDialog.confirm($L.get("The pack '{0}' will be deleted, are you sure?", selectedPack.code), function(result){
551
+ if(result) {
552
+ var promise = packResource.remove({}, {id: selectedPack.id}).$promise;
553
+ promise.then(function(data) {
554
+ $scope.selectPack(null);
555
+ $scope.packs = packResource.query();
556
+ toaster.pop('success', Catalogs.getName(), $L.get("Pack '{0}' deleted successfully", selectedPack.code));
557
+ },function(error) {
558
+ console.log(error);
559
+ toaster.pop('error', Catalogs.getName(), $L.get("Error deleting pack, reason: {0}. Details: {1}", $L.get(HTTP_ERRORS[error.status]), error.headers('X-SECURIS-ERROR-MSG')), 10000);
560
+ });
561
+ }
562
+ });
563
+ $scope.isNew = false;
564
+ }
565
+
566
+
567
+ $scope.cancel = function() {
568
+ $scope.showForm = false;
569
+ }
570
+
571
+ $scope.selectPack = function(pack) {
572
+ $scope.$parent.currentPack = pack;
573
+ $store.put('currentPack', pack);
574
+ $scope.$parent.$broadcast('pack_changed', pack);
575
+ }
576
+
577
+ $scope.getLabelFromId = function(field, myid) {
578
+ var label = null;
579
+ $scope.refs[field].forEach(function (elem) {
580
+ if (elem.id === myid) {
581
+ label = elem.label;
582
+ }
583
+ });
584
+ return label;
585
+ }
586
+
587
+ $scope.createMetadataRow = function() {
588
+ if (!$scope.formu.metadata) {
589
+ $scope.formu.metadata = [];
590
+ }
591
+ $scope.formu.metadata.push({key: '', value: '', mandatory: true});
592
+ }
593
+ $scope.removeMetadataKey = function(row_md) {
594
+ $scope.formu.metadata.splice( $scope.formu.metadata.indexOf(row_md), 1 );
595
+ }
596
+ $scope.updateMetadata = function() {
597
+ // Called when Application ID change
598
+ // in current field
599
+ var newLTId = $scope.pack['license_type_id'];
600
+ if (newLTId) {
601
+ // Only if there is a "valid"
602
+ // value selected we should
603
+ // update the metadata
604
+ Catalogs.getResource('licensetype').get({licenseTypeId: newLTId}).$promise.then(function(lt) {
605
+ $scope.pack.metadata = [];
606
+ lt.metadata.forEach(function(md) {
607
+ $scope.pack.metadata.push({
608
+ key: md.key,
609
+ value: md.value,
610
+ readonly: !!md.value,
611
+ mandatory: md.mandatory
612
+ });
613
+ });
614
+ });
615
+ }
616
+ }
617
+ } ]);
618
+
619
+ app.controller('LicensesCtrl', [
620
+ '$scope',
621
+ '$http',
622
+ '$resource',
623
+ 'toaster',
624
+ 'Licenses',
625
+ '$store',
626
+ '$L',
627
+ function($scope, $http, $resource, toaster, Licenses, $store, $L) {
628
+ $scope.Licenses = Licenses;
629
+ $scope.$on('pack_changed', function(evt, message) {
630
+ $scope.licenses = Licenses.getLicensesList($scope.currentPack);
631
+ $scope.creationAvailable = $scope.currentPack.status == 'AC';
632
+ if ($scope.showForm) {
633
+ if ($scope.isNew) {
634
+ $scope.license.pack_id = $scope.currentPack.id
635
+ } else {
636
+ $scope.showForm = false;
637
+ }
638
+ }
639
+ })
640
+
641
+ $scope.mandatory = {
642
+ code: true,
643
+ email: true
644
+ }
645
+ $scope.maxlength = {
646
+ code: 50,
647
+ request_data: 500,
648
+ comments: 1024
649
+ }
650
+ $scope.refs = {};
651
+
652
+ // Used to create the form with the
653
+ // appropriate data
654
+ $scope.isNew = undefined;
655
+
656
+ // Selected license from listing
657
+ // license is the edited license, in
658
+ // creation contains the data for
659
+ // the new license
660
+ $scope.license = null;
661
+ if ($scope.currentPack) {
662
+ $scope.licenses = Licenses.getLicensesList($scope.currentPack);
663
+ }
664
+
665
+ $scope.save = function() {
666
+ Licenses.saveLicenseData($scope.license, $scope.isNew, function() {
667
+ if (!$scope.isNew) {
668
+ $scope.showForm = false;
669
+ } else {
670
+ $scope.newLicense();
671
+ }
672
+ $scope.licenses = Licenses.getLicensesList($scope.currentPack);
673
+ });
674
+ }
675
+
676
+ $scope.newLicense = function() {
677
+ if (!$scope.currentPack) {
678
+ BootstrapDialog.show({
679
+ title: $L.get('New license'),
680
+ type: BootstrapDialog.TYPE_WARNING,
681
+ message: $L.get('Please, select a pack before to create a new license'),
682
+ buttons: [{
683
+ label: 'OK',
684
+ action: function(dialog) {
685
+ dialog.close();
686
+ }
687
+ }]
688
+ });
689
+ return;
690
+ }
691
+ if (!$scope.creationAvailable) {
692
+ BootstrapDialog.show({
693
+ title: $L.get('Pack not active'),
694
+ type: BootstrapDialog.TYPE_WARNING,
695
+ message: $L.get('Current pack is not active, so licenses cannot be created'),
696
+ buttons: [{
697
+ label: 'OK',
698
+ action: function(dialog) {
699
+ dialog.close();
700
+ }
701
+ }]
702
+ });
703
+ return;
704
+ }
705
+
706
+ $scope.isNew = true;
707
+ $scope.showForm = true;
708
+ $scope.license = {
709
+ pack_id: $scope.currentPack.id
710
+ }
711
+ setTimeout(function() {
712
+ $('#licenseForm * #code').focus();
713
+ }, 0);
714
+ }
715
+
716
+ $scope.editLicense = function(selectedlicense) {
717
+ $scope.isNew = false;
718
+ $scope.showForm = true;
719
+ $scope.license = selectedlicense;
720
+ $scope.license.status_name = Licenses.getStatusName($scope.license.status);
721
+
722
+ setTimeout(function() {
723
+ $('#licenseForm * #code').focus();
724
+ }, 0);
725
+ }
726
+
727
+ $scope.deletelicense = function(selectedlicense) {
728
+ $scope.showForm = false;
729
+ BootstrapDialog.confirm($L.get("The license '{0}' will be deleted, are you sure?", selectedlicense.code), function(result){
730
+ if(result) {
731
+ var promise = licenseResource.remove({}, {id: selectedlicense.id}).$promise;
732
+ promise.then(function(data) {
733
+ $scope.selectlicense(null);
734
+ $scope.licenses = Licenses.getLicensesList($scope.currentPack);
735
+ toaster.pop('success', Catalogs.getName(), $L.get("License '{0}' deleted successfully", selectedlicense.code));
736
+ },function(error) {
737
+ console.log(error);
738
+ toaster.pop('error', Catalogs.getName(), $L.get("Error deleting license, reason: {0}. Details: {1}", $L.get(HTTP_ERRORS[error.status]), error.headers('X-SECURIS-ERROR-MSG')), 10000);
739
+ });
740
+ }
741
+ });
742
+ $scope.isNew = false;
743
+ }
744
+
745
+ $scope.execute = function(action, license) {
746
+ if (!license) {
747
+ license = $scope.license;
748
+ }
749
+ var _execute = function(extra_data) {
750
+ if (extra_data) {
751
+ Licenses[action](license, extra_data, function() {
752
+ if (!$scope.isNew) $scope.showForm = false;
753
+ $scope.licenses = Licenses.getLicensesList($scope.currentPack);
754
+ });
755
+ } else {
756
+ Licenses[action](license, function() {
757
+ if (!$scope.isNew) $scope.showForm = false;
758
+ $scope.licenses = Licenses.getLicensesList($scope.currentPack);
759
+ });
760
+ }
761
+ }
762
+ if (action === 'delete') {
763
+ BootstrapDialog.confirm($L.get("The license '{0}' will be deleted, are you sure?", license.code), function(result){
764
+ if(result) {
765
+ _execute();
766
+ }
767
+ });
768
+ } else {
769
+ if (action === 'cancel') {
770
+ BootstrapDialog.show({
771
+ title: $L.get("License cancellation"),
772
+ type: BootstrapDialog.TYPE_DANGER,
773
+ message: function(dialog) {
774
+ var $content = $('<div></div>');
775
+ var $message = $('<div></div>');
776
+ var pageToLoad = dialog.getData('pageToLoad');
777
+ $message.append($('<label/>').text($L.get("This action cannot be undone.", license.code)));
778
+ $content.append($message);
779
+
780
+ var $message = $('<div style="margin-top:10pt;"/>');
781
+ $message.append($('<label style="margin-right:5pt;"/>').text($L.get("Cancellation reason:") + " "));
782
+ $message.append($('<input type="text" style="width:100%;" maxlength="512" id="_lic_cancellation_reason"/>'));
783
+ $content.append($message);
784
+ return $content;
785
+ },
786
+ closable: true,
787
+ buttons: [{
788
+ id: 'btn-cancel',
789
+ label: $L.get('Close'),
790
+ cssClass: 'btn-default',
791
+ action: function(dialogRef) {
792
+ dialogRef.close();
793
+ }
794
+ }, {
795
+ id: 'btn-ok',
796
+ label: $L.get('Cancel license'),
797
+ cssClass: 'btn-primary',
798
+ action: function(dialogRef){
799
+ var reason = $('#_lic_cancellation_reason').val();
800
+ console.log('Ready to cancel license, by reason: ' + reason);
801
+ if (!reason) {
802
+ $('#_lic_cancellation_reason').focus();
803
+ } else {
804
+ _execute({reason: reason});
805
+ dialogRef.close();
806
+ }
807
+ }
808
+ }]
809
+ });
810
+ } else {
811
+ _execute();
812
+ }
813
+ }
814
+ }
815
+
816
+
817
+ $scope.cancel = function() {
818
+ $scope.showForm = false;
819
+ }
820
+
821
+ $scope.showStatus = function(lic) {
822
+
823
+ }
824
+ $scope.showStatusLong = function(license) {
825
+
826
+ }
827
+
828
+ } ]);
824829
825830 })();