add api page (mock)
This commit is contained in:
parent
b44cb9e852
commit
d54ae4ac64
|
@ -16,6 +16,7 @@ import eu.dnetlib.data.is.context.repository.ContextRepository;
|
||||||
import eu.dnetlib.data.is.resource.model.ResourceType;
|
import eu.dnetlib.data.is.resource.model.ResourceType;
|
||||||
import eu.dnetlib.data.is.resource.repository.ResourceTypeRepository;
|
import eu.dnetlib.data.is.resource.repository.ResourceTypeRepository;
|
||||||
import eu.dnetlib.data.is.vocabulary.repository.VocabularyRepository;
|
import eu.dnetlib.data.is.vocabulary.repository.VocabularyRepository;
|
||||||
|
import eu.dnetlib.data.is.vocabulary.repository.VocabularyTermRepository;
|
||||||
import eu.dnetlib.is.info.KeyValue;
|
import eu.dnetlib.is.info.KeyValue;
|
||||||
import eu.dnetlib.is.wfs.WfHistoryAjaxController;
|
import eu.dnetlib.is.wfs.WfHistoryAjaxController;
|
||||||
import eu.dnetlib.openaire.dsm.utils.DsmBrowsableFields;
|
import eu.dnetlib.openaire.dsm.utils.DsmBrowsableFields;
|
||||||
|
@ -29,6 +30,9 @@ public class MainController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private VocabularyRepository vocabularyRepository;
|
private VocabularyRepository vocabularyRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private VocabularyTermRepository vocabularyTermRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ResourceTypeRepository resourceTypeRepository;
|
private ResourceTypeRepository resourceTypeRepository;
|
||||||
|
|
||||||
|
@ -41,6 +45,9 @@ public class MainController {
|
||||||
map.addAttribute("browsableFields", Arrays.stream(DsmBrowsableFields.values())
|
map.addAttribute("browsableFields", Arrays.stream(DsmBrowsableFields.values())
|
||||||
.map(f -> new KeyValue(f.name(), f.desc))
|
.map(f -> new KeyValue(f.name(), f.desc))
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
|
map.addAttribute("protocols", vocabularyTermRepository.findTermsByVocabulary("dnet:protocols"));
|
||||||
|
map.addAttribute("compatibilityLevels", vocabularyTermRepository.findTermsByVocabulary("dnet:compatibilityLevel"));
|
||||||
|
map.addAttribute("contentDescTypes", vocabularyTermRepository.findTermsByVocabulary("dnet:content_description_typologies"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/resources")
|
@GetMapping("/resources")
|
||||||
|
|
|
@ -6,6 +6,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
@ -47,4 +49,9 @@ public class DsmAjaxController extends AbstractDnetController {
|
||||||
return dsmService.findApi(id);
|
return dsmService.findApi(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/api")
|
||||||
|
public Api saveApi(@RequestBody final Api api) throws DsmException {
|
||||||
|
throw new DsmException("TO BE IMPLEMENTED");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row mt-5">
|
||||||
|
<div class="col">
|
||||||
|
|
||||||
|
<form>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-sm-2 col-form-label col-form-label-sm">Datasource</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<input type="text" readonly class="form-control-plaintext form-control-sm" ng-model="dsName"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-sm-2 col-form-label col-form-label-sm">API Id</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<div class="input-group input-group-sm">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text">{{prefix}}</span>
|
||||||
|
</div>
|
||||||
|
<input type="text" class="form-control" ng-model="api.id" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-sm-2 col-form-label col-form-label-sm">Compatibility level</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<select class="custom-select custom-select-sm" ng-model="api.compliance">
|
||||||
|
<option ng-repeat="v in compatibilityLevels">{{v}}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-sm-2 col-form-label col-form-label-sm">Content description</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<select class="custom-select custom-select-sm" ng-model="api.contentdescription">
|
||||||
|
<option ng-repeat="v in contentDescTypes">{{v}}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-sm-2 col-form-label col-form-label-sm">BaseURL</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<input type="text" class="form-control form-control-sm" ng-model="api.baseUrl"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{{api}}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -49,7 +49,7 @@
|
||||||
<td>
|
<td>
|
||||||
<span ng-repeat="o in r.organizations">
|
<span ng-repeat="o in r.organizations">
|
||||||
{{o.name}}
|
{{o.name}}
|
||||||
<img src="common/images/flags/{{o.country}}.gif" title="{{o.country}}" alt="" ng-if="o.country"/>
|
<img ng-src="common/images/flags/{{o.country}}.gif" title="{{o.country}}" alt="" ng-if="o.country"/>
|
||||||
<br />
|
<br />
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
@ -65,6 +65,8 @@
|
||||||
<span class="badge badge-success" ng-if="a.active">active</span><span class="badge badge-danger" ng-if="!a.active">not active</span>
|
<span class="badge badge-success" ng-if="a.active">active</span><span class="badge badge-danger" ng-if="!a.active">not active</span>
|
||||||
<span ng-if="a.aggrDate"><br/><b>Last aggregation:</b> {{a.aggrDate}} <b>(total: {{a.aggrTotal}})</b></span>
|
<span ng-if="a.aggrDate"><br/><b>Last aggregation:</b> {{a.aggrDate}} <b>(total: {{a.aggrTotal}})</b></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<a class="btn btn-primary btn-sm mt-2" href="#!/add/api?dsId={{r.id}}&dsName={{r.name}}">add api</a>
|
||||||
</td>
|
</td>
|
||||||
</tr><tr ng-if="r.consenttermsofuse">
|
</tr><tr ng-if="r.consenttermsofuse">
|
||||||
<th>Consent Terms of Use</th>
|
<th>Consent Terms of Use</th>
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
/*<![CDATA[*/
|
/*<![CDATA[*/
|
||||||
function browsableFields() { return /*[[${browsableFields}]]*/ ''; }
|
function browsableFields() { return /*[[${browsableFields}]]*/ ''; }
|
||||||
function pageSize() { return /*[[${pageSize}]]*/ ''; }
|
function pageSize() { return /*[[${pageSize}]]*/ ''; }
|
||||||
|
function protocols() { return /*[[${protocols}]]*/ ''; }
|
||||||
|
function compatibilityLevels() { return /*[[${compatibilityLevels}]]*/ ''; }
|
||||||
|
function contentDescTypes() { return /*[[${contentDescTypes}]]*/ ''; }
|
||||||
/*]]>*/
|
/*]]>*/
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -25,10 +28,11 @@
|
||||||
|
|
||||||
app.config(['$routeProvider', function($routeProvider) {
|
app.config(['$routeProvider', function($routeProvider) {
|
||||||
$routeProvider
|
$routeProvider
|
||||||
.when('/search', { templateUrl: 'dsm/search.html', controller: 'dsmSearchController' })
|
.when('/search', { templateUrl: 'dsm/search.html', controller: 'dsmSearchController' })
|
||||||
.when('/results/:page/:size', { templateUrl: 'dsm/results.html', controller: 'dsmResultsController' })
|
.when('/results/:page/:size', { templateUrl: 'dsm/results.html', controller: 'dsmResultsController' })
|
||||||
.when('/results/:field/:page/:size', { templateUrl: 'dsm/results.html', controller: 'dsmResultsController' })
|
.when('/results/:field/:page/:size', { templateUrl: 'dsm/results.html', controller: 'dsmResultsController' })
|
||||||
.when('/api', { templateUrl: 'dsm/api.html', controller: 'dsmApiController' })
|
.when('/add/api', { templateUrl: 'dsm/addApi.html', controller: 'dsmAddApiController' })
|
||||||
|
.when('/api', { templateUrl: 'dsm/api.html', controller: 'dsmApiController' })
|
||||||
.otherwise({ redirectTo: '/search' });
|
.otherwise({ redirectTo: '/search' });
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
@ -107,6 +111,27 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
app.controller('dsmAddApiController', function($scope, $http, $location, $timeout, $routeParams) {
|
||||||
|
$scope.dsName = $routeParams.dsName;
|
||||||
|
$scope.prefix = 'api_________::' + $routeParams.dsId + '::';
|
||||||
|
$scope.api = {}
|
||||||
|
|
||||||
|
$scope.protocols = protocols();
|
||||||
|
$scope.compatibilityLevels = compatibilityLevels();
|
||||||
|
$scope.contentDescTypes = contentDescTypes();
|
||||||
|
|
||||||
|
$scope.save = function() {
|
||||||
|
var record = angular.copy($scope.api);
|
||||||
|
record.id = $scope.prefix + record.id;
|
||||||
|
record.datasource = $routeParams.dsId;
|
||||||
|
|
||||||
|
json_http_post($http, './ajax/dsm/api', record, function(res) {
|
||||||
|
$scope.api = res.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.dnetlib.data.is.vocabulary.repository;
|
package eu.dnetlib.data.is.vocabulary.repository;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
||||||
import eu.dnetlib.data.is.vocabulary.model.VocabularyTerm;
|
import eu.dnetlib.data.is.vocabulary.model.VocabularyTerm;
|
||||||
import eu.dnetlib.data.is.vocabulary.model.VocabularyTermPK;
|
import eu.dnetlib.data.is.vocabulary.model.VocabularyTermPK;
|
||||||
|
@ -9,4 +10,6 @@ public interface VocabularyTermRepository extends JpaRepository<VocabularyTerm,
|
||||||
|
|
||||||
Iterable<VocabularyTerm> findByVocabularyOrderByCode(String vocabulary);
|
Iterable<VocabularyTerm> findByVocabularyOrderByCode(String vocabulary);
|
||||||
|
|
||||||
|
@Query(value = "SELECT vt.code FROM VocabularyTerm vt WHERE vt.vocabulary like ?1 ORDER BY vt.code")
|
||||||
|
Iterable<String> findTermsByVocabulary(String vocabulary);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue