| .. | .. |
|---|
| 20 | 20 | |
|---|
| 21 | 21 | var HTTP_ERRORS = { |
|---|
| 22 | 22 | 401: "Unathorized action", |
|---|
| 23 | + 418: "Application error", |
|---|
| 23 | 24 | 403: "Forbidden action", |
|---|
| 24 | 25 | 500: "Server error", |
|---|
| 25 | 26 | 404: "Element not found" |
|---|
| .. | .. |
|---|
| 40 | 41 | BootstrapDialog.alert($L.get("Open your .req file with a text editor and copy&paste the content in the form text field?")); |
|---|
| 41 | 42 | return; |
|---|
| 42 | 43 | } |
|---|
| 44 | + console.log('File selected'); |
|---|
| 43 | 45 | //console.log('scope.license: ' + scope.$parent.license); |
|---|
| 44 | 46 | var field = $parse(attrs.fileLoader); |
|---|
| 45 | 47 | //console.log('field: ' + field); |
|---|
| .. | .. |
|---|
| 48 | 50 | var reader = new FileReader(); |
|---|
| 49 | 51 | reader.onerror = function(data) { |
|---|
| 50 | 52 | setter(scope.$parent, 'ERROR'); |
|---|
| 51 | | - //scope.$apply(); |
|---|
| 53 | + scope.$apply(); |
|---|
| 52 | 54 | } |
|---|
| 53 | 55 | reader.onload = function(data) { |
|---|
| 54 | 56 | setter(scope.$parent, reader.result); |
|---|
| 55 | | - //scope.$apply(); |
|---|
| 57 | + scope.$apply(); |
|---|
| 56 | 58 | } |
|---|
| 57 | 59 | |
|---|
| 58 | 60 | reader.readAsText(fileList[0]); |
|---|
| 59 | 61 | } else { |
|---|
| 60 | 62 | setter(scope.$parent, ''); |
|---|
| 61 | | - //scope.$apply(); |
|---|
| 63 | + scope.$apply(); |
|---|
| 62 | 64 | } |
|---|
| 63 | 65 | }); |
|---|
| 64 | 66 | |
|---|
| .. | .. |
|---|
| 182 | 184 | $scope.editPack = function(selectedPack) { |
|---|
| 183 | 185 | $scope.isNew = false; |
|---|
| 184 | 186 | $scope.showForm = true; |
|---|
| 187 | + if (!(selectedPack.init_valid_date instanceof Date)) { |
|---|
| 188 | + selectedPack.init_valid_date = new Date(selectedPack.init_valid_date); |
|---|
| 189 | + } |
|---|
| 190 | + if (!(selectedPack.end_valid_date instanceof Date)) { |
|---|
| 191 | + selectedPack.end_valid_date = new Date(selectedPack.end_valid_date); |
|---|
| 192 | + } |
|---|
| 185 | 193 | $scope.pack = selectedPack; |
|---|
| 186 | | - setTimeout(function() { |
|---|
| 194 | + setTimeout(function() { |
|---|
| 187 | 195 | $('#code').focus(); |
|---|
| 188 | 196 | }, 0); |
|---|
| 189 | 197 | } |
|---|
| .. | .. |
|---|
| 292 | 300 | } |
|---|
| 293 | 301 | $scope.maxlength = { |
|---|
| 294 | 302 | code: 50, |
|---|
| 303 | + request_data: 500, |
|---|
| 295 | 304 | comments: 1024 |
|---|
| 296 | 305 | } |
|---|
| 297 | 306 | $scope.refs = {}; |
|---|
| .. | .. |
|---|
| 319 | 328 | // }); |
|---|
| 320 | 329 | |
|---|
| 321 | 330 | $scope.save = function() { |
|---|
| 322 | | - $( "form#licenseForm" ) |
|---|
| 323 | | - .attr( "enctype", "multipart/form-data" ) |
|---|
| 324 | | - .attr( "encoding", "multipart/form-data" ); |
|---|
| 331 | + //$( "form#licenseForm" ).attr( "enctype", "multipart/form-data" ).attr( "encoding", "multipart/form-data" ); |
|---|
| 325 | 332 | var _success = function() { |
|---|
| 326 | 333 | if (!$scope.isNew) $scope.showForm = false; |
|---|
| 327 | 334 | $scope.licenses = licenseResource.query({packId: $scope.currentPack.id}); |
|---|
| 328 | | - } |
|---|
| 329 | | - licenseResource.save_w_upload($scope.license, _success) |
|---|
| 335 | + toaster.pop('success', Catalogs.getName(), $L.get("License '{0}' {1} successfully", $scope.license.code, $scope.isNew ? $L.get("created") : $L.get("updated"))); |
|---|
| 336 | + } |
|---|
| 337 | + var _error = function(error) { |
|---|
| 338 | + console.log(error); |
|---|
| 339 | + toaster.pop('error', Catalogs.getName(), $L.get("Error {0} license '{1}'. Reason: {2}", $scope.isNew ? $L.get("creating") : $L.get("updating"), $scope.pack.code, $L.get(error.headers('X-SECURIS-ERROR')))); |
|---|
| 340 | + } |
|---|
| 341 | + licenseResource.save($scope.license, _success, _error) |
|---|
| 330 | 342 | } |
|---|
| 331 | 343 | |
|---|
| 332 | 344 | $scope.newLicense = function() { |
|---|
| .. | .. |
|---|
| 395 | 407 | } |
|---|
| 396 | 408 | $scope.isActionVisible = function(action, lic) { |
|---|
| 397 | 409 | var validStatuses = ACTIONS_BY_STATUS[action]; |
|---|
| 398 | | - return lic && validStatuses.indexOf(lic.status) !== -1; |
|---|
| 410 | + return lic && validStatuses && validStatuses.indexOf(lic.status) !== -1; |
|---|
| 399 | 411 | } |
|---|
| 400 | 412 | |
|---|
| 401 | 413 | } ]); |
|---|