| .. | .. |
|---|
| 1 | 1 | (function() { |
|---|
| 2 | 2 | 'use strict'; |
|---|
| 3 | + |
|---|
| 4 | + var LIC_STATUS = { |
|---|
| 5 | + CREATED: 1, |
|---|
| 6 | + REQUESTED: 2, |
|---|
| 7 | + PREACTIVE: 3, |
|---|
| 8 | + ACTIVE: 4, |
|---|
| 9 | + CANCELED: 5 |
|---|
| 10 | + } |
|---|
| 11 | + |
|---|
| 12 | + var ACTIONS_BY_STATUS = { |
|---|
| 13 | + activate: [LIC_STATUS.REQUESTED, LIC_STATUS.PREACTIVE], |
|---|
| 14 | + send: [LIC_STATUS.ACTIVE, LIC_STATUS.PREACTIVE], |
|---|
| 15 | + download: [LIC_STATUS.ACTIVE, LIC_STATUS.PREACTIVE], |
|---|
| 16 | + request: [LIC_STATUS.CREATED, LIC_STATUS.REQUESTED], |
|---|
| 17 | + cancel: [LIC_STATUS.REQUESTED, LIC_STATUS.PREACTIVE, LIC_STATUS.ACTIVE], |
|---|
| 18 | + 'delete': [LIC_STATUS.CREATED, LIC_STATUS.CANCELED], |
|---|
| 19 | + } |
|---|
| 3 | 20 | |
|---|
| 4 | 21 | var HTTP_ERRORS = { |
|---|
| 5 | 22 | 401: "Unathorized action", |
|---|
| .. | .. |
|---|
| 19 | 36 | console.log('scope.license: ' + scope.$parent.license); |
|---|
| 20 | 37 | var setter = $parse(attrs.fileLoader).assign; |
|---|
| 21 | 38 | element.bind('change', function(evt) { |
|---|
| 22 | | - console.log('scope.license: ' + scope.$parent.license); |
|---|
| 39 | + if (!window.FileReader) { // Browser is not compatible |
|---|
| 40 | + BootstrapDialog.alert($L.get("Open your .req file with a text editor and copy&paste the content in the form text field?")); |
|---|
| 41 | + return; |
|---|
| 42 | + } |
|---|
| 43 | + //console.log('scope.license: ' + scope.$parent.license); |
|---|
| 23 | 44 | var field = $parse(attrs.fileLoader); |
|---|
| 24 | | - console.log('field: ' + field); |
|---|
| 45 | + //console.log('field: ' + field); |
|---|
| 25 | 46 | var fileList = evt.target.files; |
|---|
| 26 | 47 | if (fileList != null && fileList[0]) { |
|---|
| 27 | 48 | var reader = new FileReader(); |
|---|
| 28 | 49 | reader.onerror = function(data) { |
|---|
| 29 | 50 | setter(scope.$parent, 'ERROR'); |
|---|
| 30 | | - scope.$apply(); |
|---|
| 51 | + //scope.$apply(); |
|---|
| 31 | 52 | } |
|---|
| 32 | 53 | reader.onload = function(data) { |
|---|
| 33 | 54 | setter(scope.$parent, reader.result); |
|---|
| 34 | | - scope.$apply(); |
|---|
| 55 | + //scope.$apply(); |
|---|
| 35 | 56 | } |
|---|
| 36 | 57 | |
|---|
| 37 | 58 | reader.readAsText(fileList[0]); |
|---|
| 38 | 59 | } else { |
|---|
| 39 | | - console.log('NO FILE: '); |
|---|
| 40 | | - field = ''; |
|---|
| 41 | | - scope.$apply(); |
|---|
| 60 | + setter(scope.$parent, ''); |
|---|
| 61 | + //scope.$apply(); |
|---|
| 42 | 62 | } |
|---|
| 43 | 63 | }); |
|---|
| 44 | 64 | |
|---|
| .. | .. |
|---|
| 46 | 66 | }; |
|---|
| 47 | 67 | }); |
|---|
| 48 | 68 | |
|---|
| 49 | | - console.log(' OK ????? '); |
|---|
| 50 | 69 | |
|---|
| 51 | 70 | app.controller('PackAndLicensesCtrl', [ |
|---|
| 52 | 71 | '$scope', |
|---|
| .. | .. |
|---|
| 312 | 331 | $scope.showStatus = function(lic) { |
|---|
| 313 | 332 | |
|---|
| 314 | 333 | } |
|---|
| 315 | | - $scope.showStatusComplete = function(license) { |
|---|
| 334 | + $scope.showStatusLong = function(license) { |
|---|
| 316 | 335 | |
|---|
| 317 | 336 | } |
|---|
| 318 | | - $scope.isActionVisible = function(actionMask, lic) { |
|---|
| 319 | | - |
|---|
| 337 | + $scope.isActionVisible = function(action, lic) { |
|---|
| 338 | + var validStatuses = ACTIONS_BY_STATUS[action]; |
|---|
| 339 | + return lic && validStatuses.indexOf(lic.status) !== -1; |
|---|
| 320 | 340 | } |
|---|
| 321 | 341 | |
|---|
| 322 | 342 | } ]); |
|---|