1
|
var isManagerControllers = angular.module('isManagerControllers', ['LocalStorageModule', 'ui.codemirror']);
|
2
|
|
3
|
function common_init($scope, $http, $sce, $location) {
|
4
|
initSpinner();
|
5
|
$scope.showError = function(error) { show_notification("error", error); }
|
6
|
$scope.showNotification = function(message) { show_notification("info", message); }
|
7
|
$scope.showSpinner = function() { showSpinner(); }
|
8
|
$scope.hideSpinner = function() { hideSpinner(); }
|
9
|
$scope.to_trusted = function(html) { return $sce.trustAsHtml(html); }
|
10
|
$scope.go = function(path) { $location.path(path); }
|
11
|
$scope.encodeValue = function(val) { return val; }
|
12
|
}
|
13
|
|
14
|
isManagerControllers.controller('typesCtrl', [
|
15
|
'$scope', '$http', '$sce', '$location', '$routeParams',
|
16
|
function ($scope, $http, $sce, $location, $routeParams) {
|
17
|
common_init($scope, $http, $sce, $location);
|
18
|
$scope.types = [];
|
19
|
$scope.showSpinner();
|
20
|
$http.get('ajax_is/listResourceTypes.do').success(function(data) {
|
21
|
$scope.hideSpinner();
|
22
|
$scope.types = data;
|
23
|
}).error(function() {
|
24
|
$scope.showError('Error listing resource types');
|
25
|
$scope.hideSpinner();
|
26
|
});
|
27
|
}
|
28
|
]);
|
29
|
|
30
|
|
31
|
isManagerControllers.controller('dsListCtrl', [
|
32
|
'$scope', '$http', '$sce', '$location', '$routeParams',
|
33
|
function ($scope, $http, $sce, $location, $routeParams) {
|
34
|
common_init($scope, $http, $sce, $location);
|
35
|
$scope.list = [];
|
36
|
$scope.type = $routeParams.type;
|
37
|
$scope.format = $routeParams.format;
|
38
|
$scope.showSpinner();
|
39
|
$http.get('ajax_is/listDatastructures.do?type=' + $scope.type).success(function(data) {
|
40
|
$scope.hideSpinner();
|
41
|
$scope.list = data;
|
42
|
}).error(function() {
|
43
|
$scope.showError('Error listing datastructures');
|
44
|
$scope.hideSpinner();
|
45
|
});
|
46
|
}
|
47
|
]);
|
48
|
|
49
|
|
50
|
isManagerControllers.controller('dsCtrl', [
|
51
|
'$scope', '$http', '$sce', '$location', '$routeParams', '$timeout',
|
52
|
function ($scope, $http, $sce, $location, $routeParams, $timeout) {
|
53
|
common_init($scope, $http, $sce, $location);
|
54
|
|
55
|
$scope.resource = {};
|
56
|
$scope.format = $routeParams.format;
|
57
|
$scope.parsedContent = '';
|
58
|
|
59
|
$scope.editorOptions = {
|
60
|
lineWrapping : true,
|
61
|
lineNumbers: true,
|
62
|
mode: "application/json"
|
63
|
};
|
64
|
|
65
|
$scope.showSpinner();
|
66
|
$scope.getResource = function(id) {
|
67
|
if (id) {
|
68
|
$scope.showSpinner();
|
69
|
$http.get('ajax_is/getDs.do?id=' + id).success(function(data) {
|
70
|
$scope.hideSpinner();
|
71
|
$scope.resource = data;
|
72
|
$scope.parsedContent = '';
|
73
|
}).error(function() {
|
74
|
$scope.showError('Error retrieving ds');
|
75
|
$scope.hideSpinner();
|
76
|
});
|
77
|
}
|
78
|
}
|
79
|
|
80
|
$scope.setupEditContent = function () {
|
81
|
$timeout(function() {
|
82
|
try {
|
83
|
if ($scope.format == 'JSON') {
|
84
|
$scope.editorOptions.mode = "application/json";
|
85
|
$scope.parsedContent = JSON.stringify(JSON.parse($scope.resource.content),null,2);
|
86
|
} else if ($scope.format == 'XML') {
|
87
|
$scope.editorOptions.mode = 'application/xml';
|
88
|
$scope.parsedContent = $scope.resource.content;
|
89
|
} else {
|
90
|
$scope.editorOptions.mode = null;
|
91
|
$scope.parsedContent = $scope.resource.content;
|
92
|
}
|
93
|
} catch(err) {
|
94
|
$scope.showError('Error parsing content (' + $scope.format + ')');
|
95
|
$scope.parsedContent = $scope.resource.content;
|
96
|
}
|
97
|
}, 1000);
|
98
|
}
|
99
|
|
100
|
$scope.deleteResource = function() {
|
101
|
if ($scope.resource && $scope.resource.id && confirm("Are you sure ?")) {
|
102
|
$scope.showSpinner();
|
103
|
$http.get('ajax_is/deleteDs.do?id=' + $scope.resource.id).success(function(data) {
|
104
|
$scope.resource = {};
|
105
|
$scope.parsedContent = '';
|
106
|
$scope.hideSpinner();
|
107
|
$scope.showNotification('Resource deleted !');
|
108
|
}).error(function() {
|
109
|
$scope.showError('Error deleting resource');
|
110
|
$scope.hideSpinner();
|
111
|
});
|
112
|
}
|
113
|
}
|
114
|
|
115
|
$scope.saveContent = function() {
|
116
|
try {
|
117
|
if ($scope.format == 'JSON') {
|
118
|
$scope.saveDs({
|
119
|
'id' : $scope.resource.id,
|
120
|
'content' : JSON.stringify(JSON.parse($scope.parsedContent))
|
121
|
});
|
122
|
} else {
|
123
|
$scope.saveDs({
|
124
|
'id' : $scope.resource.id,
|
125
|
'content' : $scope.parsedContent
|
126
|
});
|
127
|
}
|
128
|
} catch(err) {
|
129
|
$scope.showError('ERROR: Invalid content (' + $scope.format + ')');
|
130
|
}
|
131
|
}
|
132
|
|
133
|
$scope.saveInfo = function() {
|
134
|
$scope.saveDs({
|
135
|
'id' : $scope.resource.id,
|
136
|
'name' : $scope.resource.name,
|
137
|
'description' : $scope.resource.description
|
138
|
});
|
139
|
}
|
140
|
|
141
|
$scope.saveDs = function(map) {
|
142
|
$scope.showSpinner();
|
143
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
144
|
$http.post('ajax_is/updateDs.do', $.param(map)).success(function(data) {
|
145
|
$scope.hideSpinner();
|
146
|
$scope.showNotification('Resource updated !');
|
147
|
if (map.content) {
|
148
|
$('#contentModal').modal('hide');
|
149
|
}
|
150
|
$scope.getResource($scope.resource.id);
|
151
|
}).error(function(err) {
|
152
|
$scope.showError(err.message);
|
153
|
$scope.hideSpinner();
|
154
|
});
|
155
|
}
|
156
|
|
157
|
$scope.getResource($routeParams.id);
|
158
|
}
|
159
|
]);
|
160
|
|
161
|
isManagerControllers.controller('servicesCtrl', [
|
162
|
'$scope', '$http', '$sce', '$location', '$routeParams',
|
163
|
function ($scope, $http, $sce, $location, $routeParams) {
|
164
|
common_init($scope, $http, $sce, $location);
|
165
|
$scope.groups = [];
|
166
|
|
167
|
$scope.showSpinner();
|
168
|
$http.get('ajax_is/listServices.do').success(function(data) {
|
169
|
$scope.hideSpinner();
|
170
|
$scope.groups = data;
|
171
|
}).error(function() {
|
172
|
$scope.showError('Error obtaining services');
|
173
|
$scope.hideSpinner();
|
174
|
});
|
175
|
|
176
|
$scope.pingServices = function() {
|
177
|
var list = [];
|
178
|
angular.forEach($scope.groups, function(group) {
|
179
|
angular.forEach(group.services, function(service) {
|
180
|
if (service.id && service.protocols && service.protocols.SOAP) {
|
181
|
service.status = 'UNKNOWN';
|
182
|
list.push(service);
|
183
|
}
|
184
|
});
|
185
|
});
|
186
|
$scope.ping(list, 0);
|
187
|
}
|
188
|
|
189
|
$scope.ping = function(list, pos) {
|
190
|
if (list.length == 0) { return; }
|
191
|
if (pos >= list.length) { $scope.hideSpinner(); return; }
|
192
|
if (pos == 0) { $scope.showSpinner(); }
|
193
|
|
194
|
$http.get('ajax_is/ping.do?timeout=1500&url='+encodeURIComponent(list[pos].protocols.SOAP + '?wsdl')).success(function(data) {
|
195
|
list[pos].status = 'ACTIVE';
|
196
|
$scope.ping(list, pos + 1);
|
197
|
}).error(function() {
|
198
|
list[pos].status = 'NOT_RESPONDING';
|
199
|
$scope.ping(list, pos + 1);
|
200
|
});
|
201
|
}
|
202
|
}
|
203
|
]);
|
204
|
|
205
|
isManagerControllers.controller('serviceCtrl', [
|
206
|
'$scope', '$http', '$sce', '$location', '$routeParams',
|
207
|
function ($scope, $http, $sce, $location, $routeParams) {
|
208
|
common_init($scope, $http, $sce, $location);
|
209
|
|
210
|
$scope.service = {};
|
211
|
|
212
|
$scope.showSpinner();
|
213
|
$http.get('ajax_is/getService.do?id=' + $routeParams.id).success(function(data) {
|
214
|
$scope.hideSpinner();
|
215
|
$scope.service = data;
|
216
|
}).error(function() {
|
217
|
$scope.showError('Error obtaining service');
|
218
|
$scope.hideSpinner();
|
219
|
});
|
220
|
|
221
|
}
|
222
|
]);
|
223
|
|
224
|
isManagerControllers.controller('isQueryCtrl', [
|
225
|
'$scope', '$http', '$sce', '$location', '$routeParams', 'localStorageService',
|
226
|
function ($scope, $http, $sce, $location, $routeParams, localStorageService) {
|
227
|
common_init($scope, $http, $sce, $location);
|
228
|
|
229
|
$scope.history = localStorageService.get('sql_query_history');
|
230
|
if (!$scope.history) {
|
231
|
$scope.history = [];
|
232
|
}
|
233
|
|
234
|
$scope.sqlEditorOptions = {
|
235
|
lineWrapping : true,
|
236
|
lineNumbers: true,
|
237
|
mode: 'text/x-sql',
|
238
|
matchBrackets : true,
|
239
|
extraKeys: {"Ctrl-Space": "autocomplete"}
|
240
|
};
|
241
|
|
242
|
$scope.sqlResultOptions = {
|
243
|
lineWrapping : true,
|
244
|
lineNumbers: true,
|
245
|
readOnly: 'nocursor',
|
246
|
mode: "application/json"
|
247
|
};
|
248
|
|
249
|
$scope.query = "select * from resource_types";
|
250
|
$scope.error = null;
|
251
|
$scope.results = [];
|
252
|
|
253
|
$scope.search = function() {
|
254
|
$scope.results = [];
|
255
|
$scope.error = null;
|
256
|
$scope.showSpinner();
|
257
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
258
|
$http.post('ajax_is/query.do', $.param({
|
259
|
'query' : $scope.query
|
260
|
})).success(function(data) {
|
261
|
$scope.hideSpinner();
|
262
|
$scope.results = [];
|
263
|
angular.forEach(data, function(d) {
|
264
|
$scope.results.push(JSON.stringify(JSON.parse(d),null,2));
|
265
|
});
|
266
|
$scope.history.push({ 'date' : new Date(), 'query' : $scope.query });
|
267
|
if ($scope.history.length > 100) {
|
268
|
$scope.history = $scope.history.splice($scope.history.length - 100);
|
269
|
}
|
270
|
localStorageService.set('sql_query_history', $scope.history);
|
271
|
}).error(function(err) {
|
272
|
$scope.error = err;
|
273
|
$scope.hideSpinner();
|
274
|
});
|
275
|
}
|
276
|
|
277
|
$scope.updateSqlQuery = function(q) {
|
278
|
$scope.query = q;
|
279
|
$scope.search();
|
280
|
}
|
281
|
|
282
|
$scope.clearHistory = function() {
|
283
|
$scope.history = [];
|
284
|
localStorageService.set('sql_query_history', []);
|
285
|
}
|
286
|
}
|
287
|
]);
|
288
|
|
289
|
isManagerControllers.controller('bulkImporterCtrl', [
|
290
|
'$scope', '$http', '$sce', '$location', '$routeParams',
|
291
|
function ($scope, $http, $sce, $location, $routeParams) {
|
292
|
common_init($scope, $http, $sce, $location);
|
293
|
|
294
|
$scope.path = 'file:///tmp/dnet_import';
|
295
|
$scope.schemas = true;
|
296
|
$scope.profiles = true;
|
297
|
|
298
|
$scope.response = {};
|
299
|
|
300
|
$scope.bulkImport = function() {
|
301
|
$scope.response = {};
|
302
|
$scope.showSpinner();
|
303
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
304
|
$http.post('ajax_is/import.do', $.param({
|
305
|
'path' : $scope.path,
|
306
|
'schemas' : $scope.schemas,
|
307
|
'profiles' : $scope.profiles
|
308
|
})).success(function(data) {
|
309
|
$scope.hideSpinner();
|
310
|
$scope.response = data;
|
311
|
}).error(function() {
|
312
|
$scope.showError('Error registerting profile');
|
313
|
$scope.hideSpinner();
|
314
|
});
|
315
|
}
|
316
|
}
|
317
|
]);
|
318
|
|
319
|
isManagerControllers.controller('blackboardCtrl', [
|
320
|
'$scope', '$http', '$sce', '$location', '$routeParams',
|
321
|
function ($scope, $http, $sce, $location, $routeParams) {
|
322
|
common_init($scope, $http, $sce, $location);
|
323
|
|
324
|
$scope.refresh = function() {
|
325
|
$scope.blackboards = [];
|
326
|
$scope.showSpinner();
|
327
|
$http.get('ajax_is/listBlackboards.do').success(function(data) {
|
328
|
$scope.hideSpinner();
|
329
|
$scope.blackboards = data;
|
330
|
}).error(function() {
|
331
|
$scope.showError('Error retreiving schemas');
|
332
|
$scope.hideSpinner();
|
333
|
});
|
334
|
}
|
335
|
$scope.refresh();
|
336
|
}
|
337
|
]);
|
338
|
|
339
|
isManagerControllers.controller('backupCtrl', [
|
340
|
'$scope', '$http', '$sce', '$location', '$routeParams',
|
341
|
function ($scope, $http, $sce, $location, $routeParams) {
|
342
|
common_init($scope, $http, $sce, $location);
|
343
|
|
344
|
$scope.metaWfId = '';
|
345
|
$scope.section = '';
|
346
|
$scope.family = '';
|
347
|
|
348
|
$scope.getBackupMetaWfId = function() {
|
349
|
$scope.metaWfId = '';
|
350
|
$scope.section = '';
|
351
|
$scope.family = '';
|
352
|
|
353
|
$scope.showSpinner();
|
354
|
$http.get('ajax_is/getMetaWfIdForFamily.do?family=IS_BACKUP').success(function(data) {
|
355
|
$scope.hideSpinner();
|
356
|
$scope.metaWfId = data.id;
|
357
|
$scope.section = data.section;
|
358
|
$scope.family = data.family;
|
359
|
}).error(function() {
|
360
|
$scope.showError('Metaworkflow not registered');
|
361
|
$scope.hideSpinner();
|
362
|
});
|
363
|
}
|
364
|
|
365
|
$scope.registerBackupWfs = function() {
|
366
|
$scope.metaWfId = '';
|
367
|
$scope.showSpinner();
|
368
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
369
|
$http.post('ajax_is/import.do', $.param({
|
370
|
'path' : 'classpath*:/eu/dnetlib/functionality/modular/workflows/backup',
|
371
|
'schemas' : false,
|
372
|
'profiles' : true
|
373
|
})).success(function(data) {
|
374
|
$scope.hideSpinner();
|
375
|
$scope.showNotification('Profiles are been registered');
|
376
|
$scope.getBackupMetaWfId();
|
377
|
}).error(function() {
|
378
|
$scope.showError('Error registering profiles');
|
379
|
$scope.hideSpinner();
|
380
|
});
|
381
|
}
|
382
|
|
383
|
$scope.getBackupMetaWfId();
|
384
|
}
|
385
|
]);
|