1 |
34144
|
sandro.lab
|
var mdstoreInspectorControllers = angular.module('mdstoreInspectorControllers', ['LocalStorageModule']);
|
2 |
|
|
|
3 |
|
|
function common_init($scope, $http, $sce, $location) {
|
4 |
39627
|
sandro.lab
|
initSpinner();
|
5 |
|
|
$scope.showError = function (error) {
|
6 |
|
|
show_notification("error", error);
|
7 |
|
|
}
|
8 |
|
|
$scope.showNotification = function (message) {
|
9 |
|
|
show_notification("info", message);
|
10 |
|
|
}
|
11 |
|
|
$scope.showSpinner = function () {
|
12 |
|
|
showSpinner();
|
13 |
|
|
}
|
14 |
|
|
$scope.hideSpinner = function () {
|
15 |
|
|
hideSpinner();
|
16 |
|
|
}
|
17 |
|
|
$scope.to_trusted = function (html) {
|
18 |
|
|
return $sce.trustAsHtml(html);
|
19 |
|
|
}
|
20 |
|
|
$scope.go = function (path) {
|
21 |
|
|
$location.path(path);
|
22 |
|
|
}
|
23 |
|
|
$scope.encodeValue = function (val) {
|
24 |
|
|
return val;
|
25 |
|
|
}
|
26 |
34144
|
sandro.lab
|
}
|
27 |
|
|
|
28 |
39627
|
sandro.lab
|
function ngGridFlexibleHeightPlugin(opts) {
|
29 |
|
|
var self = this;
|
30 |
|
|
self.grid = null;
|
31 |
|
|
self.scope = null;
|
32 |
|
|
self.init = function (scope, grid, services) {
|
33 |
|
|
self.domUtilityService = services.DomUtilityService;
|
34 |
|
|
self.grid = grid;
|
35 |
|
|
self.scope = scope;
|
36 |
|
|
var recalcHeightForData = function () {
|
37 |
|
|
setTimeout(innerRecalcForData, 1);
|
38 |
|
|
};
|
39 |
|
|
var innerRecalcForData = function () {
|
40 |
|
|
var gridId = self.grid.gridId;
|
41 |
|
|
var footerPanelSel = '.' + gridId + ' .ngFooterPanel';
|
42 |
|
|
var extraHeight = self.grid.$topPanel.height() + $(footerPanelSel).height();
|
43 |
|
|
var naturalHeight = self.grid.$canvas.height() + 1;
|
44 |
|
|
if (opts != null) {
|
45 |
|
|
if (opts.minHeight != null && (naturalHeight + extraHeight) < opts.minHeight) {
|
46 |
|
|
naturalHeight = opts.minHeight - extraHeight - 2;
|
47 |
|
|
}
|
48 |
|
|
if (opts.maxHeight != null && (naturalHeight + extraHeight) > opts.maxHeight) {
|
49 |
|
|
naturalHeight = opts.maxHeight;
|
50 |
|
|
}
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
var newViewportHeight = naturalHeight + 3;
|
54 |
|
|
if (!self.scope.baseViewportHeight || self.scope.baseViewportHeight !== newViewportHeight) {
|
55 |
|
|
self.grid.$viewport.css('height', newViewportHeight + 'px');
|
56 |
|
|
self.grid.$root.css('height', (newViewportHeight + extraHeight) + 'px');
|
57 |
|
|
self.scope.baseViewportHeight = newViewportHeight;
|
58 |
|
|
self.domUtilityService.RebuildGrid(self.scope, self.grid);
|
59 |
|
|
}
|
60 |
|
|
};
|
61 |
|
|
self.scope.catHashKeys = function () {
|
62 |
|
|
var hash = '',
|
63 |
|
|
idx;
|
64 |
|
|
for (idx in self.scope.renderedRows) {
|
65 |
|
|
hash += self.scope.renderedRows[idx].$$hashKey;
|
66 |
|
|
}
|
67 |
|
|
return hash;
|
68 |
|
|
};
|
69 |
|
|
self.scope.$watch('catHashKeys()', innerRecalcForData);
|
70 |
|
|
self.scope.$watch(self.grid.config.data, recalcHeightForData);
|
71 |
|
|
};
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
mdstoreInspectorControllers.directive('compileTemplate', function ($compile, $parse) {
|
75 |
34144
|
sandro.lab
|
return {
|
76 |
39627
|
sandro.lab
|
link: function (scope, element, attr) {
|
77 |
|
|
var parsed = $parse(attr.ngBindHtml);
|
78 |
34144
|
sandro.lab
|
|
79 |
39627
|
sandro.lab
|
function getStringValue() {
|
80 |
|
|
return (parsed(scope) || '').toString();
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
//Recompile if the template changes
|
84 |
|
|
scope.$watch(getStringValue, function () {
|
85 |
|
|
$compile(element, null, -9999)(scope); //The -9999 makes it skip directives so that we do not recompile ourselves
|
86 |
|
|
});
|
87 |
|
|
}
|
88 |
34144
|
sandro.lab
|
}
|
89 |
|
|
});
|
90 |
|
|
|
91 |
|
|
function hasOwnProperty(obj, prop) {
|
92 |
|
|
var proto = obj.__proto__ || obj.constructor.prototype;
|
93 |
|
|
return (prop in obj) &&
|
94 |
|
|
(!(prop in proto) || proto[prop] !== obj[prop]);
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
mdstoreInspectorControllers.controller('inspectMdstoresController', [
|
99 |
39627
|
sandro.lab
|
'$scope', '$http', '$sce', '$location', '$routeParams',
|
100 |
|
|
function ($scope, $http, $sce, $location, $routeParams) {
|
101 |
|
|
common_init($scope, $http, $sce, $location);
|
102 |
34144
|
sandro.lab
|
|
103 |
39627
|
sandro.lab
|
$scope.mdId = $routeParams.id;
|
104 |
|
|
$scope.from_page = 0;
|
105 |
|
|
$scope.to_page = 0;
|
106 |
44785
|
sandro.lab
|
$scope.queryValues = {}
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
39627
|
sandro.lab
|
$scope.loadInfo = function () {
|
111 |
|
|
$scope.showSpinner();
|
112 |
44785
|
sandro.lab
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
113 |
39627
|
sandro.lab
|
$http.post('mdstore/getMdStoreInfo.do', $.param({
|
114 |
|
|
'id': $routeParams.id
|
115 |
|
|
})).success(function (data) {
|
116 |
|
|
$scope.hideSpinner();
|
117 |
|
|
$scope.mdStoreInfo = data;
|
118 |
|
|
if (hasOwnProperty($scope, 'searchResult') == false) {
|
119 |
|
|
$scope.searchResult = {}
|
120 |
|
|
}
|
121 |
44785
|
sandro.lab
|
$scope.queryValues = {"body": "", "id": ""};
|
122 |
54508
|
sandro.lab
|
|
123 |
39627
|
sandro.lab
|
$scope.searchResult.total = data.size;
|
124 |
|
|
}).error(function () {
|
125 |
|
|
$scope.showError('Error getting info from mdstore');
|
126 |
|
|
$scope.hideSpinner();
|
127 |
|
|
});
|
128 |
|
|
$scope.hideSpinner();
|
129 |
|
|
}
|
130 |
|
|
|
131 |
39742
|
sandro.lab
|
$scope.findIndexFields = function (indexField) {
|
132 |
|
|
$scope.showSpinner();
|
133 |
|
|
if ($scope.query == null) {
|
134 |
|
|
if ($scope.searchResult != null)
|
135 |
|
|
$scope.searchResult.total = $scope.mdStoreInfo.size
|
136 |
|
|
}
|
137 |
44785
|
sandro.lab
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
138 |
39742
|
sandro.lab
|
$http.post('mdstore/findByIndexField', $.param({
|
139 |
|
|
'mdId': $routeParams.id, 'from': $scope.from_page, 'query': $scope.query,
|
140 |
|
|
'indexField': indexField
|
141 |
|
|
})).success(function (data) {
|
142 |
|
|
$scope.hideSpinner();
|
143 |
|
|
$scope.searchResult.records = data;
|
144 |
|
|
$scope.to_page = Math.min($scope.from_page + 10, $scope.searchResult.total);
|
145 |
|
|
}).error(function () {
|
146 |
|
|
$scope.showError('Error getting info from mdstore');
|
147 |
|
|
$scope.hideSpinner();
|
148 |
|
|
});
|
149 |
|
|
|
150 |
|
|
}
|
151 |
|
|
|
152 |
39627
|
sandro.lab
|
$scope.getResults = function () {
|
153 |
|
|
$scope.showSpinner();
|
154 |
44785
|
sandro.lab
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
155 |
39627
|
sandro.lab
|
if ($scope.query == null) {
|
156 |
|
|
if ($scope.searchResult != null)
|
157 |
|
|
$scope.searchResult.total = $scope.mdStoreInfo.size
|
158 |
|
|
}
|
159 |
|
|
$http.post('mdstore/mdStoreResults', $.param({
|
160 |
|
|
'mdId': $routeParams.id, 'from': $scope.from_page
|
161 |
|
|
})).success(function (data) {
|
162 |
|
|
$scope.hideSpinner();
|
163 |
44785
|
sandro.lab
|
$scope.searchResult.records = data.result;
|
164 |
|
|
$scope.searchResult.total = data.count;
|
165 |
39627
|
sandro.lab
|
$scope.to_page = Math.min($scope.from_page + 10, $scope.searchResult.total);
|
166 |
|
|
}).error(function () {
|
167 |
|
|
$scope.showError('Error getting info from mdstore');
|
168 |
|
|
$scope.hideSpinner();
|
169 |
|
|
});
|
170 |
|
|
};
|
171 |
|
|
|
172 |
|
|
|
173 |
44785
|
sandro.lab
|
$scope.startSearch = function () {
|
174 |
|
|
$scope.from_page = 0;
|
175 |
|
|
return $scope.searchByQuery()
|
176 |
|
|
}
|
177 |
|
|
|
178 |
|
|
$scope.searchByQuery = function () {
|
179 |
|
|
$scope.showSpinner();
|
180 |
|
|
if ($scope.query == null) {
|
181 |
|
|
if ($scope.searchResult != null)
|
182 |
|
|
$scope.searchResult.total = $scope.mdStoreInfo.size
|
183 |
|
|
}
|
184 |
|
|
var query = {};
|
185 |
|
|
var setValue;
|
186 |
|
|
for (var key in $scope.queryValues) {
|
187 |
|
|
if ($scope.queryValues[key].length > 0) {
|
188 |
|
|
query[key] = $scope.queryValues[key];
|
189 |
|
|
setValue = true;
|
190 |
|
|
}
|
191 |
|
|
}
|
192 |
|
|
if (setValue == false)
|
193 |
|
|
return $scope.getResults();
|
194 |
|
|
query["mdId"] = $routeParams.id;
|
195 |
|
|
query["page"] = $scope.from_page;
|
196 |
|
|
$http.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8";
|
197 |
|
|
$http.post('mdstore/findRecords', query)
|
198 |
|
|
.success(function (data) {
|
199 |
|
|
$scope.hideSpinner();
|
200 |
|
|
$scope.searchResult.records = data.result;
|
201 |
|
|
$scope.searchResult.total = data.count;
|
202 |
|
|
$scope.to_page = Math.min($scope.from_page + 10, $scope.searchResult.total);
|
203 |
|
|
}).error(function () {
|
204 |
|
|
$scope.showError('Error getting info from mdstore');
|
205 |
|
|
$scope.hideSpinner();
|
206 |
|
|
});
|
207 |
|
|
};
|
208 |
|
|
|
209 |
39627
|
sandro.lab
|
$scope.getRecordById = function () {
|
210 |
|
|
|
211 |
|
|
if (($scope.record_id != null) && ($scope.record_id.length > 0)) {
|
212 |
|
|
$scope.showSpinner();
|
213 |
|
|
}
|
214 |
44785
|
sandro.lab
|
|
215 |
|
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
216 |
39627
|
sandro.lab
|
$http.post('mdstore/mdStoreResults', $.param({
|
217 |
|
|
'mdId': $routeParams.id, 'from': $scope.from_page, 'id_query': $scope.record_id
|
218 |
|
|
})).success(function (data) {
|
219 |
|
|
$scope.hideSpinner();
|
220 |
44785
|
sandro.lab
|
$scope.searchResult.records = data.records.result;
|
221 |
|
|
$scope.searchResult.total = data.records.total;
|
222 |
39627
|
sandro.lab
|
$scope.to_page = 0
|
223 |
|
|
if (data == null) {
|
224 |
|
|
$scope.to_page = 0
|
225 |
|
|
$scope.searchResult.total = 0
|
226 |
|
|
}
|
227 |
|
|
else {
|
228 |
|
|
$scope.to_page = data.length
|
229 |
|
|
$scope.searchResult.total = data.length
|
230 |
|
|
}
|
231 |
|
|
|
232 |
|
|
}).error(function () {
|
233 |
|
|
$scope.showError('Error getting info from mdstore');
|
234 |
|
|
$scope.hideSpinner();
|
235 |
|
|
});
|
236 |
|
|
};
|
237 |
|
|
|
238 |
|
|
$scope.nextPage = function () {
|
239 |
|
|
if ($scope.from_page < $scope.searchResult.total - 10) {
|
240 |
|
|
$scope.from_page = $scope.from_page + 10;
|
241 |
44785
|
sandro.lab
|
$scope.searchByQuery();
|
242 |
39627
|
sandro.lab
|
$scope.to_page = Math.min($scope.from_page + 10, $scope.searchResult.total);
|
243 |
|
|
}
|
244 |
|
|
|
245 |
|
|
};
|
246 |
|
|
|
247 |
|
|
$scope.prevPage = function () {
|
248 |
|
|
if ($scope.from_page + 10 > 10) {
|
249 |
|
|
$scope.from_page = $scope.from_page - 10;
|
250 |
44785
|
sandro.lab
|
$scope.searchByQuery();
|
251 |
39627
|
sandro.lab
|
$scope.to_page = Math.min($scope.from_page + 10, $scope.searchResult.total);
|
252 |
|
|
}
|
253 |
|
|
|
254 |
|
|
}
|
255 |
|
|
|
256 |
|
|
$scope.loadInfo();
|
257 |
44785
|
sandro.lab
|
|
258 |
39627
|
sandro.lab
|
$scope.getResults();
|
259 |
|
|
}]);
|
260 |
|
|
|
261 |
|
|
|
262 |
34144
|
sandro.lab
|
mdstoreInspectorControllers.controller('mdstoresController', [
|
263 |
39627
|
sandro.lab
|
'$scope', '$http', '$sce', '$location',
|
264 |
|
|
function ($scope, $http, $sce, $location) {
|
265 |
|
|
common_init($scope, $http, $sce, $location);
|
266 |
|
|
$scope.showSpinner();
|
267 |
|
|
$http.get('mdstore/listMDStores.do').success(function (data) {
|
268 |
|
|
$scope.hideSpinner();
|
269 |
|
|
$scope.mdTable = data;
|
270 |
|
|
}).error(function () {
|
271 |
|
|
$scope.showError('Error listing xmldb collections');
|
272 |
|
|
$scope.hideSpinner();
|
273 |
|
|
});
|
274 |
34144
|
sandro.lab
|
|
275 |
39627
|
sandro.lab
|
$scope.refreshInfo = function () {
|
276 |
|
|
|
277 |
|
|
$scope.showSpinner();
|
278 |
|
|
$http.get('mdstore/reloadInfo').success(function (data) {
|
279 |
|
|
$scope.hideSpinner();
|
280 |
|
|
$scope.mdTable = data;
|
281 |
|
|
}).error(function () {
|
282 |
|
|
$scope.showError('Error listing xmldb collections');
|
283 |
|
|
$scope.hideSpinner();
|
284 |
|
|
});
|
285 |
|
|
|
286 |
|
|
}
|
287 |
|
|
|
288 |
|
|
$scope.gridOptions = {
|
289 |
|
|
data: 'mdTable',
|
290 |
|
|
enableRowSelection: false,
|
291 |
|
|
enableCellEditOnFocus: false,
|
292 |
|
|
enableHighlighting: true,
|
293 |
|
|
plugins: [new ngGridFlexibleHeightPlugin()],
|
294 |
|
|
|
295 |
|
|
columnDefs: [
|
296 |
|
|
{field: 'format', displayName: 'Format', width: '55px'},
|
297 |
|
|
{field: 'layout', displayName: 'Layout', width: '55px'},
|
298 |
|
|
{field: 'interpretation', displayName: 'Interpretation', width: '100px'},
|
299 |
|
|
{field: 'lastStorageDate', displayName: 'Last Storage', width: '120px'},
|
300 |
|
|
{field: 'size', displayName: 'Size', width: '90px'},
|
301 |
|
|
{field: 'serviceURI', displayName: 'Service URI', width: '350px'},
|
302 |
|
|
{
|
303 |
|
|
field: 'id',
|
304 |
|
|
displayName: 'profile',
|
305 |
|
|
cellTemplate: '<div class="ngCellText" ng-class="col.colIndex()"><a href="isManager.do#/profile/{{row.getProperty(col.field)}}" class="btn btn-primary btn-xs" data-placement="top" ><span class="glyphicon glyphicon-zoom-in"></span> profile</button></div>',
|
306 |
|
|
width: '80px',
|
307 |
|
|
headerClass: 'text-center'
|
308 |
|
|
},
|
309 |
|
|
{
|
310 |
|
|
field: 'id',
|
311 |
|
|
displayName: 'View',
|
312 |
|
|
cellTemplate: '<div class="ngCellText" ng-class="col.colIndex()"><a href="mdstoreInspector.do#/inspect.do/{{row.getProperty(col.field)}}" class="btn btn-primary btn-xs" data-placement="top" title="{{row.getProperty(col.field)}}"><span class="glyphicon glyphicon-zoom-in"></span> inspect</button></div>',
|
313 |
|
|
width: '80px',
|
314 |
|
|
headerClass: 'text-center'
|
315 |
|
|
},
|
316 |
|
|
{
|
317 |
|
|
field: 'datasourcesInvolved',
|
318 |
|
|
displayName: 'Datasource',
|
319 |
|
|
cellTemplate: '<div class="ngCellText" ng-class="col.colIndex()"><b>{{row.getProperty(col.field).datasourceName}}</b> </div>',
|
320 |
|
|
headerClass: 'text-center'
|
321 |
|
|
}
|
322 |
|
|
|
323 |
|
|
]
|
324 |
|
|
};
|
325 |
|
|
|
326 |
|
|
}]);
|
327 |
|
|
|
328 |
|
|
window.onresize = function () {
|
329 |
|
|
|
330 |
|
|
var elem = document.getElementById('gridMdstores');
|
331 |
|
|
var height = 0;
|
332 |
|
|
var body = window.document.body;
|
333 |
|
|
if (window.innerHeight) {
|
334 |
|
|
height = window.innerHeight;
|
335 |
|
|
} else if (body.parentElement.clientHeight) {
|
336 |
|
|
height = body.parentElement.clientHeight;
|
337 |
|
|
} else if (body && body.clientHeight) {
|
338 |
|
|
height = body.clientHeight;
|
339 |
|
|
}
|
340 |
|
|
elem.style.height = ((height - elem.offsetTop - 280) + "px");
|
341 |
|
|
|
342 |
|
|
};
|
343 |
|
|
|