This commit is contained in:
Michele Artini 2022-06-16 11:15:05 +02:00
parent 6e42765602
commit 3905cf3c3f
5 changed files with 116 additions and 5 deletions

View File

@ -0,0 +1,15 @@
package eu.dnetlib.is.vocabulary;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
public class VocabularyUIController {
@GetMapping("/vocabularyEditor")
public void vocabularyEditor(@RequestParam final String id, final ModelMap map) {
map.put("vocId", id);
}
}

View File

@ -1,6 +1,6 @@
var app = angular.module('vocabularyApp', []); var app = angular.module('vocabulariesApp', []);
app.controller('vocabularyController', function($scope, $http) { app.controller('vocabulariesController', function($scope, $http) {
$scope.vocabularies = []; $scope.vocabularies = [];
$scope.reload = function() { $scope.reload = function() {

View File

@ -0,0 +1,27 @@
var app = angular.module('vocabularyApp', []);
app.controller('vocabularyController', function($scope, $http, $location) {
$scope.terms = [];
$scope.vocId = vocId();
$scope.reload = function() {
$http.get('./api/vocs/'+ encodeURIComponent($scope.vocId) + '?' + $.now()).then(function successCallback(res) {
$scope.terms = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.message);
});
};
$scope.newTerm = function(code, englishName, nativeName) {
$http.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8";
//TODO
};
$scope.deleteTerm = function(code) {
if (confirm("Are you sure ?")) {
//TODO
}
};
$scope.reload();
});

View File

@ -13,7 +13,7 @@
} }
</style> </style>
<body ng-app="vocabularyApp" ng-controller="vocabularyController"> <body ng-app="vocabulariesApp" ng-controller="vocabulariesController">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col"> <div class="col">
@ -42,7 +42,7 @@
<td colspan="4" class="text-muted">no vocabularies</td> <td colspan="4" class="text-muted">no vocabularies</td>
</tr> </tr>
<tr ng-repeat="v in vocabularies|filter:vocFilter"> <tr ng-repeat="v in vocabularies|filter:vocFilter">
<th>{{v.id}}</th> <th><a href="vocabularyEditor?id={{v.id}}">{{v.id}}</a></th>
<td>{{v.name}}</td> <td>{{v.name}}</td>
<td>{{v.description}}</td> <td>{{v.description}}</td>
<td align="right"><button type="button" class="btn btn-sm btn-danger" ng-click="deleteVocabulary(v.id)">delete</button></td> <td align="right"><button type="button" class="btn btn-sm btn-danger" ng-click="deleteVocabulary(v.id)">delete</button></td>
@ -93,5 +93,5 @@
<script src="common/js/bootstrap.min.js"></script> <script src="common/js/bootstrap.min.js"></script>
<script src="common/js/angular.min.js"></script> <script src="common/js/angular.min.js"></script>
<script src="js/vocabulary.js"></script> <script src="js/vocabularies.js"></script>
</html> </html>

View File

@ -0,0 +1,69 @@
<!DOCTYPE html>
<html>
<head>
<title>Information Service - Vocabulary</title>
<link rel="stylesheet" href="common/css/bootstrap.cerulean.min.css" />
<link rel="stylesheet" href="common/css/fontawesome-all.min.css" />
</head>
<style>
td {
vertical-align: middle !important;
}
</style>
<script th:inline="javascript">
/*<![CDATA[*/
function vocId() { return /*[[${vocId}]]*/ ''; }
/*]]>*/
</script>
<body ng-app="vocabularyApp" ng-controller="vocabularyController">
<div class="container-fluid">
<div class="row">
<div class="col">
<h1>Information Service - Vocabulary {{vocId}}</h1>
<hr />
<p ng-show="terms.length > 0">
<input type="text" class="form-control form-control-sm" ng-model="termFilter" placeholder="Filter..."/>
</p>
<p>
<span class="text-muted"><b>Number of terms:</b> {{(terms | filter:termFilter).length}}</span>
</p>
<table class="table table-sm table-striped">
<thead>
<tr>
<th style="width: 25%">Code</th>
<th style="width: 25%">English Name</th>
<th style="width: 25%">Native Name</th>
<th></th>
</tr>
</thead>
<tbody>
<tr ng-show="(terms|filter:termFilter).length == 0">
<td colspan="4" class="text-muted">no terms</td>
</tr>
<tr ng-repeat="t in terms|filter:termFilter">
<th>{{t.code}}</th>
<td>{{t.englishName}}</td>
<td>{{t.nativeName}}</td>
<td align="right"><button type="button" class="btn btn-sm btn-danger" ng-click="deleteTerm(t.id)">delete</button></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</body>
<script src="common/js/jquery.min.js"></script>
<script src="common/js/popper.min.js"></script>
<script src="common/js/bootstrap.min.js"></script>
<script src="common/js/angular.min.js"></script>
<script src="js/vocabularyEditor.js"></script>
</html>