api page (mock)

This commit is contained in:
Michele Artini 2022-12-20 09:13:47 +01:00
parent 0e027eb037
commit b44cb9e852
5 changed files with 35 additions and 3 deletions

View File

@ -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);
}
}

View File

@ -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));
}
}

View File

@ -0,0 +1,7 @@
<div class="container-fluid">
<div class="row mt-5">
<div class="col">
{{api}}
</div>
</div>
</div>

View File

@ -57,7 +57,9 @@
<th>APIs</th>
<td>
<div ng-repeat="a in r.apis" ng-if="a.id">
<span class="monospaced">{{a.id}}</span>
<span class="monospaced">
<a href="#!/api?id={{a.id}}">{{a.id}}</a>
</span>
<span class="badge badge-primary" title="protocol">{{a.protocol}}</span>
<span class="badge badge-info" title="compliance">{{a.compliance}}</span>
<span class="badge badge-success" ng-if="a.active">active</span><span class="badge badge-danger" ng-if="!a.active">not active</span>

View File

@ -28,7 +28,8 @@
.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' });
}
]);
@ -95,6 +96,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;
});
});
</script>
</html>