dnet-applications/apps/dnet-is-application/src/main/resources/static/js/contextEditor.js

51 lines
1.4 KiB
JavaScript

var app = angular.module('contextApp', []);
app.controller('contextController', function($scope, $http, $location) {
$scope.categories = [];
$scope.ctxId = ctxId();
$scope.parameters = [];
$scope.reload = function() {
$scope.url = './ajax/contexts/' + encodeURIComponent($scope.ctxId) + '/categories';
$http.get($scope.url + '?' + $.now()).then(function successCallback(res) {
$scope.categories = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.message);
});
};
$scope.loadContextParameters = function() {
$scope.parameters = [];
$http.get('./ajax/contexts/' + encodeURIComponent($scope.ctxId) + '?' + $.now()).then(function successCallback(res) {
$scope.parameters = res.data.parameters;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.message);
});
}
$scope.populateNode = function(level, node) {
$scope.url = './ajax/contexts/'
+ encodeURIComponent(level)
+ '/'
+ encodeURIComponent(node.id)
+ '/concepts';
node.populated = true;
$http.get($scope.url + '?' + $.now()).then(function successCallback(res) {
node.concepts = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.message);
});
}
$scope.initShowParameters = function(params) {
$scope.parameters = params;
}
$scope.reload();
});