1 |
46770
|
sandro.lab
|
/**
|
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 |
50035
|
sandro.lab
|
if (page === null){
|
13 |
46770
|
sandro.lab
|
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 |
50035
|
sandro.lab
|
};
|
19 |
50064
|
sandro.lab
|
|
20 |
|
|
factory.queryPid = function (pid) {
|
21 |
|
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
22 |
|
|
console.log("Make query for PID "+pid)
|
23 |
|
|
return $http.post('/api/queryPid/', $.param({ 'pid': pid}));
|
24 |
|
|
};
|
25 |
|
|
|
26 |
46770
|
sandro.lab
|
factory.getStatsDetail = function () {
|
27 |
|
|
//$http.defaults.headers.get["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
28 |
|
|
return $http.get('currentStats.json');
|
29 |
50035
|
sandro.lab
|
};
|
30 |
46770
|
sandro.lab
|
|
31 |
|
|
factory.getStats = function () {
|
32 |
|
|
//$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
33 |
|
|
return $http.get('stats2.json');
|
34 |
50035
|
sandro.lab
|
};
|
35 |
46770
|
sandro.lab
|
|
36 |
|
|
factory.getDatasources = function() {
|
37 |
|
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
38 |
|
|
return $http.post('/api/ds_info/');
|
39 |
50035
|
sandro.lab
|
};
|
40 |
46770
|
sandro.lab
|
|
41 |
|
|
|
42 |
|
|
factory.getItem = function (identifier) {
|
43 |
|
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
44 |
|
|
return $http.post('/api/item/' + identifier);
|
45 |
50035
|
sandro.lab
|
};
|
46 |
46770
|
sandro.lab
|
|
47 |
|
|
factory.getItem = function (identifier, type, from) {
|
48 |
|
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
49 |
|
|
return $http.post('/api/item/' + identifier, $.param({'type': type, 'from': from}));
|
50 |
50035
|
sandro.lab
|
};
|
51 |
46770
|
sandro.lab
|
|
52 |
|
|
factory.getDsInfo = function (identifier, name) {
|
53 |
|
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
54 |
|
|
return $http.post('/api/ds_info/', $.param({'id': identifier, 'name':name}));
|
55 |
50035
|
sandro.lab
|
};
|
56 |
46770
|
sandro.lab
|
|
57 |
50035
|
sandro.lab
|
|
58 |
|
|
factory.resolveIdentifier = function (pid, pid_type) {
|
59 |
|
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
60 |
|
|
return $http.post('api/resolveId/', $.param({'pid': pid, 'pid_type':pid_type}));
|
61 |
|
|
};
|
62 |
|
|
|
63 |
46770
|
sandro.lab
|
return factory;
|
64 |
|
|
}]);
|