Skip to content

Commit

Permalink
Detect URLs in /info and render them as links
Browse files Browse the repository at this point in the history
With this commit urls form the /info endpoint are deteceted and rendered as
links.
The downside is to make that work I had to drop the collapsible info section in
the overview list and replaced it with an resizable/scrollabe <pre> section.
  • Loading branch information
joshiste committed Jun 22, 2016
1 parent d4f521c commit 9086e00
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 80 deletions.
4 changes: 4 additions & 0 deletions spring-boot-admin-samples/spring-boot-admin-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
info:
version: @pom.version@
version: @project.version@
scm-url: @scm.url@
stage: test

logging:
Expand All @@ -11,9 +12,6 @@ spring:
boot:
admin:
url: http://localhost:8080
cloud:
config:
enabled: false

endpoints:
health:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@
<b>Error:</b> {{ error }}
</div>
<div style="display: flex; flex-wrap: wrap; justify-content: space-around;">
<sba-info-panel class="span5" panel-title="Application" raw="api/applications/{{ application.id }}/info">
<sba-info-panel class="span6" style="margin-left:0px" panel-title="Application" raw="api/applications/{{ application.id }}/info">
<table class="table">
<tr ng-repeat="(key, value) in info">
<td ng-bind="key"></td>
<td style="white-space: pre">{{ value | yaml }}</td>
<td style="white-space: pre" ng-bind-html="value | yaml | linkify:50"></td>
</tr>
</table>
</sba-info-panel>
<sba-info-panel class="span5" panel-title="Health" raw="api/applications/{{ application.id }}/health">
<sba-info-panel class="span6" style="margin-left:0px" panel-title="Health" raw="api/applications/{{ application.id }}/health">
<sba-health-status health="health"></sba-health-status>
</sba-info-panel>
<sba-info-panel class="span5" panel-title="Memory" raw="api/applications/{{ application.id }}/metrics/mem.*%7Cheap.*">
<sba-info-panel class="span6" style="margin-left:0px" panel-title="Memory" raw="api/applications/{{ application.id }}/metrics/mem.*%7Cheap.*">
<sba-memory-stats metrics=metrics></sba-memory-stats>
</sba-info-panel>
<sba-info-panel class="span5" panel-title="JVM" raw="api/applications/{{ application.id }}/metrics/systemload.*%7Cclasses.*%7Cuptime%7Cprocessors%7Cthreads.*">
<sba-info-panel class="span6" style="margin-left:0px"panel-title="JVM" raw="api/applications/{{ application.id }}/metrics/systemload.*%7Cclasses.*%7Cuptime%7Cprocessors%7Cthreads.*">
<sba-jvm-stats metrics="metrics"></sba-jvm-stats>
</sba-info-panel>
<sba-info-panel class="span5" panel-title="Garbage Collection" raw="api/applications/{{ application.id }}/metrics/gc.*">
<sba-info-panel class="span6" style="margin-left:0px" panel-title="Garbage Collection" raw="api/applications/{{ application.id }}/metrics/gc.*">
<sba-gc-stats metrics="metrics"></sba-gc-stats>
</sba-info-panel>
<sba-info-panel class="span5" panel-title="Servlet Container" raw="api/applications/{{ application.id }}/metrics/httpsessions.*" ng-show="metrics['httpsessions.active'] != null">
<sba-info-panel class="span6" style="margin-left:0px" panel-title="Servlet Container" raw="api/applications/{{ application.id }}/metrics/httpsessions.*" ng-show="metrics['httpsessions.active'] != null">
<sba-servlet-container-stats metrics="metrics"></sba-servlet-container-stats>
</sba-info-panel>
<sba-info-panel class="span5" panel-title="Datasources" raw="api/applications/{{ application.id }}/metrics/datasource.*" ng-show="hasDatasources">
<sba-info-panel class="span6" style="margin-left:0px" panel-title="Datasources" raw="api/applications/{{ application.id }}/metrics/datasource.*" ng-show="hasDatasources">
<sba-datasource-stats metrics="metrics"></sba-datasource-stats>
</sba-info-panel>
<sba-info-panel class="span5" panel-title="Caches" raw="api/applications/{{ application.id }}/metrics/cache.*" ng-show="hasCaches">
<sba-info-panel class="span6" style="margin-left:0px" panel-title="Caches" raw="api/applications/{{ application.id }}/metrics/cache.*" ng-show="hasCaches">
<sba-cache-stats metrics="metrics"></sba-cache-stats>
</sba-info-panel>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<tr>
<th>Type</th>
<th>Expiry</th>
<th>remove</th>
<th>Action</th>
</tr>
<tr ng-repeat="(key, value) in $ctrl.activeFilters">
<td ng-if="value.name">by name ({{value.name}})</td>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

var linkify = require('linkifyjs/string');

module.exports = function () {
return function (input, maxLength) {
var max = maxLength || Number.MAX_VALUE;
return linkify(input, {
target: '_blank',
format: function(url, type) {
if (type === 'url' && url.length > max) {
url = url.replace(/https?:\/\//, '');
if (url.length > max) {
var last = url.lastIndexOf('/');
if (last >= 0 && (url.length - last) < max) {
var end = url.substr(last);
var first = url.lastIndexOf('/', max - 3 - end.length);
if (first < 0) {
first = max - 3 - end.length;
}
url = url.substr(0, first + 1) + '...' + end;
} else {
url = url.substr(0, max - 3) + '...';
}
}
}
return url;
}
});
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ module.exports = function () {
return function (input) {
return yaml.dump(input, {
skipInvalid: true,
sort: true
sort: true,
lineWidth: Number.MAX_VALUE
});
};
};
14 changes: 3 additions & 11 deletions spring-boot-admin-server-ui/modules/applications/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

var angular = require('angular');

var module = angular.module('sba-applications', ['sba-core', require('angular-resource')]);
var module = angular.module('sba-applications', ['sba-core', require('angular-resource'), require('angular-sanitize')]);
global.sbaModules.push(module.name);

module.controller('applicationsCtrl', require('./controllers/applicationsCtrl.js'));
Expand All @@ -29,7 +29,7 @@ module.service('NotificationFilters', require('./services/notificationFilters.js
module.service('ApplicationViews', require('./services/applicationViews.js'));

module.filter('yaml', require('./filters/yaml.js'));
module.filter('limitLines', require('./filters/limitLines.js'));
module.filter('linkify', require('./filters/linkify.js'));

module.component('sbaInfoPanel', require('./components/infoPanel.js'));
module.component('sbaAccordion', require('./components/accordion.js'));
Expand Down Expand Up @@ -84,16 +84,8 @@ module.run(function ($rootScope, $state, $filter, Notification, Application, Mai
application.getInfo().then(function (response) {
var info = response.data;
application.version = info.version;
application.infoDetails = null;
application.infoShort = '';
delete info.version;
var infoYml = $filter('yaml')(info);
if (infoYml !== '{}\n') {
application.infoShort = $filter('limitLines')(infoYml, 3);
if (application.infoShort !== infoYml) {
application.infoDetails = $filter('limitLines')(infoYml, 32000, 3);
}
}
application.info = info;
}).finally(function () {
application.refreshing = false;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ <h3>Spring Boot applications</h3>
<input placeholder="Filter" class="input-xxlarge" type="search" ng-model="searchFilter" />
</div>
<table class="table table-hover">
<col/>
<col/>
<col/>
<col/>
<col/>
<col style="width: 250px;" />

<thead>
<tr>
<th><span class="sortable" ng-class="orderByCssClass('name')" ng-click="orderBy('name')">Application</span> /
Expand All @@ -25,11 +20,7 @@ <h3>Spring Boot applications</h3>
<td>{{ application.name }} ({{ application.id }})
<br/><span class="muted">{{ application.serviceUrl || application.managementUrl || application.healthUrl }}</span></td>
<td>{{ application.version }}</td>
<td><span style="white-space: pre" ng-init="collapsed = true">{{application.infoShort}}</span>
<a class="btn btn-mini" ng-show="application.infoDetails" ng-click="collapsed = !collapsed">...</a>
<br/>
<span style="white-space: pre" ng-hide="collapsed">{{application.infoDetails}}</span>
</td>
<td><pre class="pre-scrollable" style="resize: vertical; height: 62px;" ng-bind-html="application.info | yaml | linkify:60"></pre></td>
<td><span class="status-{{application.statusInfo.status}}" title="{{application.statusInfo.timestamp | date:'dd.MM.yyyy HH:mm:ss' }}">{{ application.statusInfo.status }}</span>
<span ng-show="application.refreshing"><i class="fa fa-spinner fa-pulse fa-lg"></i></span>
</td>
Expand Down
4 changes: 3 additions & 1 deletion spring-boot-admin-server-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
"dependencies": {
"angular": "^1.5.6",
"angular-resource": "^1.5.6",
"angular-sanitize": "^1.5.7",
"angular-ui-router": "^0.3.1",
"es5-shim": "^4.5.8",
"font-awesome": "^4.6.3",
"jquery": "^2.2.4",
"js-yaml": "^3.6.1",
"karma-chrome-launcher": "^1.0.1",
"karma-jasmine": "^1.0.2"
"karma-jasmine": "^1.0.2",
"linkifyjs": "^2.0.3"
},
"devDependencies": {
"clean-webpack-plugin": "^0.1.9",
Expand Down

This file was deleted.

0 comments on commit 9086e00

Please sign in to comment.