1
|
/**
|
2
|
* Created by sandro on 11/11/15.
|
3
|
*/
|
4
|
|
5
|
|
6
|
dliApp.controller('detailController', ['$scope', '$routeParams', '$location', 'queryService', function ($scope, $routeParams, $location, queryService) {
|
7
|
$scope.identifier = $routeParams['id'];
|
8
|
$scope.activeTabName ="";
|
9
|
$scope.currentDatasetPage =1
|
10
|
$scope.currentPublicationPage =1
|
11
|
$scope.currentUnknownPage =1
|
12
|
|
13
|
|
14
|
queryService.getItem($scope.identifier).success(function (data) {
|
15
|
if ('result' in data) {
|
16
|
if ('hits' in data.result) {
|
17
|
|
18
|
var summary = data.result.hits[0];
|
19
|
var relations = data.result.hits[1];
|
20
|
|
21
|
relPubs = summary['relatedPublications']
|
22
|
relData = summary['relatedDatasets']
|
23
|
relUnk = summary['relatedUnknown']
|
24
|
|
25
|
$scope.item = summary;
|
26
|
$scope.relations = relations;
|
27
|
|
28
|
$('#myTabs a').click(function (e) {
|
29
|
e.preventDefault()
|
30
|
$(this).tab('show')
|
31
|
});
|
32
|
}
|
33
|
}
|
34
|
}).error(function (data) {
|
35
|
$scope.hideSpinner();
|
36
|
});
|
37
|
|
38
|
|
39
|
$scope.startSearch= function (type, nextPage) {
|
40
|
queryService.getItem($scope.identifier, type, nextPage).success(function (data) {
|
41
|
if ('result' in data) {
|
42
|
if ('hits' in data.result) {
|
43
|
|
44
|
var summary = data.result.hits[0];
|
45
|
var relations = data.result.hits[1];
|
46
|
|
47
|
$scope.item = summary;
|
48
|
$scope.relations = relations;
|
49
|
|
50
|
$('#myTabs a').click(function (e) {
|
51
|
e.preventDefault()
|
52
|
$(this).tab('show')
|
53
|
});
|
54
|
}
|
55
|
}
|
56
|
}).error(function (data) {
|
57
|
$scope.hideSpinner();
|
58
|
});
|
59
|
}
|
60
|
|
61
|
$scope.nextPage = function (type) {
|
62
|
var nextPage = 0;
|
63
|
if (type === 'dataset'){
|
64
|
nextPage = ++$scope.currentDatasetPage * 10;
|
65
|
}
|
66
|
if (type === 'publication'){
|
67
|
nextPage = ++$scope.currentPublicationPage * 10;
|
68
|
}
|
69
|
if (type === 'unknown'){
|
70
|
nextPage = ++$scope.currentUnknownPage *10;
|
71
|
}
|
72
|
$scope.startSearch(type, nextPage)
|
73
|
}
|
74
|
|
75
|
$scope.prevPage = function (type) {
|
76
|
var prevPage = 0;
|
77
|
if (type === 'dataset'){
|
78
|
prevPage = --$scope.currentDatasetPage * 10;
|
79
|
}
|
80
|
if (type === 'publication'){
|
81
|
prevPage = --$scope.currentPublicationPage * 10;
|
82
|
}
|
83
|
if (type === 'unknown'){
|
84
|
prevPage = --$scope.currentUnknownPage *10;
|
85
|
}
|
86
|
$scope.startSearch(type, prevPage)
|
87
|
}
|
88
|
|
89
|
|
90
|
|
91
|
$scope.activeClass = function(name) {
|
92
|
if (name === $scope.activeTabName)
|
93
|
return "active";
|
94
|
return "";
|
95
|
}
|
96
|
|
97
|
}]);
|
98
|
|
99
|
|
100
|
|
101
|
|
102
|
dliApp.controller('queryController', ['$scope', '$routeParams', '$location', 'queryService', function ($scope, $routeParams, $location, queryService) {
|
103
|
|
104
|
//TO DO Titolo non più lungo di 240 caratteri in caso aggiungere puntini
|
105
|
// Oltre il quarto autore aggiungere puntini
|
106
|
|
107
|
$scope.makeQuery= function () {
|
108
|
$location.path("/query/q=" + $scope.query);
|
109
|
};
|
110
|
|
111
|
|
112
|
$scope.query = $routeParams['q'];
|
113
|
|
114
|
$scope.filterType = $routeParams['f'];
|
115
|
$scope.filters = []
|
116
|
|
117
|
|
118
|
|
119
|
$scope.calculateFilter= function(ftype, fValue) {
|
120
|
if ($scope.filterType != null && $scope.filterType.length >0 ) {
|
121
|
return $scope.filterType +"__"+ftype+"_"+fValue;
|
122
|
} else
|
123
|
return ftype+"_"+fValue;
|
124
|
|
125
|
}
|
126
|
|
127
|
|
128
|
if ($scope.query == null || $scope.query.length == 0) {
|
129
|
$location.path("/")
|
130
|
}
|
131
|
$scope.page = $routeParams['page'];
|
132
|
$scope.filter = $routeParams['f'];
|
133
|
$scope.total = 0;
|
134
|
$scope.pageFrom = 1;
|
135
|
$scope.pageto = 6;
|
136
|
|
137
|
|
138
|
$scope.filterPath = function () {
|
139
|
if ($scope.filterType != null && $scope.filterType.length >0 ) {
|
140
|
return $scope.filterType+ "/";
|
141
|
}
|
142
|
return"";
|
143
|
|
144
|
}
|
145
|
|
146
|
if ($scope.page != null) {
|
147
|
$scope.page = parseInt($scope.page);
|
148
|
$scope.pageFrom = Math.max(1, $scope.page - 4);
|
149
|
$scope.pageto = $scope.page + 4;
|
150
|
}
|
151
|
$scope.pageRange = [];
|
152
|
$scope.activePage = function (n) {
|
153
|
if (n == $scope.page)
|
154
|
return "active";
|
155
|
return ""
|
156
|
};
|
157
|
$scope.doSomething = function () {
|
158
|
$location.path("/query/q=" + $scope.query);
|
159
|
};
|
160
|
|
161
|
queryService.query($scope.query, $scope.page, $scope.filter).success(function (data) {
|
162
|
|
163
|
$scope.result_query = data['result']['hits'];
|
164
|
$scope.facet = data['result']['facet'];
|
165
|
$scope.total = data['result']['total'];
|
166
|
|
167
|
var totalPages = Math.round($scope.total / 10);
|
168
|
|
169
|
if ($scope.total > 10 && $scope.total % 10)
|
170
|
totalPages += 1;
|
171
|
|
172
|
$scope.totalPages = totalPages ;
|
173
|
|
174
|
$scope.lastPage = Math.min($scope.pageto, totalPages - 1);
|
175
|
|
176
|
|
177
|
if ($scope.page != null)
|
178
|
$scope.pageto = Math.max(Math.min($scope.pageFrom + 4, $scope.lastPage), $scope.page);
|
179
|
else {
|
180
|
$scope.page = 1;
|
181
|
$scope.pageto = Math.max(Math.min($scope.pageFrom + 4, $scope.lastPage), 1);
|
182
|
}
|
183
|
$scope.pageRange = [];
|
184
|
for (var i = $scope.pageFrom; i <= $scope.pageto; i++) {
|
185
|
$scope.pageRange.push(i)
|
186
|
}
|
187
|
}).error(function (data) {
|
188
|
|
189
|
})
|
190
|
}]);
|