Skip to content

Commit 3cb0378

Browse files
author
Johannes Stelzer
committed
Flatten objects and format time in info-section
fixes #104
1 parent a36571b commit 3cb0378

File tree

5 files changed

+60
-2
lines changed

5 files changed

+60
-2
lines changed

spring-boot-admin-samples/spring-boot-admin-sample/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
<addResources>false</addResources>
3737
</configuration>
3838
</plugin>
39+
<plugin>
40+
<groupId>pl.project13.maven</groupId>
41+
<artifactId>git-commit-id-plugin</artifactId>
42+
</plugin>
3943
</plugins>
4044
</build>
4145
</project>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2014 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
'use strict';
17+
18+
var angular = require('angular');
19+
20+
module.exports = function ($filter) {
21+
var flatten = function (obj, prefix) {
22+
if (obj instanceof Date) {
23+
obj = $filter('date')(obj, 'dd.MM.yyyy HH:mm:ss');
24+
}
25+
if (typeof obj === 'boolean' || typeof obj === 'string' || typeof obj === 'number') {
26+
return (prefix ? prefix + ': ' : '') + obj;
27+
}
28+
29+
var result = '';
30+
var first = true;
31+
angular.forEach(obj, function(value, key) {
32+
if (angular.isString(value) && (key === 'time' || key === 'timestamp')) {
33+
if (/^\d+$/.test(value)) {
34+
value = new Date(value * 1000);
35+
} else if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{4}$/.test(value)) {
36+
value = new Date(value);
37+
}
38+
}
39+
40+
if (first) {
41+
first = false;
42+
} else {
43+
result = result + '\n';
44+
}
45+
46+
result = result + flatten(value, prefix ? prefix + '.' + key : key);
47+
});
48+
49+
return result;
50+
};
51+
52+
return flatten;
53+
};

spring-boot-admin-server-ui/app/js/filter/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ springBootAdmin.filter('classNameLoggerOnly', require('./classNameLoggerOnly'));
88
springBootAdmin.filter('capitalize', require('./capitalize'));
99
springBootAdmin.filter('humanBytes', require('./humanBytes'));
1010
springBootAdmin.filter('joinArray', require('./joinArray'));
11+
springBootAdmin.filter('flatten', require('./flatten'));

spring-boot-admin-server-ui/app/views/apps/details.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<thead><tr><th colspan="2">Application <small class="pull-right"><a href="api/applications/{{ application.id }}/info">raw JSON</a></small></th></tr></thead>
1010
<tbody>
1111
<tr ng-repeat="(key, value) in info" >
12-
<td>{{ key }}</td><td>{{ value }}</td>
12+
<td>{{ key }}</td><td style="white-space: pre;">{{ value | flatten }}</td>
1313
</tr>
1414
</tbody>
1515
</table>

spring-boot-admin-server-ui/app/views/overview.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ <h2 >Spring-Boot applications<br>
2323
<tr ng-repeat="application in applications|orderBy:order.column:order.descending|orderBy:'statusInfo.status':false track by application.id">
2424
<td>{{ application.name }}<br/><span class="muted">{{ application.serviceUrl || application.managementUrl || application.healthUrl }}</span></td>
2525
<td>{{ application.info.version }}</td>
26-
<td><span ng-repeat="(name, value) in application.info track by name" ng-if="name != 'version'">{{name}}: {{value}}<br></span></td>
26+
<td><span ng-repeat="(name, value) in application.info track by name" ng-if="name != 'version'" style="white-space: pre">{{value | flatten:name}}<br/></span></td>
2727
<td><span class="status-{{application.statusInfo.status}}" title="{{application.statusInfo.timestamp | date:'dd.MM.yyyy HH:mm:ss' }}">{{ application.statusInfo.status }}</span>
2828
<span ng-show="application.refreshing" class="refresh"></span></td>
2929
<td>

0 commit comments

Comments
 (0)