|
1 | | -(function(abp, angular) { |
| 1 | +(function (abp, angular) { |
2 | 2 |
|
3 | 3 | if (!angular) { |
4 | 4 | return; |
|
9 | 9 | var abpModule = angular.module('abp', []); |
10 | 10 |
|
11 | 11 | abpModule.config([ |
12 | | - '$httpProvider', function($httpProvider) { |
| 12 | + '$httpProvider', function ($httpProvider) { |
13 | 13 | //$httpProvider.defaults.transformResponse.push(function (a) { |
14 | 14 | // return a; |
15 | 15 | //}); |
16 | 16 | } |
17 | 17 | ]); |
18 | 18 |
|
19 | 19 | abpModule.factory('abp.$http', [ |
20 | | - '$q', '$http', function($q, $http) { |
21 | | - return function (options) { |
| 20 | + '$q', '$http', function ($q, $http) { |
22 | 21 |
|
23 | | - options.transformResponse = function(strData) { |
24 | | - var data = strData && JSON.parse(strData); |
25 | | - if (data) { |
26 | | - if (data.targetUrl) { |
27 | | - location.href = data.targetUrl; |
28 | | - } |
29 | | - |
30 | | - if (data.success === true) { |
31 | | - return data.result; |
32 | | - } else { //data.success === false |
33 | | - if (data.error) { |
34 | | - abp.message.error(data.error.message); |
35 | | - } |
36 | | - |
37 | | - if (data.unAuthorizedRequest && !data.targetUrl) { |
38 | | - location.reload(); |
39 | | - } |
40 | | - |
41 | | - if (data.targetUrl) { |
42 | | - location.href = data.targetUrl; |
43 | | - } |
44 | | - |
45 | | - //TODO: ERROR |
46 | | - return null; |
47 | | - } |
48 | | - } else { //no data sent to back |
49 | | - return strData; |
50 | | - } |
51 | | - }; |
| 22 | + //var defaultOptions = { |
| 23 | + // transformResponse: function (strData) { |
| 24 | + // if (!strData) { |
| 25 | + // return strData; |
| 26 | + // } |
| 27 | + |
| 28 | + // var data = JSON.parse(strData); |
| 29 | + // if (!data) { //Needless check? |
| 30 | + // return strData; |
| 31 | + // } |
| 32 | + |
| 33 | + // if (data.targetUrl) { //TODO: Check if it works and does not prevent return value! |
| 34 | + // location.href = data.targetUrl; |
| 35 | + // } |
| 36 | + |
| 37 | + // if (data.success === true) { |
| 38 | + // return data.result; |
| 39 | + // } else { //data.success === false |
| 40 | + // if (data.error) { |
| 41 | + // abp.log.error(data.error.details); |
| 42 | + // abp.message.error(data.error.message); |
| 43 | + // } |
| 44 | + |
| 45 | + // if (data.unAuthorizedRequest && !data.targetUrl) { |
| 46 | + // location.reload(); |
| 47 | + // } |
52 | 48 |
|
53 | | - return $http(options); |
| 49 | + // return data; |
| 50 | + // } |
| 51 | + |
| 52 | + // } |
| 53 | + //}; |
| 54 | + |
| 55 | + return function (options) { |
| 56 | + |
| 57 | + return $http($.extend({}, defaultOptions, options)); |
54 | 58 | }; |
55 | 59 | } |
56 | 60 | ]); |
57 | 61 |
|
58 | 62 | abpModule.factory('services.tasksystem.task', [ |
59 | | - 'abp.$http', function($http) { |
60 | | - return new function() { |
61 | | - //this.getTasks = abp.services.tasksystem.task.getTasks; |
62 | | - |
| 63 | + 'abp.$http', function ($http) { |
| 64 | + return new function () { |
63 | 65 | //Working on this code! |
64 | | - this.getTasks = function(input) { |
| 66 | + this.getTasks = function (input) { |
65 | 67 | return $http({ |
66 | 68 | url: '/api/services/tasksystem/task/GetTasks', |
67 | 69 | method: 'POST', |
|
0 commit comments