form
This commit is contained in:
parent
f5ff6f0601
commit
0acad7e737
|
@ -24,6 +24,7 @@ import eu.dnetlib.data.openaire.dsm.model.view.SimpleDsWithApis;
|
|||
import eu.dnetlib.dsm.utils.DsmBrowsableFields;
|
||||
import eu.dnetlib.is.errors.DsmException;
|
||||
import eu.dnetlib.is.info.KeyValue;
|
||||
import eu.dnetlib.is.protocol.ProtocolService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/ajax/dsm")
|
||||
|
@ -35,6 +36,9 @@ public class DsmAjaxController extends AbstractDnetController {
|
|||
@Autowired
|
||||
private VocabularyTermRepository vocabularyTermRepository;
|
||||
|
||||
@Autowired
|
||||
private ProtocolService protocolService;
|
||||
|
||||
@GetMapping("/browsableFields")
|
||||
public List<KeyValue> browsableFields() {
|
||||
return Arrays.stream(DsmBrowsableFields.values())
|
||||
|
@ -42,10 +46,10 @@ public class DsmAjaxController extends AbstractDnetController {
|
|||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@GetMapping("/validTerms")
|
||||
public Map<String, Iterable<String>> validTerms() {
|
||||
final Map<String, Iterable<String>> map = new LinkedHashMap<>();
|
||||
map.put("protocols", vocabularyTermRepository.findTermsByVocabulary("dnet:protocols"));
|
||||
@GetMapping("/conf")
|
||||
public Map<String, Iterable<?>> configuration() {
|
||||
final Map<String, Iterable<?>> map = new LinkedHashMap<>();
|
||||
map.put("protocols", protocolService.listProtocols());
|
||||
map.put("compatibilityLevels", vocabularyTermRepository.findTermsByVocabulary("dnet:compatibilityLevel"));
|
||||
map.put("contentDescTypes", vocabularyTermRepository.findTermsByVocabulary("dnet:content_description_typologies"));
|
||||
return map;
|
||||
|
|
|
@ -41,8 +41,8 @@
|
|||
<div class="form-group row">
|
||||
<label class="col-sm-2 col-form-label col-form-label-sm">Protocol</label>
|
||||
<div class="col-sm-10">
|
||||
<select class="custom-select custom-select-sm" ng-model="api.protocol">
|
||||
<option ng-repeat="v in protocols">{{v}}</option>
|
||||
<select class="custom-select custom-select-sm" ng-model="api.protocol" ng-change="updateSelProtParams()">
|
||||
<option ng-repeat="prot in protocols">{{prot.id}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -51,7 +51,17 @@
|
|||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control form-control-sm" ng-model="api.baseUrl"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-show="api.protocol" ng-repeat="p in selProtParams">
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2 col-form-label col-form-label-sm">Parameter: {{p.label}}</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control form-control-sm" ng-model="api.apiParams[p.name]"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
|
|
|
@ -87,13 +87,28 @@ app.controller('dsmAddApiController', function($scope, $http, $routeParams) {
|
|||
$scope.protocols = [];
|
||||
$scope.compatibilityLevels = [];
|
||||
$scope.contentDescTypes = [];
|
||||
|
||||
call_http_get($http, './ajax/dsm/browsableFields' , function(res) {
|
||||
|
||||
$scope.selProtParams = [];
|
||||
|
||||
call_http_get($http, './ajax/dsm/conf' , function(res) {
|
||||
$scope.protocols = res.data.protocols;
|
||||
$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;
|
||||
|
|
Loading…
Reference in New Issue