| .. | .. |
|---|
| 178 | 178 | cancel: { |
|---|
| 179 | 179 | method: "POST", |
|---|
| 180 | 180 | params: {action: "cancel"} |
|---|
| 181 | | - }, |
|---|
| 181 | + }, // Download a file cannot be done form AJAX, We should do it manually, using $http |
|---|
| 182 | 182 | download: { |
|---|
| 183 | 183 | method: "GET", |
|---|
| 184 | 184 | params: {action: "download"} |
|---|
| 185 | | - }, |
|---|
| 185 | + }, |
|---|
| 186 | 186 | block: { |
|---|
| 187 | 187 | method: "POST", |
|---|
| 188 | 188 | params: {action: "block"} |
|---|
| 189 | 189 | }, |
|---|
| 190 | | - send: { |
|---|
| 190 | + sendEmail: { |
|---|
| 191 | 191 | method: "POST", |
|---|
| 192 | 192 | params: {action: "send"} |
|---|
| 193 | 193 | }, |
|---|
| .. | .. |
|---|
| 256 | 256 | console.log('Block on license: ' + license.id); |
|---|
| 257 | 257 | var _success = _createSuccessCallback($L.get('Block'), $L.get("License '{0}' {1} successfully", license.code, $L.get("blocked")), _onsuccess); |
|---|
| 258 | 258 | var _error = _createErrorCallback(license, $L.get('Block'), _onerror); |
|---|
| 259 | | - licenseResource.putonhold({id: license.id}, _success, _error); |
|---|
| 259 | + licenseResource.block({id: license.id}, _success, _error); |
|---|
| 260 | 260 | } |
|---|
| 261 | 261 | this.unblock = function(license, _onsuccess, _onerror) { |
|---|
| 262 | 262 | console.log('Unblock on license: ' + license.id); |
|---|
| 263 | 263 | var _success = _createSuccessCallback($L.get('Unblock'), $L.get("License '{0}' {1} successfully", license.code, $L.get("unblocked")), _onsuccess); |
|---|
| 264 | 264 | var _error = _createErrorCallback(license, $L.get('Unblock'), _onerror); |
|---|
| 265 | | - licenseResource.putonhold({id: license.id}, _success, _error); |
|---|
| 265 | + licenseResource.unblock({id: license.id}, _success, _error); |
|---|
| 266 | + } |
|---|
| 267 | + this.send = function(license, _onsuccess, _onerror) { |
|---|
| 268 | + console.log('Sending email: ' + license.id); |
|---|
| 269 | + var _success = _createSuccessCallback($L.get('Send email'), $L.get("License '{0}' was sent by email ({1}) successfully", license.code, license.email), _onsuccess); |
|---|
| 270 | + var _error = _createErrorCallback(license, $L.get('Send email'), _onerror); |
|---|
| 271 | + licenseResource.sendEmail({id: license.id}, _success, _error); |
|---|
| 272 | + } |
|---|
| 273 | + this.download = function(license, _onsuccess, _onerror) { |
|---|
| 274 | + console.log('Download license: ' + license.id); |
|---|
| 275 | + var _success = _createSuccessCallback($L.get('Download'), $L.get("License '{0}' {1} successfully", license.code, $L.get("downloaded")), _onsuccess); |
|---|
| 276 | + var _error = _createErrorCallback(license, $L.get('Download license file'), _onerror); |
|---|
| 277 | + //window.open(downloadPath, '_blank', ''); |
|---|
| 278 | + var _success2 = function(data, headers) { |
|---|
| 279 | + //console.log(headers.get("Content-Disposition")); |
|---|
| 280 | + // attachment; filename="license.lic" |
|---|
| 281 | + var filename = JSON.parse(headers('Content-Disposition').match(/".*"$/g)[0]); |
|---|
| 282 | + data.$promise.then(function(content) { |
|---|
| 283 | + saveAs( new Blob([ JSON.stringify(content, null, 2) ], { type : 'application/octet-stream' }), filename); |
|---|
| 284 | + }); |
|---|
| 285 | + _success(); |
|---|
| 286 | + }; |
|---|
| 287 | + licenseResource.download({licenseId: license.id}, _success2, _error); |
|---|
| 266 | 288 | } |
|---|
| 267 | 289 | this.cancel = function(license, extra_data, _onsuccess, _onerror) { |
|---|
| 268 | 290 | console.log('Cancellation on license: ' + license.id); |
|---|