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