diff --git a/apps/dnet-is-application/src/main/java/eu/dnetlib/dsm/DsmAjaxController.java b/apps/dnet-is-application/src/main/java/eu/dnetlib/dsm/DsmAjaxController.java index 2ac26820..3bd40bc1 100644 --- a/apps/dnet-is-application/src/main/java/eu/dnetlib/dsm/DsmAjaxController.java +++ b/apps/dnet-is-application/src/main/java/eu/dnetlib/dsm/DsmAjaxController.java @@ -47,8 +47,8 @@ public class DsmAjaxController extends AbstractDnetController { } @GetMapping("/conf") - public Map> configuration() { - final Map> map = new LinkedHashMap<>(); + public Map configuration() { + final Map map = new LinkedHashMap<>(); map.put("protocols", protocolService.listProtocols()); map.put("compatibilityLevels", vocabularyTermRepository.findTermsByVocabulary("dnet:compatibilityLevel")); map.put("contentDescTypes", vocabularyTermRepository.findTermsByVocabulary("dnet:content_description_typologies")); diff --git a/apps/dnet-is-application/src/main/resources/static/html/dsm_add_api.html b/apps/dnet-is-application/src/main/resources/static/html/dsm_add_api.html index a06058a7..6be8bad3 100644 --- a/apps/dnet-is-application/src/main/resources/static/html/dsm_add_api.html +++ b/apps/dnet-is-application/src/main/resources/static/html/dsm_add_api.html @@ -7,38 +7,12 @@
- - -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- - + + + -
diff --git a/apps/dnet-is-application/src/main/resources/static/html/parts/form_select.html b/apps/dnet-is-application/src/main/resources/static/html/parts/form_select.html new file mode 100644 index 00000000..620edfd3 --- /dev/null +++ b/apps/dnet-is-application/src/main/resources/static/html/parts/form_select.html @@ -0,0 +1,11 @@ +
+ +
+ +
+
diff --git a/apps/dnet-is-application/src/main/resources/static/js/dsm_ctrls.js b/apps/dnet-is-application/src/main/resources/static/js/dsm_ctrls.js index 05c627dd..d4cd90b3 100644 --- a/apps/dnet-is-application/src/main/resources/static/js/dsm_ctrls.js +++ b/apps/dnet-is-application/src/main/resources/static/js/dsm_ctrls.js @@ -85,30 +85,31 @@ app.controller('dsmAddApiController', function($scope, $http, $routeParams) { $scope.api = {} $scope.protocols = []; + $scope.protocolsMap = {}; $scope.compatibilityLevels = []; $scope.contentDescTypes = []; $scope.selProtParams = []; + $scope.$watch('api.protocol', function() { + if ($scope.api.protocol) { + $scope.selProtParams = $scope.protocolsMap[$scope.api.protocol]; + } + }); + + call_http_get($http, './ajax/dsm/conf' , function(res) { - $scope.protocols = res.data.protocols; + $scope.protocols = []; + $scope.protocolsMap = {}; + angular.forEach(res.data.protocols, function(prot) { + $scope.protocols.push(prot.id); + $scope.protocolsMap[prot.id] = prot.params; + }); + $scope.compatibilityLevels = res.data.compatibilityLevels; $scope.contentDescTypes = res.data.contentDescTypes; }); - - $scope.updateSelProtParams = function() { - $scope.api.apiParams = {}; - - if ($scope.api.protocol) { - for (var i=0; i < $scope.protocols.length; ++i) { - if ($scope.protocols[i].id == $scope.api.protocol) { - $scope.selProtParams = $scope.protocols[i].params; - return; - } - } - } - } - + $scope.save = function() { var record = angular.copy($scope.api); record.id = $scope.prefix + record.id; diff --git a/apps/dnet-is-application/src/main/resources/static/js/is_main.js b/apps/dnet-is-application/src/main/resources/static/js/is_main.js index e1d3b0d7..fc803fa1 100644 --- a/apps/dnet-is-application/src/main/resources/static/js/is_main.js +++ b/apps/dnet-is-application/src/main/resources/static/js/is_main.js @@ -79,4 +79,25 @@ app.directive('formTextfieldWithPrefix', function() { } }); +app.directive('formSelect', function() { + return { + restrict: 'E', + scope: { + 'label' : '@', + 'optional' : '@', + 'terms' : '=', + 'value' : '=', + + }, + templateUrl: './html/parts/form_select.html', + link: function(scope, element, attrs) { + scope.required = (scope.optional != 'true'); + } + }; +}); + + + + +