This commit is contained in:
Michele Artini 2022-11-29 14:14:59 +01:00
parent 437e835d42
commit dcdfbbf64e
2 changed files with 44 additions and 43 deletions

View File

@ -11,6 +11,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.maven.model.Model; import org.apache.maven.model.Model;
@ -41,14 +42,7 @@ public class InfoRestController {
@GetMapping("/") @GetMapping("/")
public List<InfoSection<?>> info() throws Exception { public List<InfoSection<?>> info() throws Exception {
return Arrays.asList(jvm(), env(), libs(), sysProps(), appProps(), modules()); return Arrays.asList(jvm(), env(), libs(), sysProps(), modules());
}
private InfoSection<KeyValue> appProps() {
final InfoSection<KeyValue> appProps = new InfoSection<>("Application properties");
configurableEnvironment.getPropertySources()
.forEach(ps -> appProps.getData().add(new KeyValue(ps.getName(), ps.getSource().toString())));
return appProps;
} }
private InfoSection<KeyValue> sysProps() { private InfoSection<KeyValue> sysProps() {
@ -59,10 +53,10 @@ public class InfoRestController {
private InfoSection<KeyValue> libs() { private InfoSection<KeyValue> libs() {
final InfoSection<KeyValue> libs = new InfoSection<>("Libraries and arguments"); final InfoSection<KeyValue> libs = new InfoSection<>("Libraries and arguments");
libs.getData().add(new KeyValue("Classpath", mxbean.getClassPath().replaceAll(":", " : "))); libs.getData().add(new KeyValue("Classpath", mxbean.getClassPath()));
libs.getData().add(new KeyValue("Boot ClassPath", mxbean.getBootClassPath().replaceAll(":", " : "))); libs.getData().add(new KeyValue("Boot ClassPath", mxbean.getBootClassPath()));
libs.getData().add(new KeyValue("Input arguments", mxbean.getInputArguments().toString())); libs.getData().add(new KeyValue("Input arguments", StringUtils.join(mxbean.getInputArguments(), " ")));
libs.getData().add(new KeyValue("Library Path", mxbean.getLibraryPath().replaceAll(":", " : "))); libs.getData().add(new KeyValue("Library Path", mxbean.getLibraryPath()));
return libs; return libs;
} }

View File

@ -15,37 +15,35 @@
<input type="text" class="form-control form-control-sm" ng-model="infoFilter" placeholder="Filter..."/> <input type="text" class="form-control form-control-sm" ng-model="infoFilter" placeholder="Filter..."/>
</p> </p>
<div class="card mb-3" ng-repeat="section in info"> <div class="card mb-3" ng-repeat="section in info" ng-show="(section.data|filter:infoFilter).length > 0">
<div class="card-header">{{section.name}}</div>
<table class="table table-striped table-sm small">
<thead ng-if="section.name == 'Modules'">
<tr>
<th>Group ID</th>
<th>Artifact ID</th>
<th>Version</th>
<th>POM</th>
</tr>
</thead>
<tbody>
<tr ng-show="(section.data|filter:infoFilter).length == 0">
<td colspan="4">No match</td>
</tr>
<tr ng-repeat="r in section.data|filter:infoFilter" ng-if="section.name != 'Modules'">
<th style="width:30%">{{r.k}}</th>
<td>{{r.v}}</td>
</tr>
<tr ng-repeat="r in section.data|filter:infoFilter" ng-if="section.name == 'Modules'" ng-class="{'table-warning' : r.files.length > 1}">
<td>{{r.group}}</td>
<td>{{r.name}}</td>
<td><span ng-repeat="v in r.versions">{{v}}<br /></span></td>
<td><span ng-repeat="f in r.files">{{f}}<br /></span></td>
</tr>
</tbody>
</table>
<table class="table table-striped table-sm small" >
</tbody> <div class="card-body">
</table> <h5 class="card-title">{{section.name}}</h5>
<table class="table table-striped table-sm small">
<thead ng-if="section.name == 'Modules'">
<tr>
<th>Group ID</th>
<th>Artifact ID</th>
<th>Version</th>
<th>POM</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="r in section.data|filter:infoFilter" ng-if="section.name != 'Modules'">
<th style="width:30%">{{r.k}}</th>
<td><pre style="margin: 0">{{r.v}}</pre></td>
</tr>
<tr ng-repeat="r in section.data|filter:infoFilter" ng-if="section.name == 'Modules'" ng-class="{'table-warning' : r.files.length > 1}">
<td>{{r.group}}</td>
<td>{{r.name}}</td>
<td class="text-monospace"><span ng-repeat="v in r.versions">{{v}}<br /></span></td>
<td class="text-monospace"><span ng-repeat="f in r.files">{{f}}<br /></span></td>
</tr>
</tbody>
</table>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -62,6 +60,15 @@
$scope.modules = {}; $scope.modules = {};
$http.get('./api/info/?' + $.now()).then(function successCallback(res) { $http.get('./api/info/?' + $.now()).then(function successCallback(res) {
angular.forEach(res.data, function(section) {
if (section.name != 'Modules') {
angular.forEach(section.data, function(r) {
if (r.k.toLowerCase().includes('path')) {
r.v = r.v.replaceAll(':', ':\n');
}
});
}
});
$scope.info = res.data; $scope.info = res.data;
}, function errorCallback(res) { }, function errorCallback(res) {
alert('ERROR: ' + res.data.message); alert('ERROR: ' + res.data.message);