Skip to content

Commit 0c1caf7

Browse files
author
Johannes Stelzer
committed
Added working error messages to logging and jmx view to prevent such confusion as in #72
1 parent cbafd81 commit 0c1caf7

File tree

8 files changed

+106
-82
lines changed

8 files changed

+106
-82
lines changed

spring-boot-admin-server-ui/app/js/controller/apps/jmxCtrl.js

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

18-
module.exports = function ($scope, $modal, $log, application, ApplicationJMX) {
18+
module.exports = function ($scope, $modal, application, ApplicationJMX) {
1919
$scope.error = null;
2020
$scope.domains = [];
2121

2222
ApplicationJMX.list(application)
2323
.then(function (domains) {
2424
$scope.domains = domains;
25-
})
26-
.catch(function (response) {
27-
$scope.error = response.error;
28-
$log.error(response.stacktrace);
25+
}, function (response) {
26+
$scope.error = response;
27+
$scope.errorWhileListing = true;
2928
});
3029

3130
$scope.readAllAttr = function (bean) {
@@ -39,10 +38,8 @@ module.exports = function ($scope, $modal, $log, application, ApplicationJMX) {
3938
bean.attributes[name].jsonValue = JSON.stringify(response.value[
4039
name], null, ' ');
4140
}
42-
})
43-
.catch(function (response) {
41+
}, function (response) {
4442
bean.error = response.error;
45-
$log.error(response.stacktrace);
4643
});
4744
};
4845

@@ -52,7 +49,6 @@ module.exports = function ($scope, $modal, $log, application, ApplicationJMX) {
5249
.catch(
5350
function (response) {
5451
attr.error = response.error;
55-
$log.error(response.stacktrace);
5652
});
5753
};
5854

@@ -65,8 +61,7 @@ module.exports = function ($scope, $modal, $log, application, ApplicationJMX) {
6561
function (response) {
6662
$scope.invocation.state = 'success';
6763
$scope.invocation.result = response.value;
68-
})
69-
.catch(function (response) {
64+
}, function (response) {
7065
$scope.invocation.state = 'error';
7166
$scope.invocation.error = response.error;
7267
$scope.invocation.stacktrace = response.stacktrace;
@@ -97,8 +92,7 @@ module.exports = function ($scope, $modal, $log, application, ApplicationJMX) {
9792
})
9893
.result.then(function (chosenOp) {
9994
$scope.prepareInvoke(bean, name, chosenOp);
100-
})
101-
.catch(function () {
95+
}, function () {
10296
$scope.invocation = null;
10397
});
10498
} else {
@@ -122,8 +116,7 @@ module.exports = function ($scope, $modal, $log, application, ApplicationJMX) {
122116
})
123117
.result.then(function () {
124118
$scope.invoke();
125-
})
126-
.catch(function () {
119+
}, function () {
127120
$scope.invocation = null;
128121
});
129122
}

spring-boot-admin-server-ui/app/js/controller/apps/loggingCtrl.js

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

18-
module.exports = function ($scope, application, ApplicationLogging, $log) {
18+
module.exports = function ($scope, application, ApplicationLogging) {
1919
$scope.loggers = [];
2020
$scope.filteredLoggers = [];
2121
$scope.limit = 10;
2222

23-
function findLogger(loggers, name) {
23+
var findLogger = function (loggers, name) {
2424
for (var i in loggers) {
2525
if (loggers[i].name === name) {
2626
return loggers[i];
2727
}
2828
}
29-
}
29+
};
3030

3131
$scope.setLogLevel = function (name, level) {
3232
ApplicationLogging.setLoglevel(application, name, level)
3333
.then(function () {
3434
$scope.reload(name);
35-
})
36-
.catch(function (response) {
37-
$scope.error = response.error;
38-
$log.error(response.stacktrace);
35+
}, function (response) {
36+
$scope.error = response;
3937
$scope.reload(name);
4038
});
4139
};
@@ -72,12 +70,10 @@ module.exports = function ($scope, application, ApplicationLogging, $log) {
7270
findLogger($scope.loggers, name)
7371
.level = level;
7472
}
75-
})
76-
.catch(function (responses) {
73+
}, function (responses) {
7774
for (var j in responses) {
7875
if (responses[j].error != null) {
79-
$scope.error = responses[j].error;
80-
$log.error(responses[j].stacktrace);
76+
$scope.error = responses[j];
8177
break;
8278
}
8379
}
@@ -101,9 +97,8 @@ module.exports = function ($scope, application, ApplicationLogging, $log) {
10197
$scope.$watch('limit', function () {
10298
$scope.refreshLevels();
10399
});
104-
})
105-
.catch(function (response) {
106-
$scope.error = response.error;
107-
$log.error(response.stacktrace);
100+
}, function (response) {
101+
$scope.error = response;
102+
$scope.errorWhileListing = true;
108103
});
109104
};

spring-boot-admin-server-ui/app/js/service/application.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@ module.exports = function ($resource, $http) {
2828

2929
var getCapabilities = function(application) {
3030
application.capabilities = {};
31-
$http.get('api/applications/' + application.id + '/configprops').success(function(configprops) {
32-
application.capabilities.logfile = isEndpointPresent('logfileEndpoint', configprops);
33-
application.capabilities.activiti = isEndpointPresent('processEngineEndpoint', configprops);
34-
application.capabilities.restart = isEndpointPresent('restartEndpoint', configprops);
35-
application.capabilities.refresh = isEndpointPresent('refreshEndpoint', configprops);
36-
application.capabilities.pause = isEndpointPresent('pauseEndpoint', configprops);
37-
application.capabilities.resume = isEndpointPresent('resumeEndpoint', configprops);
38-
});
31+
if (application.managementUrl) {
32+
$http.get('api/applications/' + application.id + '/configprops').success(function(configprops) {
33+
application.capabilities.logfile = isEndpointPresent('logfileEndpoint', configprops);
34+
application.capabilities.activiti = isEndpointPresent('processEngineEndpoint', configprops);
35+
application.capabilities.restart = isEndpointPresent('restartEndpoint', configprops);
36+
application.capabilities.refresh = isEndpointPresent('refreshEndpoint', configprops);
37+
application.capabilities.pause = isEndpointPresent('pauseEndpoint', configprops);
38+
application.capabilities.resume = isEndpointPresent('resumeEndpoint', configprops);
39+
});
40+
}
3941
};
4042

4143
var Application = $resource(

spring-boot-admin-server-ui/app/js/service/applicationJmx.js

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

18-
module.exports = function ($rootScope, Abbreviator, jolokia) {
18+
module.exports = function ($rootScope, Abbreviator, jolokia, $q) {
1919
this.list = function (app) {
2020
return jolokia.list('api/applications/' + app.id + '/jolokia/')
2121
.then(function (response) {
@@ -76,7 +76,7 @@ module.exports = function ($rootScope, Abbreviator, jolokia) {
7676

7777
return domains;
7878
}, function (response) {
79-
return response;
79+
return $q.reject(response);
8080
});
8181
};
8282

spring-boot-admin-server-ui/app/js/service/jolokia.js

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

18+
var angular = require('angular');
1819
module.exports = function ($q) {
1920
var outer = this;
2021
var j4p = new Jolokia();
@@ -45,6 +46,13 @@ module.exports = function ($q) {
4546
if (responses.length >= requests.length) {
4647
deferred.reject(responses);
4748
}
49+
},
50+
ajaxError: function (response) {
51+
hasError = true;
52+
responses.push(angular.fromJson(response.responseText));
53+
if (responses.length >= requests.length) {
54+
deferred.reject(responses, response.status);
55+
}
4856
}
4957
});
5058

@@ -63,6 +71,9 @@ module.exports = function ($q) {
6371
},
6472
error: function (response) {
6573
deferred.reject(response);
74+
},
75+
ajaxError: function (response) {
76+
deferred.reject(angular.fromJson(response.responseText), response.status);
6677
}
6778
});
6879

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
<div class="navbar header--application-urls">
1818
<div class="navbar-inner">
1919
<div class="container-fluid">
20-
<ul class="nav" style="width: 100%;">
21-
<li style="width: 33%; text-align: center;"><a href="{{ application.serviceUrl }}" title="Service URL"><i class="icon-home" ></i> {{ application.serviceUrl }}</a></li>
22-
<li style="width: 33%; text-align: center;"><a href="{{ application.healthUrl }}" title="Health URL"><i class="icon-heart" ></i> {{ application.healthUrl }}</a></li>
23-
<li style="width: 33%; text-align: center;"><a href="{{ application.managementUrl }}" title="Management URL"><i class="icon-wrench"></i> {{ application.managementUrl }}</a></li>
20+
<ul class="nav">
21+
<li ng-if="application.healthUrl" style=" text-align: center;"><a href="{{ application.healthUrl }}" title="Health URL"><i class="icon-heart" ></i> {{ application.healthUrl }}</a></li>
22+
<li ng-if="application.serviceUrl" style="text-align: center;"><a href="{{ application.serviceUrl }}" title="Service URL"><i class="icon-home" ></i> {{ application.serviceUrl }}</a></li>
23+
<li ng-if="application.managementUrl" style="text-align: center;"><a href="{{ application.managementUrl }}" title="Management URL"><i class="icon-wrench"></i> {{ application.managementUrl }}</a></li>
2424
</ul>
2525
</div>
2626
</div>

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
<div class="container content">
2-
<div class="alert alert-error" ng-if="error">
3-
<b>Error:</b> {{ error }}
2+
<div ng-if="errorWhileListing">
3+
<p>To make the JMX section work you need to make the /jolokia-endpoint accessible.<br/>
4+
Include the jolokia-core.jar in your spring-boot-application:
5+
<pre>&lt;dependency&gt;
6+
&lt;groupId>org.jolokia&lt;/groupId&gt;
7+
&lt;artifactId>jolokia-core&lt;/artifactId&gt;
8+
&lt;/dependency&gt;</pre></p>
49
</div>
5-
<accordion close-others="true">
10+
<pre class="alert alert-error" ng-if="error"><b>Error:</b><br/>{{ error | json }}</pre>
11+
<accordion ng-if="domains" close-others="true">
612
<accordion-group ng-repeat="domain in domains track by domain.name">
713
<accordion-heading>
814
<small class="muted">Domain</small> {{domain.name}}
Lines changed: 52 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,54 @@
11
<div class="container content">
2-
<form ng-init="showPackageLoggers = false">
3-
<div class="input-prepend input-append">
4-
<button class="btn" title="Show package-level loggers" ng-class="{'btn-inverse': showPackageLoggers}" ng-model="showPackageLoggers" btn-checkbox ><i class="icon-folder-open" ng-class="{'icon-white': showPackageLoggers}"></i></button>
5-
<input placeholder="Filter by name ..." class="span10" type="search" ng-model="filterLogger.name" />
6-
<button class="btn" title="reload list" ng-click="reload()"><i class="icon-refresh"></i></button>
7-
<span title="filtered / total" class="add-on">{{ filteredLoggers.length }}/{{ loggers.length }}</span>
8-
</div>
9-
</form>
10-
<table class="table table-hover">
11-
<tbody>
12-
<tr ng-repeat="logger in (filteredLoggers = (loggers | classNameLoggerOnly:!showPackageLoggers | filter:filterLogger) ) | limitTo: limit track by logger.name">
13-
<td>
14-
{{ logger.name }}
15-
<div class="btn-group pull-right">
16-
<label class="btn btn-small" ng-class="{'active btn-danger': logger.level== 'TRACE'}" ng-click="setLogLevel(logger.name, 'TRACE')">TRACE</label>
17-
<label class="btn btn-small" ng-class="{'active btn-warning': logger.level=='DEBUG'}" ng-click="setLogLevel(logger.name, 'DEBUG')">DEBUG</label>
18-
<label class="btn btn-small" ng-class="{'active btn-info': logger.level=='INFO'}" ng-click="setLogLevel(logger.name, 'INFO')">INFO</label>
19-
<label class="btn btn-small" ng-class="{'active btn-success': logger.level == 'WARN'}" ng-click="setLogLevel(logger.name, 'WARN')">WARN</label>
20-
<label class="btn btn-small" ng-class="{'active btn-primary': logger.level == 'ERROR'}" ng-click="setLogLevel(logger.name, 'ERROR')">ERROR</label>
21-
<label class="btn btn-small" ng-class="{'active btn-inverse': logger.level == 'OFF'}" ng-click="setLogLevel(logger.name, 'OFF')">OFF</label>
22-
</div>
23-
</td>
24-
</tr>
25-
<tr ng-show="limit < loggers.length" >
26-
<td>
27-
<button class="btn btn-link btn-block" ng-click="limit = limit + 10">show more</button>
28-
</td>
29-
</tr>
30-
<tr ng-show="limit < loggers.length" >
31-
<td>
32-
<button class="btn btn-link btn-block" ng-click="limit = loggers.length">show all</button>
33-
</td>
34-
</tr>
35-
</tbody>
36-
</table>
2+
<div ng-if="errorWhileListing">
3+
<p>To make the logging section work you need to make the /jolokia-endpoint accessible.<br/>
4+
Include the jolokia-core.jar in your spring-boot-application:
5+
<pre>&lt;dependency&gt;
6+
&lt;groupId>org.jolokia&lt;/groupId&gt;
7+
&lt;artifactId>jolokia-core&lt;/artifactId&gt;
8+
&lt;/dependency&gt;</pre></p>
9+
<p>Please note that the logging section currently only works with Logback.<br/>
10+
To make the section work with Logback please activate the JMXConfigurator in your <b>logback.xml</b>:
11+
<pre>&lt;configuration&gt;
12+
&lt;include resource="org/springframework/boot/logging/logback/base.xml"/&gt;
13+
&lt;jmxConfigurator/&gt;
14+
&lt;/configuration&gt;</pre></p>
15+
</div>
16+
<pre class="alert alert-error" ng-if="error"><b>Error:</b><br/>{{ error | json }}</pre>
17+
<div ng-show="loggers">
18+
<form ng-init="showPackageLoggers = false">
19+
<div class="input-prepend input-append">
20+
<button class="btn" title="Show package-level loggers" ng-class="{'btn-inverse': showPackageLoggers}" ng-model="showPackageLoggers" btn-checkbox ><i class="icon-folder-open" ng-class="{'icon-white': showPackageLoggers}"></i></button>
21+
<input placeholder="Filter by name ..." class="span10" type="search" ng-model="filterLogger.name" />
22+
<button class="btn" title="reload list" ng-click="reload()"><i class="icon-refresh"></i></button>
23+
<span title="filtered / total" class="add-on">{{ filteredLoggers.length }}/{{ loggers.length }}</span>
24+
</div>
25+
</form>
26+
<table class="table table-hover">
27+
<tbody>
28+
<tr ng-repeat="logger in (filteredLoggers = (loggers | classNameLoggerOnly:!showPackageLoggers | filter:filterLogger) ) | limitTo: limit track by logger.name">
29+
<td>
30+
{{ logger.name }}
31+
<div class="btn-group pull-right">
32+
<label class="btn btn-small" ng-class="{'active btn-danger': logger.level== 'TRACE'}" ng-click="setLogLevel(logger.name, 'TRACE')">TRACE</label>
33+
<label class="btn btn-small" ng-class="{'active btn-warning': logger.level=='DEBUG'}" ng-click="setLogLevel(logger.name, 'DEBUG')">DEBUG</label>
34+
<label class="btn btn-small" ng-class="{'active btn-info': logger.level=='INFO'}" ng-click="setLogLevel(logger.name, 'INFO')">INFO</label>
35+
<label class="btn btn-small" ng-class="{'active btn-success': logger.level == 'WARN'}" ng-click="setLogLevel(logger.name, 'WARN')">WARN</label>
36+
<label class="btn btn-small" ng-class="{'active btn-primary': logger.level == 'ERROR'}" ng-click="setLogLevel(logger.name, 'ERROR')">ERROR</label>
37+
<label class="btn btn-small" ng-class="{'active btn-inverse': logger.level == 'OFF'}" ng-click="setLogLevel(logger.name, 'OFF')">OFF</label>
38+
</div>
39+
</td>
40+
</tr>
41+
<tr ng-show="limit < loggers.length" >
42+
<td>
43+
<button class="btn btn-link btn-block" ng-click="limit = limit + 10">show more</button>
44+
</td>
45+
</tr>
46+
<tr ng-show="limit < loggers.length" >
47+
<td>
48+
<button class="btn btn-link btn-block" ng-click="limit = loggers.length">show all</button>
49+
</td>
50+
</tr>
51+
</tbody>
52+
</table>
53+
</div>
3754
</div>

0 commit comments

Comments
 (0)