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 === undefined || page ==null){
|
13
|
return $http.post('/api/post/', $.param({'action': "query", 'query': query, 'filter':filter, start:0}));
|
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
|
|
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
|
factory.getStatsDetail = function () {
|
27
|
//$http.defaults.headers.get["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
28
|
return $http.get('static/currentStats.json');
|
29
|
};
|
30
|
|
31
|
factory.getMainPageStats = function () {
|
32
|
//$http.defaults.headers.get["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
33
|
return $http.get('/api/main_page_stats');
|
34
|
};
|
35
|
|
36
|
factory.getStats = function () {
|
37
|
//$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
38
|
return $http.get('static/stats2.json');
|
39
|
};
|
40
|
|
41
|
factory.getDatasources = function() {
|
42
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
43
|
return $http.post('/api/ds_info/');
|
44
|
};
|
45
|
|
46
|
|
47
|
factory.getItem = function (identifier) {
|
48
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
49
|
return $http.post('/api/item/' + identifier);
|
50
|
};
|
51
|
|
52
|
factory.getItem = function (identifier, type, from) {
|
53
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
54
|
return $http.post('/api/item/' + identifier, $.param({'object_type': type, 'start': from}));
|
55
|
};
|
56
|
|
57
|
factory.getDsInfo = function (identifier, name) {
|
58
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
59
|
return $http.post('/api/ds_info/', $.param({'id': identifier, 'name':name}));
|
60
|
};
|
61
|
|
62
|
|
63
|
factory.resolveIdentifier = function (pid, pid_type) {
|
64
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
65
|
return $http.post('api/resolveId/', $.param({'pid': pid, 'pid_type':pid_type}));
|
66
|
};
|
67
|
|
68
|
return factory;
|
69
|
}]);
|