diff --git a/apps/dnet-is-application/src/main/java/eu/dnetlib/is/MainController.java b/apps/dnet-is-application/src/main/java/eu/dnetlib/is/MainController.java
index 2f2842c0..a723f456 100644
--- a/apps/dnet-is-application/src/main/java/eu/dnetlib/is/MainController.java
+++ b/apps/dnet-is-application/src/main/java/eu/dnetlib/is/MainController.java
@@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import eu.dnetlib.data.is.context.repository.ContextRepository;
import eu.dnetlib.data.is.resource.model.ResourceType;
import eu.dnetlib.data.is.resource.repository.ResourceTypeRepository;
-import eu.dnetlib.data.is.vocabulary.model.Vocabulary;
import eu.dnetlib.data.is.vocabulary.repository.VocabularyRepository;
import eu.dnetlib.is.info.KeyValue;
import eu.dnetlib.is.wfs.WfHistoryAjaxController;
@@ -68,14 +67,6 @@ public class MainController {
@GetMapping("/contexts")
public void contexts() {}
- @GetMapping("/vocabularyEditor")
- public void vocabularyEditor(@RequestParam final String id, final ModelMap map) {
- final Vocabulary voc = vocabularyRepository.getById(id);
- map.put("vocId", voc.getId());
- map.put("vocName", voc.getName());
- map.put("vocDesc", voc.getDescription());
- }
-
@GetMapping("/wf_history")
public void wfHistory(final ModelMap map,
@RequestParam(required = false, defaultValue = "-1") final Long from,
diff --git a/apps/dnet-is-application/src/main/resources/static/contexts/editor.html b/apps/dnet-is-application/src/main/resources/static/contexts/editor.html
index 1f490902..ac36dc61 100644
--- a/apps/dnet-is-application/src/main/resources/static/contexts/editor.html
+++ b/apps/dnet-is-application/src/main/resources/static/contexts/editor.html
@@ -6,7 +6,7 @@
data-target="#showParametersModal" ng-click="loadContextParameters()">[show]
- Return to contexts list Download
+ Return to contexts list Download
diff --git a/apps/dnet-is-application/src/main/resources/static/js/vocabularies.js b/apps/dnet-is-application/src/main/resources/static/js/vocabularies.js
index cfbe79a2..4db8384c 100644
--- a/apps/dnet-is-application/src/main/resources/static/js/vocabularies.js
+++ b/apps/dnet-is-application/src/main/resources/static/js/vocabularies.js
@@ -1,17 +1,24 @@
-var app = angular.module('vocabulariesApp', []);
+var app = angular.module('vocabulariesApp', ['ngRoute']);
-app.controller('vocabulariesController', function($scope, $http) {
+
+app.config(['$routeProvider', function($routeProvider) {
+ $routeProvider
+ .when('/list', { templateUrl: 'vocs/list.html', controller: 'vocListController' })
+ .when('/edit', { templateUrl: 'vocs/editor.html', controller: 'vocEditorController' })
+ .otherwise({ redirectTo: '/list' });
+ }
+]);
+
+app.controller('vocListController', function($scope, $http, $location) {
$scope.vocabularies = [];
$scope.tmpVoc = {};
$scope.mode = '';
-
- $scope.reload = function() {
- $http.get('./ajax/vocs/?' + $.now()).then(function successCallback(res) {
- $scope.vocabularies = res.data;
- }, function errorCallback(res) {
- alert('ERROR: ' + res.data.message);
- });
- };
+
+ $http.get('./ajax/vocs/?' + $.now()).then(function successCallback(res) {
+ $scope.vocabularies = res.data;
+ }, function errorCallback(res) {
+ alert('ERROR: ' + res.data.message);
+ });
$scope.prepareNewVoc = function() {
$scope.mode = 'new';
@@ -60,6 +67,88 @@ app.controller('vocabulariesController', function($scope, $http) {
});
}
};
-
- $scope.reload();
+});
+
+app.controller('vocEditorController', function($scope, $http, $location, $routeParams) {
+ $scope.terms = [];
+ $scope.vocId = $routeParams.id;
+ $scope.vocInfo = {};
+ $scope.editTermCode = '';
+ $scope.tmpTerm = {};
+ $scope.mode = '';
+ $scope.currTerm = [];
+
+ $scope.baseUrl = './ajax/vocs/' + encodeURIComponent($scope.vocId);
+
+ $http.get($scope.baseUrl + '?' + $.now()).then(function successCallback(res) {
+ $scope.vocInfo = res.data;
+
+ $http.get($scope.baseUrl + '/terms?' + $.now()).then(function successCallback(res) {
+ $scope.terms = res.data;
+ }, function errorCallback(res) {
+ alert('ERROR: ' + res.data.message);
+ });
+ }, function errorCallback(res) {
+ alert('ERROR: ' + res.data.message);
+ });
+
+ $scope.setCurrTerm = function(term) {
+ $scope.currTerm = angular.copy(term);
+ }
+
+ $scope.prepareNewTerm = function() {
+ $scope.mode = 'new';
+ $scope.editTermCode = '';
+ $scope.tmpTerm = {
+ 'code' : '',
+ 'name' : '',
+ 'encoding' : 'OPENAIRE',
+ 'synonyms' : []
+ };
+ }
+
+ $scope.prepareEditTerm = function(term) {
+ $scope.mode = 'edit';
+ $scope.editTermCode = term.code;
+ $scope.tmpTerm = angular.copy(term);
+ }
+
+
+ $scope.saveTerm = function(term) {
+
+ var url = $scope.baseUrl + '/terms?' + $.now();
+
+ $http.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8";
+ $http.post(url, term).then(function successCallback(res) {
+ if ($scope.editTermCode != '' && $scope.editTermCode != $scope.tmpTerm.code) {
+ var deleteUrl = $scope.baseUrl + '/terms/' + encodeURIComponent($scope.editTermCode) + '?' + $.now();
+ $http.delete(deleteUrl).then(function successCallback(res) {
+ $scope.terms = res.data;
+ alert("Term replaced");
+ }, function errorCallback(res) {
+ alert('ERROR: ' + res.data.message);
+ });
+ } else {
+ $scope.terms = res.data;
+ alert("Term saved");
+ }
+ }, function errorCallback(res) {
+ alert('ERROR: ' + res.data.message);
+ });
+
+ };
+
+ $scope.deleteTerm = function(code) {
+ if (confirm("Are you sure ?")) {
+ var url = $scope.baseUrl + '/terms/' + encodeURIComponent(code) + '?' + $.now();
+
+ $http.delete(url).then(function successCallback(res) {
+ $scope.terms = res.data;
+ alert("Term deleted");
+ }, function errorCallback(res) {
+ alert('ERROR: ' + res.data.message);
+ });
+ }
+ };
+
});
diff --git a/apps/dnet-is-application/src/main/resources/static/vocs/editor.htm b/apps/dnet-is-application/src/main/resources/static/vocs/editor.htm
deleted file mode 100644
index e69de29b..00000000
diff --git a/apps/dnet-is-application/src/main/resources/static/vocs/editor.html b/apps/dnet-is-application/src/main/resources/static/vocs/editor.html
new file mode 100644
index 00000000..95a0d9e0
--- /dev/null
+++ b/apps/dnet-is-application/src/main/resources/static/vocs/editor.html
@@ -0,0 +1,116 @@
+
+
+
+
+
+ Vocabulary ID: Vocabulary Name: Description:
+
+
+ Return to vocabulary list
+ create a new term
+ Download
+
+
+
+
+
+
+ Number of terms: {{(terms | filter:termFilter).length}}
+
+
+
+
+
+ Code
+ Name
+ Encoding
+ Synonyms
+
+
+
+
+
+ no terms
+
+
+ {{t.code}}
+ {{t.name}}
+ {{t.encoding}}
+ 0 synonym(s) {{s.term}}
+
+ edit
+ delete
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/apps/dnet-is-application/src/main/resources/static/vocs/list.html b/apps/dnet-is-application/src/main/resources/static/vocs/list.html
index e69de29b..98acfc83 100644
--- a/apps/dnet-is-application/src/main/resources/static/vocs/list.html
+++ b/apps/dnet-is-application/src/main/resources/static/vocs/list.html
@@ -0,0 +1,72 @@
+
+
+
+
+ create a new vocabulary
+
+
+
+
+
+ Number of vocabularies: {{(vocabularies | filter:vocFilter).length}}
+
+
+
+
+ ID
+ Name
+ Description
+
+
+
+
+
+ no vocabularies
+
+
+ {{v.id}}
+ {{v.name}}
+ {{v.description}}
+
+ edit
+ delete
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/apps/dnet-is-application/src/main/resources/templates/vocabularies.html b/apps/dnet-is-application/src/main/resources/templates/vocabularies.html
deleted file mode 100644
index 534edee1..00000000
--- a/apps/dnet-is-application/src/main/resources/templates/vocabularies.html
+++ /dev/null
@@ -1,90 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
- create a new vocabulary
-
-
-
-
-
- Number of vocabularies: {{(vocabularies | filter:vocFilter).length}}
-
-
-
-
- ID
- Name
- Description
-
-
-
-
-
- no vocabularies
-
-
- {{v.id}}
- {{v.name}}
- {{v.description}}
-
- edit
- delete
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/apps/dnet-is-application/src/main/resources/templates/vocabularyEditor.html b/apps/dnet-is-application/src/main/resources/templates/vocabularyEditor.html
deleted file mode 100644
index 1afb641c..00000000
--- a/apps/dnet-is-application/src/main/resources/templates/vocabularyEditor.html
+++ /dev/null
@@ -1,146 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Vocabulary ID:
- Vocabulary Name:
- Description:
-
-
- Return to vocabulary list
- create a new term
- Download
-
-
-
-
-
-
- Number of terms: {{(terms | filter:termFilter).length}}
-
-
-
-
-
- Code
- Name
- Encoding
- Synonyms
-
-
-
-
-
- no terms
-
-
- {{t.code}}
- {{t.name}}
- {{t.encoding}}
-
- 0 synonym(s)
- {{s.term}}
-
-
- edit
- delete
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/apps/dnet-is-application/src/main/resources/templates/vocs.html b/apps/dnet-is-application/src/main/resources/templates/vocs.html
new file mode 100644
index 00000000..d2e139b4
--- /dev/null
+++ b/apps/dnet-is-application/src/main/resources/templates/vocs.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/libs/dnet-is-common/TODO.txt b/libs/dnet-is-common/TODO.txt
new file mode 100644
index 00000000..6349d133
--- /dev/null
+++ b/libs/dnet-is-common/TODO.txt
@@ -0,0 +1,4 @@
+- Cache
+- Spinner durante il caricamento
+- Astrarre le chiamate Ajax con Spinner
+- Nuove pagine