This commit is contained in:
Michele Artini 2022-06-27 14:54:22 +02:00
parent 9ff5476a70
commit 2ee52eef18
4 changed files with 53 additions and 31 deletions

View File

@ -59,7 +59,7 @@ public class ContextRestController {
@GetMapping("/{ctxId}")
public Context getContext(@PathVariable final String ctxId) {
return contextRepository.getById(ctxId);
return contextRepository.findById(ctxId).get();
}
@GetMapping("/{parent}/categories")

View File

@ -3,6 +3,7 @@ var app = angular.module('contextApp', []);
app.controller('contextController', function($scope, $http, $location) {
$scope.categories = [];
$scope.ctxId = ctxId();
$scope.parameters = [];
$scope.reload = function() {
$scope.url = './api/contexts/' + encodeURIComponent($scope.ctxId) + '/categories';
@ -14,6 +15,17 @@ app.controller('contextController', function($scope, $http, $location) {
});
};
$scope.loadContextParameters = function() {
$scope.parameters = [];
$http.get('./api/contexts/' + encodeURIComponent($scope.ctxId) + '?' + $.now()).then(function successCallback(res) {
$scope.parameters = res.data.parameters;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.message);
});
}
$scope.populateNode = function(level, node) {
$scope.url = './api/contexts/'
+ encodeURIComponent(level)
@ -30,5 +42,9 @@ app.controller('contextController', function($scope, $http, $location) {
});
}
$scope.initShowParameters = function(params) {
$scope.parameters = params;
}
$scope.reload();
});

View File

@ -20,33 +20,33 @@
<p>
<b>Context ID: </b><span th:text="${ctxId}"></span><br />
<b>Label: </b><span th:text="${ctxLabel}"></span><br />
<b>Type: </b><span th:text="${ctxType}"></span>
<b>Type: </b><span th:text="${ctxType}"></span><br />
<b>Parameters: </b><a href="javascript:void(0)" data-toggle="modal" data-target="#showParametersModal" ng-click="loadContextParameters()">[show]</a>
</p>
<p>
<a class="btn btn-sm btn-primary" href="/contexts">Return to contexts list</a>
</p>
<ul>
<li ng-repeat="cat in categories">
<a href="javascript:void(0)" title="{{cat.label}}" ng-click="populateNode(0, cat)" ng-hide="cat.populated">{{cat.id}}</a>
<span title="{{cat.label}}" ng-show="cat.populated">{{cat.id}}</span>
<li ng-repeat="cat in categories" style="display: in">
<a href="javascript:void(0)" ng-click="populateNode(0, cat)" ng-hide="cat.populated">[+]</a>
<span class="badge badge-info" ng-show="cat.claim">claim</span>
<a href="javascript:void(0)" title="{{cat.label}}" data-toggle="modal" data-target="#showParametersModal" ng-click="initShowParameters(cat.parameters)">{{cat.id}}</a>
<ul ng-show="cat.concepts.length > 0">
<li ng-repeat="c0 in cat.concepts">
<a href="javascript:void(0)" title="{{c0.label}}" ng-click="populateNode(1, c0)" ng-hide="c0.populated">{{c0.id}}</a>
<span title="{{c0.label}}" ng-show="c0.populated">{{c0.id}}</span>
<a href="javascript:void(0)" ng-click="populateNode(1, c0)" ng-hide="c0.populated">[+]</a>
<span class="badge badge-info" ng-show="c0.claim">claim</span>
<a href="javascript:void(0)" title="{{c0.label}}" data-toggle="modal" data-target="#showParametersModal" ng-click="initShowParameters(c0.parameters)">{{c0.id}}</a>
<ul ng-show="c0.concepts.length > 0">
<li ng-repeat="c1 in c0.concepts">
<a href="javascript:void(0)" title="{{c1.label}}" ng-click="populateNode(2, c1)" ng-hide="c1.populated">{{c1.id}}</a>
<span title="{{c1.label}}" ng-show="c1.populated">{{c1.id}}</span>
<a href="javascript:void(0)" ng-click="populateNode(2, c1)" ng-hide="c1.populated">[+]</a>
<span class="badge badge-info" ng-show="c1.claim">claim</span>
<a href="javascript:void(0)" title="{{c1.label}}" data-toggle="modal" data-target="#showParametersModal" ng-click="initShowParameters(c1.parameters)">{{c1.id}}</a>
<ul ng-show="c1.concepts.length > 0">
<li ng-repeat="c2 in c1.concepts">
<span title="{{c1.label}}">{{c1.id}}</span>
<span class="badge badge-info" ng-show="c1.claim">claim</span>
<span class="badge badge-info" ng-show="c2.claim">claim</span>
<a href="javascript:void(0)" title="{{c2.label}}" data-toggle="modal" data-target="#showParametersModal" ng-click="initShowParameters(c2.parameters)">{{c2.id}}</a>
</li>
</ul>
</li>
</ul>
@ -59,6 +59,30 @@
</div>
</div>
<!-- Modals -->
<div class="modal fade" tabindex="-1" id="showParametersModal">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Parameters</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<table class="table table-sm table-striped" style="table-layout: fixed;">
<tr ng-show="parameters.length == 0">
<td colspan="2" align="center">0 parameter(s)</td>
</tr>
<tr ng-repeat="p in parameters">
<th style="width: 15%; padding-left: 20px">{{p.name}}</th>
<td style="overflow: hidden; text-overflow: ellipsis;">{{p.value}}</td>
</tr>
</table>
</div>
</div>
</div>
</body>
<th:block th:replace="fragments/mainParts.html :: scripts"></th:block>

View File

@ -2,32 +2,17 @@ package eu.dnetlib.is.context.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "contexts")
public class Context extends CtxInfo {
private static final long serialVersionUID = -8290775989306039922L;
@Id
@Column(name = "id")
private String id;
private static final long serialVersionUID = -8981861647499495787L;
@Column(name = "type")
private String type;
@Override
public String getId() {
return id;
}
@Override
public void setId(final String id) {
this.id = id;
}
public String getType() {
return type;
}
@ -36,7 +21,4 @@ public class Context extends CtxInfo {
this.type = type;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
}