Revision 57674
Added by Michele Artini over 4 years ago
organizations.js | ||
---|---|---|
1 | 1 |
var orgsModule = angular.module('orgs', ['ngRoute', 'checklist-model']); |
2 | 2 |
|
3 |
|
|
4 |
orgsModule.service('orgInfoService', function($http) { |
|
5 |
this.info = {}; |
|
6 |
this.count = 0; |
|
7 |
this.getInfo = function(id, f) { |
|
8 |
|
|
9 |
if (id) { |
|
10 |
if (this.info.id == id) { |
|
11 |
f(this.info); |
|
12 |
} else { |
|
13 |
$http.get('api/organizations/info?id=' + id).then(function successCallback(res) { |
|
14 |
this.info = res.data; |
|
15 |
f(angular.copy(this.info)); |
|
16 |
}, function errorCallback(res) { |
|
17 |
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')'); |
|
18 |
}); |
|
19 |
} |
|
20 |
} else { |
|
21 |
f({}); |
|
22 |
} |
|
23 |
}; |
|
24 |
}); |
|
25 |
|
|
26 |
orgsModule.directive('organizationInfo', function() { |
|
27 |
return { |
|
28 |
restrict: 'E', |
|
29 |
scope: { |
|
30 |
info : '=' |
|
31 |
}, |
|
32 |
templateUrl: 'resources/html/part/org_info.html' |
|
33 |
} |
|
34 |
}); |
|
35 |
|
|
36 |
|
|
37 |
orgsModule.directive('orgTabsMenu', function($http, orgInfoService) { |
|
38 |
return { |
|
39 |
restrict: 'E', |
|
40 |
scope: { |
|
41 |
'info' : '=', |
|
42 |
'selected': '@', |
|
43 |
'orgId' : '@' |
|
44 |
|
|
45 |
}, |
|
46 |
templateUrl: 'resources/html/part/org_tabs_menu.html' |
|
47 |
} |
|
48 |
}); |
|
49 |
|
|
50 |
|
|
3 | 51 |
orgsModule.config(function($routeProvider) { |
4 | 52 |
$routeProvider |
5 | 53 |
.when('/new', { templateUrl: 'resources/html/edit.html', controller: 'newOrgCtrl' }) |
... | ... | |
47 | 95 |
"urls": [] |
48 | 96 |
}; |
49 | 97 |
$scope.vocabularies = {}; |
50 |
|
|
98 |
|
|
51 | 99 |
$http.get('api/vocabularies').then(function successCallback(res) { |
52 | 100 |
$scope.vocabularies = res.data; |
53 | 101 |
}, function errorCallback(res) { |
... | ... | |
139 | 187 |
}); |
140 | 188 |
|
141 | 189 |
|
142 |
orgsModule.controller('showMetadataCtrl', function ($scope, $http, $routeParams, $route, $location, $timeout) { |
|
190 |
orgsModule.controller('showMetadataCtrl', function ($scope, $http, $routeParams, $route, $location, $timeout, orgInfoService) {
|
|
143 | 191 |
$scope.orgId = $routeParams.id; |
144 | 192 |
$scope.org = {}; |
145 | 193 |
$scope.vocabularies = {}; |
194 |
$scope.info = {}; |
|
146 | 195 |
|
196 |
orgInfoService.getInfo($scope.orgId, function(info) { $scope.info = info; }); |
|
197 |
|
|
147 | 198 |
if ($routeParams.msg == 1) { |
148 | 199 |
$scope.message = 'New organization registered !!!'; |
149 | 200 |
} else if ($routeParams.msg == 2) { |
150 | 201 |
$scope.message = 'Organization updated !!!'; |
151 | 202 |
} else { |
152 | 203 |
$scope.message = ''; |
153 |
}
|
|
204 |
} |
|
154 | 205 |
|
155 | 206 |
$timeout(function() { $scope.message = ''; }, 3000) |
156 | 207 |
|
... | ... | |
179 | 230 |
}); |
180 | 231 |
|
181 | 232 |
|
182 |
orgsModule.controller('showRelationsCtrl', function ($scope, $http, $routeParams) { |
|
233 |
orgsModule.controller('showRelationsCtrl', function ($scope, $http, $routeParams, orgInfoService) {
|
|
183 | 234 |
$scope.orgId = $routeParams.id; |
184 | 235 |
$scope.rels = []; |
185 | 236 |
$scope.vocabularies = {}; |
... | ... | |
188 | 239 |
$scope.searchOrgs = []; |
189 | 240 |
$scope.newRelType=''; |
190 | 241 |
$scope.newRelation = {}; |
242 |
$scope.info = {}; |
|
191 | 243 |
|
244 |
orgInfoService.getInfo($scope.orgId, function(info) { $scope.info = info; }); |
|
245 |
|
|
192 | 246 |
$http.get('api/vocabularies').then(function successCallback(res) { |
193 | 247 |
$scope.vocabularies = res.data; |
194 | 248 |
|
... | ... | |
241 | 295 |
|
242 | 296 |
}); |
243 | 297 |
|
244 |
orgsModule.controller('showEnrichmentsCtrl', function ($scope, $http, $routeParams) { |
|
298 |
orgsModule.controller('showEnrichmentsCtrl', function ($scope, $http, $routeParams, orgInfoService) {
|
|
245 | 299 |
$scope.orgId = $routeParams.id; |
246 | 300 |
$scope.enrichments = []; |
247 | 301 |
$scope.vocabularies = {}; |
302 |
$scope.info = {}; |
|
248 | 303 |
|
304 |
orgInfoService.getInfo($scope.orgId, function(info) { $scope.info = info; }); |
|
305 |
|
|
249 | 306 |
$http.get('api/vocabularies').then(function successCallback(res) { |
250 | 307 |
$scope.vocabularies = res.data; |
251 | 308 |
|
... | ... | |
270 | 327 |
} |
271 | 328 |
}); |
272 | 329 |
|
273 |
orgsModule.controller('showConflictsCtrl', function ($scope, $http, $routeParams) { |
|
330 |
orgsModule.controller('showConflictsCtrl', function ($scope, $http, $routeParams, orgInfoService) {
|
|
274 | 331 |
$scope.orgId = $routeParams.id; |
275 | 332 |
$scope.conflicts = []; |
276 | 333 |
$scope.vocabularies = {}; |
334 |
$scope.info = {}; |
|
277 | 335 |
|
336 |
orgInfoService.getInfo($scope.orgId, function(info) { $scope.info = info; }); |
|
337 |
|
|
278 | 338 |
$http.get('api/vocabularies').then(function successCallback(res) { |
279 | 339 |
$scope.vocabularies = res.data; |
280 | 340 |
|
Also available in: Unified diff
org info in all tabs