1
- var abp = abp || { } ;
2
- ( function ( angular ) {
1
+ ( function ( abp , angular ) {
3
2
4
3
if ( ! angular ) {
5
4
return ;
9
8
10
9
var abpModule = angular . module ( 'abp' , [ ] ) ;
11
10
12
- abpModule . factory ( 'services.tasksystem.task' , [ '$http' , function ( $http ) {
13
- return new function ( ) {
14
- this . getTasks = abp . services . tasksystem . task . getTasks ;
15
-
16
- //Working on this code!
17
- //this.getTasks = function(input) {
18
- // return $http({
19
- // url: '/api/services/tasksystem/task/GetTasks',
20
- // method: 'POST',
21
- // data: JSON.stringify(input)
22
- // });
23
- //};
24
- } ;
25
- } ] ) ;
26
-
27
- } ) ( angular || undefined ) ;
11
+ abpModule . config ( [
12
+ '$httpProvider' , function ( $httpProvider ) {
13
+ //$httpProvider.defaults.transformResponse.push(function (a) {
14
+ // return a;
15
+ //});
16
+ }
17
+ ] ) ;
18
+
19
+ abpModule . factory ( 'abp.$http' , [
20
+ '$q' , '$http' , function ( $q , $http ) {
21
+ return function ( options ) {
22
+
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
+ } ;
52
+
53
+ return $http ( options ) ;
54
+ } ;
55
+ }
56
+ ] ) ;
57
+
58
+ abpModule . factory ( 'services.tasksystem.task' , [
59
+ 'abp.$http' , function ( $http ) {
60
+ return new function ( ) {
61
+ //this.getTasks = abp.services.tasksystem.task.getTasks;
62
+
63
+ //Working on this code!
64
+ this . getTasks = function ( input ) {
65
+ return $http ( {
66
+ url : '/api/services/tasksystem/task/GetTasks' ,
67
+ method : 'POST' ,
68
+ data : JSON . stringify ( input )
69
+ } ) ;
70
+ } ;
71
+ } ;
72
+ }
73
+ ] ) ;
74
+
75
+ } ) ( ( abp || ( abp = { } ) ) , ( angular || undefined ) ) ;
0 commit comments