Skip to content

Commit d1b2a76

Browse files
committed
Use YAML for infos and shorten them in overview
fixes #107
1 parent 7fe777d commit d1b2a76

File tree

8 files changed

+75
-68
lines changed

8 files changed

+75
-68
lines changed

spring-boot-admin-server-ui/app/js/controller/overviewCtrl.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
*/
1616
'use strict';
1717

18-
var angular = require('angular');
19-
20-
module.exports = function ($scope, $location, $interval, $q, $state, Application, Notification) {
18+
module.exports = function ($scope, $location, $interval, $q, $state, $filter, Application, Notification) {
2119
var createNote = function(app) {
2220
var title = app.name + (app.statusInfo.status === 'UP' ? ' is back ' : ' went ') + app.statusInfo.status;
2321
var options = { tag: app.id,
@@ -37,18 +35,28 @@ module.exports = function ($scope, $location, $interval, $q, $state, Application
3735
//find application in known applications and copy state --> less flickering
3836
for (var j = 0; $scope.applications != null && j < $scope.applications.length; j++) {
3937
if (app.id === $scope.applications[j].id) {
40-
app.info = $scope.applications[j].info;
41-
38+
app.infoShort = $scope.applications[j].infoShort;
39+
app.infoDetails = $scope.applications[j].infoDetails;
40+
app.version = $scope.applications[j].version;
4241
//issue notifiaction on state change
4342
if (app.statusInfo.status !== $scope.applications[j].statusInfo.status) {
4443
createNote(app);
4544
}
4645
break;
4746
}
4847
}
49-
5048
app.getInfo().success(function(info) {
51-
angular.copy(info, app.info);
49+
app.version = info.version;
50+
app.infoDetails = null;
51+
app.infoShort = '';
52+
delete info.version;
53+
var infoYml = $filter('yaml')(info);
54+
if (infoYml !== '{}\n') {
55+
app.infoShort = $filter('limitLines')(infoYml, 3);
56+
if (app.infoShort !== infoYml) {
57+
app.infoDetails = $filter('limitLines')(infoYml, 32000, 3);
58+
}
59+
}
5260
}).finally(function(){
5361
app.refreshing = false;
5462
});

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

Lines changed: 0 additions & 53 deletions
This file was deleted.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ 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'));
11+
springBootAdmin.filter('yaml', require('./yaml'));
12+
springBootAdmin.filter('limitLines', require('./limitLines'));
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
module.exports = function () {
19+
return function (input, limit, begin) {
20+
begin = begin | 0;
21+
var lines = input.match(/[^\r\n]+/g);
22+
return lines.splice(begin, begin + limit).join('\n');
23+
};
24+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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 yaml = require('js-yaml');
19+
20+
module.exports = function () {
21+
return function (input) {
22+
return yaml.dump(input, {skipInvalid: true, sort: true});
23+
};
24+
};

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 style="white-space: pre;">{{ value | flatten }}</td>
12+
<td>{{ key }}</td><td style="white-space: pre">{{ value | yaml }}</td>
1313
</tr>
1414
</tbody>
1515
</table>

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ <h2 >Spring-Boot applications<br>
2222
<tbody>
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>
25-
<td>{{ application.info.version }}</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>
25+
<td>{{ application.version }}</td>
26+
<td><span style="white-space: pre" ng-init="collapsed = true">{{application.infoShort}}</span>
27+
<a class="btn btn-mini" ng-show="application.infoDetails" ng-click="collapsed = !collapsed">...</a><br/>
28+
<span style="white-space: pre" ng-hide="collapsed">{{application.infoDetails}}</span></td>
2729
<td><span class="status-{{application.statusInfo.status}}" title="{{application.statusInfo.timestamp | date:'dd.MM.yyyy HH:mm:ss' }}">{{ application.statusInfo.status }}</span>
2830
<span ng-show="application.refreshing" class="refresh"></span></td>
2931
<td>

spring-boot-admin-server-ui/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
"test": "./node_modules/gulp/bin/gulp.js"
88
},
99
"dependencies": {
10-
"es5-shim": "^3.0.2",
11-
"jquery": "~2.1.1",
12-
"angular-ui-router": "~0.2.11",
10+
"angular": "~1.2.27",
1311
"angular-resource": "~1.2.27",
1412
"angular-route": "~1.2.27",
15-
"angular": "~1.2.27"
13+
"angular-ui-router": "~0.2.11",
14+
"es5-shim": "^3.0.2",
15+
"jquery": "~2.1.1",
16+
"js-yaml": "^3.4.2"
1617
},
1718
"devDependencies": {
1819
"browserify": "^3.44.2",

0 commit comments

Comments
 (0)