Skip to content

Commit cdc250e

Browse files
committed
Working on abp.ng module
1 parent d9698f4 commit cdc250e

File tree

2 files changed

+69
-22
lines changed
  • SimpleTaskSystemSPA_AngularJs_EntityFramework/SimpleTaskSystem.Web

2 files changed

+69
-22
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
var abp = abp || {};
2-
(function (angular) {
1+
(function(abp, angular) {
32

43
if (!angular) {
54
return;
@@ -9,19 +8,68 @@
98

109
var abpModule = angular.module('abp', []);
1110

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));

SimpleTaskSystemSPA_AngularJs_EntityFramework/SimpleTaskSystem.Web/App/Main/views/task/list.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616
});
1717

1818
vm.refreshTasks = function () {
19+
//NOTE: Working on task service!
1920
taskService.getTasks({
2021
state: $scope.selectedTaskState > 0 ? $scope.selectedTaskState : null
21-
}).done(function (data) {
22-
$scope.$apply(function() {
23-
vm.tasks = data.tasks;
24-
});
22+
}).success(function (data) {
23+
vm.tasks = data.tasks;
2524
});
2625
};
2726

0 commit comments

Comments
 (0)