1
|
/**
|
2
|
* Created by sandro on 6/19/15.
|
3
|
*/
|
4
|
|
5
|
|
6
|
|
7
|
dliApp.factory('queryService', ['$http', function ($http) {
|
8
|
|
9
|
var factory = {}
|
10
|
factory.query = function (query, page, filter, value) {
|
11
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
12
|
if (page == null){
|
13
|
return $http.post('/api/post/', $.param({'action': "query", 'query': query, 'filter':filter, 'value':value}));
|
14
|
}
|
15
|
else {
|
16
|
return $http.post('/api/post/', $.param({'action': "query", 'query': query, 'start': (page - 1) * 10, 'filter':filter, 'value':value}));
|
17
|
}
|
18
|
}
|
19
|
factory.getStatsDetail = function () {
|
20
|
//$http.defaults.headers.get["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
21
|
return $http.get('currentStats.json');
|
22
|
}
|
23
|
|
24
|
factory.getStats = function () {
|
25
|
//$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
26
|
return $http.get('stats2.json');
|
27
|
}
|
28
|
|
29
|
factory.getDatasources = function() {
|
30
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
31
|
return $http.post('/api/ds_info/');
|
32
|
}
|
33
|
|
34
|
|
35
|
factory.getItem = function (identifier) {
|
36
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
37
|
return $http.post('/api/item/' + identifier);
|
38
|
}
|
39
|
|
40
|
factory.getItem = function (identifier, type, from) {
|
41
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
42
|
return $http.post('/api/item/' + identifier, $.param({'type': type, 'from': from}));
|
43
|
}
|
44
|
|
45
|
factory.getDsInfo = function (identifier, name) {
|
46
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
47
|
return $http.post('/api/ds_info/', $.param({'id': identifier, 'name':name}));
|
48
|
}
|
49
|
|
50
|
return factory;
|
51
|
}]);
|