Commit 97335237 by Johannes Edmeier

Don't read /configprops for detecting endpoints

Detecect endpoints by making a HEAD request instead of querying the configprops since it is broken when having a second applicationContext
parent e93935bb
...@@ -15,10 +15,15 @@ ...@@ -15,10 +15,15 @@
*/ */
'use strict'; 'use strict';
module.exports = function ($scope, application) { module.exports = function ($scope, $http, application) {
'ngInject'; 'ngInject';
$scope.application = application; $scope.application = application;
$scope.refreshSupported = false;
$http.head('api/applications/' + application.id + '/refresh').catch(function (response) {
$scope.refreshSupported = response.status === 405; //If method not allowed is returned the endpoint is present.
});
var toArray = function (obj) { var toArray = function (obj) {
return Object.getOwnPropertyNames(obj).map(function (key) { return Object.getOwnPropertyNames(obj).map(function (key) {
...@@ -38,8 +43,7 @@ module.exports = function ($scope, application) { ...@@ -38,8 +43,7 @@ module.exports = function ($scope, application) {
var env = response.data; var env = response.data;
$scope.profiles = env.profiles; $scope.profiles = env.profiles;
delete env.profiles; delete env.profiles;
$scope.env = toArray(env); // to get the env-sources in correct $scope.env = toArray(env); // to get the env-sources in correct order we have to convert to an array
// order we have to convert to an array
}).catch(function (response) { }).catch(function (response) {
$scope.error = response.data; $scope.error = response.data;
}); });
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</table> </table>
</sba-info-panel> </sba-info-panel>
<sba-info-panel panel-title="Environment manager" ng-show="application.capabilities.refresh"> <sba-info-panel panel-title="Environment manager" ng-show="refreshSupported">
<sba-environment-manager environment="env" application="application" on-environment-changed="refresh"></sba-environment-manager> <sba-environment-manager environment="env" application="application" on-environment-changed="refresh"></sba-environment-manager>
</sba-info-panel> </sba-info-panel>
......
...@@ -19,9 +19,5 @@ module.exports = function ($scope, application, ApplicationViews) { ...@@ -19,9 +19,5 @@ module.exports = function ($scope, application, ApplicationViews) {
'ngInject'; 'ngInject';
$scope.application = application; $scope.application = application;
if (!application.capablities) {
application.getCapabilities();
}
$scope.views = ApplicationViews.getApplicationViews(application); $scope.views = ApplicationViews.getApplicationViews(application);
}; };
...@@ -67,6 +67,23 @@ module.run(function ($rootScope, $state, $filter, $sce, $http, Notification, App ...@@ -67,6 +67,23 @@ module.run(function ($rootScope, $state, $filter, $sce, $http, Notification, App
}); });
ApplicationViews.register({ ApplicationViews.register({
order: 1,
title: $sce.trustAsHtml('<i class="fa fa-file-text-o fa-fw"></i>Log'),
href: '/api/applications/{id}/logfile',
target: '_blank',
show: function (application) {
if (!application.managementUrl || !application.statusInfo.status || application.statusInfo.status === 'OFFLINE') {
return false;
}
return $http.head('api/applications/' + application.id + '/logfile').then(function () {
return true;
}).catch(function () {
return false;
});
}
});
ApplicationViews.register({
order: 110, order: 110,
title: $sce.trustAsHtml('<i class="fa fa-cubes fa-fw"></i>Heapdump'), title: $sce.trustAsHtml('<i class="fa fa-cubes fa-fw"></i>Heapdump'),
href: '/api/applications/{id}/heapdump', href: '/api/applications/{id}/heapdump',
...@@ -97,7 +114,6 @@ module.run(function ($rootScope, $state, $filter, $sce, $http, Notification, App ...@@ -97,7 +114,6 @@ module.run(function ($rootScope, $state, $filter, $sce, $http, Notification, App
var refresh = function (application) { var refresh = function (application) {
application.info = {}; application.info = {};
application.refreshing = true; application.refreshing = true;
application.getCapabilities();
application.getInfo().then(function (response) { application.getInfo().then(function (response) {
var info = response.data; var info = response.data;
application.version = info.version; application.version = info.version;
......
...@@ -18,14 +18,6 @@ ...@@ -18,14 +18,6 @@
module.exports = function ($resource, $http) { module.exports = function ($resource, $http) {
'ngInject'; 'ngInject';
var isEndpointPresent = function (endpoint, configprops) {
if (configprops[endpoint]) {
return true;
} else {
return false;
}
};
var Application = $resource('api/applications/:id', { var Application = $resource('api/applications/:id', {
id: '@id' id: '@id'
}, { }, {
...@@ -52,23 +44,6 @@ module.exports = function ($resource, $http) { ...@@ -52,23 +44,6 @@ module.exports = function ($resource, $http) {
return response; return response;
}; };
Application.prototype.getCapabilities = function () {
var application = this;
this.capabilities = {};
if (this.managementUrl) {
$http.get('api/applications/' + application.id + '/configprops').then(
function (response) {
application.capabilities.refresh = isEndpointPresent('refreshEndpoint',
response.data);
});
$http.head('api/applications/' + application.id + '/logfile').then(function () {
application.capabilities.logfile = true;
}).catch(function () {
application.capabilities.logfile = false;
});
}
};
Application.prototype.getHealth = function () { Application.prototype.getHealth = function () {
return $http.get('api/applications/' + this.id + '/health').then(convert); return $http.get('api/applications/' + this.id + '/health').then(convert);
}; };
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
<td> <td>
<div class="pull-right"> <div class="pull-right">
<div class="btn-group"> <div class="btn-group">
<a ng-if="application.capabilities.logfile && application.statusInfo.status != null && application.statusInfo.status != 'OFFLINE'" target="_blank" class="btn btn-success" ng-href="{{application.capabilities.logfile ? 'api/applications/' + application.id + '/logfile' :''}}"><i class="fa fa-file-text-o"></i> Log</a>
<a ng-if="views.length > 0" ng-href="{{views[0].href}}" target="{{views[0].target}}" class="btn btn-success" ng-bind-html="views[0].title"></a> <a ng-if="views.length > 0" ng-href="{{views[0].href}}" target="{{views[0].target}}" class="btn btn-success" ng-bind-html="views[0].title"></a>
<a class="btn btn-success dropdown-toggle" data-toggle="dropdown" ng-if="views.length > 1"> <a class="btn btn-success dropdown-toggle" data-toggle="dropdown" ng-if="views.length > 1">
<i class="fa fa-caret-down"></i> <i class="fa fa-caret-down"></i>
......
...@@ -52,9 +52,8 @@ public class ApplicationRouteLocator implements RefreshableRouteLocator { ...@@ -52,9 +52,8 @@ public class ApplicationRouteLocator implements RefreshableRouteLocator {
/** /**
* Endpoints to be proxified by spring boot admin. * Endpoints to be proxified by spring boot admin.
*/ */
private String[] endpoints = { "env", "metrics", "trace", "dump", "jolokia", "info", private String[] endpoints = { "env", "metrics", "trace", "dump", "jolokia", "info", "trace",
"configprops", "trace", "activiti", "logfile", "refresh", "flyway", "liquibase", "activiti", "logfile", "refresh", "flyway", "liquibase", "heapdump" };
"heapdump" };
public ApplicationRouteLocator(String servletPath, ApplicationRegistry registry, public ApplicationRouteLocator(String servletPath, ApplicationRegistry registry,
String prefix) { String prefix) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment