Project

General

Profile

1
var isManagerControllers = angular.module('isManagerControllers', []);
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('listCollectionsCtrl', [
15
	'$scope', '$http', '$sce', '$location', '$routeParams',
16
	function ($scope, $http, $sce, $location, $routeParams) {
17
		common_init($scope, $http, $sce, $location);
18

    
19
		$scope.results = [];
20
		
21
		$scope.showSpinner();
22

    
23
		$http.get('is/listCollections.do').success(function(data) {
24
			$scope.hideSpinner();
25
			$scope.results = data;
26
		}).error(function() {
27
			$scope.showError('Error listing xmldb collections');
28
			$scope.hideSpinner();
29
	    });
30
	}
31
]);
32

    
33

    
34
isManagerControllers.controller('profilesCtrl', [
35
	'$scope', '$http', '$sce', '$location', '$routeParams',
36
	function ($scope, $http, $sce, $location, $routeParams) {
37
		common_init($scope, $http, $sce, $location);
38

    
39
		$scope.profiles = [];
40
		$scope.path = '/db/DRIVER/' + $routeParams.kind + '/' + $routeParams.type;
41
		
42
		$scope.showSpinner();
43
		
44
		$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
45
		$http.post('is/listProfiles.do', $.param({
46
			'kind' :  $routeParams.kind,
47
			'type' :  $routeParams.type
48
		})).success(function(data) {
49
			$scope.hideSpinner();
50
			$scope.profiles = data;
51
		}).error(function() {
52
			$scope.showError('Error listing xmldb collections');
53
			$scope.hideSpinner();
54
	    });
55
	}
56
]);
57

    
58

    
59
isManagerControllers.controller('profileCtrl', [
60
	'$scope', '$http', '$sce', '$location', '$routeParams',
61
	function ($scope, $http, $sce, $location, $routeParams) {
62
		common_init($scope, $http, $sce, $location);
63

    
64
		$scope.id = $routeParams.id;
65
		$scope.profile = '';
66

    
67
		$scope.showSpinner();
68
		
69
		$http.get('is/getProfile.do?id=' + $scope.id).success(function(data) {
70
			$scope.hideSpinner();
71
			$scope.profile = data;
72
		}).error(function() {
73
			$scope.showError('Error retreiving profile' + $scope.id);
74
			$scope.hideSpinner();
75
		});
76
	}
77
]);
78

    
79

    
80
isManagerControllers.controller('schemasCtrl', [
81
	'$scope', '$http', '$sce', '$location', '$routeParams',
82
	function ($scope, $http, $sce, $location, $routeParams) {
83
		common_init($scope, $http, $sce, $location);
84

    
85
		$scope.schemas = [];
86
		
87
		$scope.showSpinner();
88

    
89
		$http.get('is/listSchemas.do').success(function(data) {
90
			$scope.hideSpinner();
91
			$scope.schemas = data;
92
		}).error(function() {
93
			$scope.showError('Error retreiving schemas');
94
			$scope.hideSpinner();
95
	    });
96
	}
97
]);
98

    
99

    
100
isManagerControllers.controller('schemaCtrl', [
101
	'$scope', '$http', '$sce', '$location', '$routeParams',
102
	function ($scope, $http, $sce, $location, $routeParams) {
103
		common_init($scope, $http, $sce, $location);
104

    
105
		$scope.name = $routeParams.name;
106
		$scope.schema = '';
107

    
108
		$scope.showSpinner();
109
		
110
		$http.get('is/getSchema.do?name=' + $scope.name).success(function(data) {
111
			$scope.hideSpinner();
112
			$scope.schema = data;
113
		}).error(function() {
114
			$scope.showError('Error retreiving schema' + $scope.name);
115
			$scope.hideSpinner();
116
		});
117
	}
118
]);
119

    
120
isManagerControllers.controller('isQueryCtrl', [
121
	'$scope', '$http', '$sce', '$location', '$routeParams',  
122
	function ($scope, $http, $sce, $location, $routeParams) {
123
		common_init($scope, $http, $sce, $location);
124

    
125
		$scope.query = "for $x in collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType') return $x";
126
		$scope.results = [];
127

    
128
        $scope.searchXQuery = function() {
129
			$scope.results = [];
130

    
131
			$scope.showSpinner();
132
			$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
133
			$http.post('is/xquery.do', $.param({
134
				'query' : $scope.query
135
			})).success(function(data) {
136
				$scope.hideSpinner();
137
				$scope.results = data;
138
			}).error(function() {
139
				$scope.showError('Something really bad must have happened to our fellow hamster..');
140
				$scope.hideSpinner();
141
			});
142
		}
143
	}
144
]);
145
isManagerControllers.controller('registerProfileCtrl', [
146
	'$scope', '$http', '$sce', '$location', '$routeParams',
147
	function ($scope, $http, $sce, $location, $routeParams) {
148
		common_init($scope, $http, $sce, $location);
149

    
150
		$scope.profile = '';
151

    
152
		$scope.register = function() {
153
			$scope.showSpinner();
154
			$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
155
			$http.post('is/registerProfile.do', $.param({
156
				'profile' : $scope.profile
157
			})).success(function(id) {
158
				$scope.hideSpinner();
159
				$scope.go('/profile/' + id)
160
			}).error(function() {
161
				$scope.showError('Error registerting profile');
162
				$scope.hideSpinner();
163
		    });
164
		}
165
	}
166
]);
167

    
168

    
169
isManagerControllers.controller('bulkImporterCtrl', [
170
	'$scope', '$http', '$sce', '$location', '$routeParams',
171
	function ($scope, $http, $sce, $location, $routeParams) {
172
		common_init($scope, $http, $sce, $location);
173

    
174
		$scope.path = 'file:///tmp/dnet_import';
175
		$scope.schemas = true;
176
		$scope.profiles = true;
177
		
178
		$scope.response = {};
179
		
180
		$scope.bulkImport = function() {
181
			$scope.response = {};
182
			$scope.showSpinner();
183
			$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
184
			$http.post('is/import.do', $.param({
185
				'path'     : $scope.path,
186
				'schemas'  : $scope.schemas,
187
				'profiles' : $scope.profiles
188
			})).success(function(data) {
189
				$scope.hideSpinner();
190
				$scope.response = data;
191
			}).error(function() {
192
				$scope.showError('Error registerting profile');
193
				$scope.hideSpinner();
194
		    });
195
		}
196
	}
197
]);
198

    
199

    
200
isManagerControllers.controller('validateProvilesCtrl', [
201
	'$scope', '$http', '$sce', '$location', '$routeParams',
202
	function ($scope, $http, $sce, $location, $routeParams) {
203
		common_init($scope, $http, $sce, $location);
204

    
205
		$scope.results = [];
206

    
207
		$scope.XXXXXXX = function() {
208
			$scope.results = [];
209

    
210
			$scope.showSpinner();
211
			$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
212
			$http.post('is/XXXXXX.do', $.param({
213
				'query' : $scope.query
214
			})).success(function(data) {
215
				$scope.hideSpinner();
216
				$scope.results = data;
217
			}).error(function() {
218
				$scope.showError('Something really bad must have happened to our fellow hamster..');
219
				$scope.hideSpinner();
220
		    });
221
		}
222
	}
223
]);
224

    
225
isManagerControllers.controller('subscriptionsCtrl', [
226
	'$scope', '$http', '$sce', '$location', '$routeParams',
227
	function ($scope, $http, $sce, $location, $routeParams) {
228
		common_init($scope, $http, $sce, $location);
229

    
230
		$scope.results = [];
231

    
232
		$scope.XXXXXXX = function() {
233
			$scope.results = [];
234

    
235
			$scope.showSpinner();
236
			$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
237
			$http.post('is/XXXXXX.do', $.param({
238
				'query' : $scope.query
239
			})).success(function(data) {
240
				$scope.hideSpinner();
241
				$scope.results = data;
242
			}).error(function() {
243
				$scope.showError('Something really bad must have happened to our fellow hamster..');
244
				$scope.hideSpinner();
245
		    });
246
		}
247
	}
248
]);
249

    
250

    
251
isManagerControllers.controller('blackboardCtrl', [
252
	'$scope', '$http', '$sce', '$location', '$routeParams',
253
	function ($scope, $http, $sce, $location, $routeParams) {
254
		common_init($scope, $http, $sce, $location);
255
		
256
		$scope.refresh = function() {
257
			$scope.blackboards = [];
258
			$scope.showSpinner();
259
			$http.get('is/listBlackboards.do').success(function(data) {
260
				$scope.hideSpinner();
261
				$scope.blackboards = data;
262
			}).error(function() {
263
				$scope.showError('Error retreiving schemas');
264
				$scope.hideSpinner();
265
		    });
266
		}
267
		$scope.refresh();
268
	}
269
]);
270
isManagerControllers.controller('backupCtrl', [
271
	'$scope', '$http', '$sce', '$location', '$routeParams',
272
	function ($scope, $http, $sce, $location, $routeParams) {
273
		common_init($scope, $http, $sce, $location);
274
		
275
		$scope.metaWfId = '';
276
		$scope.section = '';
277
		$scope.family = '';
278
		
279
		$scope.getBackupMetaWfId = function() {
280
			$scope.metaWfId = '';
281
			$scope.section = '';
282
			$scope.family = '';
283
			
284
			$scope.showSpinner();
285
			$http.get('is/getBackupMetaWfId.do').success(function(data) {
286
				$scope.hideSpinner();
287
				$scope.metaWfId = data.id;
288
				$scope.section = data.section;
289
				$scope.family = data.family;
290
			}).error(function() {
291
				$scope.showError('Metaworkflow not registered');
292
                $scope.hideSpinner();
293
			});
294
		}
295
		
296
		$scope.registerBackupWfs = function() {
297
			$scope.metaWfId = '';
298
			$scope.showSpinner();
299
			$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
300
			$http.post('is/import.do', $.param({
301
				'path'     : 'classpath*:/eu/dnetlib/functionality/modular/workflows/backup',
302
				'schemas'  : false,
303
				'profiles' : true
304
			})).success(function(data) {
305
				$scope.hideSpinner();
306
				$scope.getBackupMetaWfId();
307
			}).error(function() {
308
				$scope.showError('Error registerting profile');
309
				$scope.hideSpinner();
310
		    });
311
		}
312
		
313
		$scope.getBackupMetaWfId();
314
	}
315
]);
(2-2/2)