diff --git a/apps/dnet-is-application/src/main/java/eu/dnetlib/openaire/dsm/DsmAjaxController.java b/apps/dnet-is-application/src/main/java/eu/dnetlib/openaire/dsm/DsmAjaxController.java index e4cd5b2d..c472e057 100644 --- a/apps/dnet-is-application/src/main/java/eu/dnetlib/openaire/dsm/DsmAjaxController.java +++ b/apps/dnet-is-application/src/main/java/eu/dnetlib/openaire/dsm/DsmAjaxController.java @@ -11,8 +11,10 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import eu.dnetlib.common.controller.AbstractDnetController; +import eu.dnetlib.data.openaire.dsm.model.Api; import eu.dnetlib.data.openaire.dsm.model.BrowseTerm; import eu.dnetlib.data.openaire.dsm.model.view.SimpleDsWithApis; +import eu.dnetlib.is.errors.DsmException; import eu.dnetlib.openaire.dsm.utils.DsmBrowsableFields; @RestController @@ -40,4 +42,9 @@ public class DsmAjaxController extends AbstractDnetController { return dsmService.search(value, page, size); } + @GetMapping("/api") + public Api findApi(@RequestParam final String id) throws DsmException { + return dsmService.findApi(id); + } + } diff --git a/apps/dnet-is-application/src/main/java/eu/dnetlib/openaire/dsm/DsmService.java b/apps/dnet-is-application/src/main/java/eu/dnetlib/openaire/dsm/DsmService.java index 30692dde..a01c0c4c 100644 --- a/apps/dnet-is-application/src/main/java/eu/dnetlib/openaire/dsm/DsmService.java +++ b/apps/dnet-is-application/src/main/java/eu/dnetlib/openaire/dsm/DsmService.java @@ -517,4 +517,8 @@ public class DsmService { return simpleDsWithApisRepository.search(value, PageRequest.of(page, size)); } + public Api findApi(final String id) throws DsmException { + return apiRepository.findById(id).orElseThrow(() -> new DsmException("Api not found. ID: " + id)); + } + } diff --git a/apps/dnet-is-application/src/main/resources/static/dsm/api.html b/apps/dnet-is-application/src/main/resources/static/dsm/api.html new file mode 100644 index 00000000..04185ca0 --- /dev/null +++ b/apps/dnet-is-application/src/main/resources/static/dsm/api.html @@ -0,0 +1,7 @@ +
+
+
+ {{api}} +
+
+
diff --git a/apps/dnet-is-application/src/main/resources/static/dsm/results.html b/apps/dnet-is-application/src/main/resources/static/dsm/results.html index 270dc202..f5485238 100644 --- a/apps/dnet-is-application/src/main/resources/static/dsm/results.html +++ b/apps/dnet-is-application/src/main/resources/static/dsm/results.html @@ -57,7 +57,9 @@ APIs
- {{a.id}} + + {{a.id}} + {{a.protocol}} {{a.compliance}} activenot active diff --git a/apps/dnet-is-application/src/main/resources/templates/dsm.html b/apps/dnet-is-application/src/main/resources/templates/dsm.html index 276ba4cd..b8957911 100644 --- a/apps/dnet-is-application/src/main/resources/templates/dsm.html +++ b/apps/dnet-is-application/src/main/resources/templates/dsm.html @@ -28,11 +28,12 @@ .when('/search', { templateUrl: 'dsm/search.html', controller: 'dsmSearchController' }) .when('/results/:page/:size', { templateUrl: 'dsm/results.html', controller: 'dsmResultsController' }) .when('/results/:field/:page/:size', { templateUrl: 'dsm/results.html', controller: 'dsmResultsController' }) - .otherwise({ redirectTo: '/search' }); + .when('/api', { templateUrl: 'dsm/api.html', controller: 'dsmApiController' }) + .otherwise({ redirectTo: '/search' }); } ]); - app.controller('dsmSearchController', function($scope, $http, $location, $timeout) { + app.controller('dsmSearchController', function($scope, $http, $location, $timeout) { $scope.browseFieldId = ""; $scope.browseFieldName = ""; $scope.browseData = []; @@ -94,6 +95,17 @@ }); + + app.controller('dsmApiController', function($scope, $http, $location, $timeout, $routeParams) { + $scope.apiId = $routeParams.id; + $scope.api = {}; + + call_http_get($http, './ajax/dsm/api?id=' + encodeURIComponent($scope.apiId) , function(res) { + $scope.api = res.data; + }); + + }); +