Commit 6ff2b45c by Johannes Stelzer

add function to remove offline apps

parent 87ee9bbd
......@@ -20,10 +20,12 @@ import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import de.codecentric.boot.admin.model.Application;
......@@ -67,6 +69,18 @@ public class RegistryController {
}
/**
* Deregister an application within this admin application.
*
* @param id The application id.
*/
@ResponseStatus(value = HttpStatus.OK)
@RequestMapping(value = "/api/application/{id}", method = RequestMethod.DELETE)
public void unregister(@PathVariable String id) {
LOGGER.info("Deregister application with ID '{}'", id);
registry.unregister(id);
}
/**
* List all registered applications.
*
* @return List.
......
......@@ -100,4 +100,12 @@ public class ApplicationRegistry {
return registry.get(id);
}
/**
* Remove a specific application from registry
* @param id
*/
public void unregister(String id) {
registry.remove(id);
}
}
......@@ -16,8 +16,8 @@
'use strict';
angular.module('springBootAdmin')
.controller('overviewCtrl', ['$scope', '$location', '$interval', 'Applications', 'ApplicationOverview',
function ($scope, $location, $interval, Applications, ApplicationOverview) {
.controller('overviewCtrl', ['$scope', '$location', '$interval', 'Applications', 'ApplicationOverview', 'Application',
function ($scope, $location, $interval, Applications, ApplicationOverview, Application) {
$scope.loadData = function() {
Applications.query(function(applications) {
......@@ -36,6 +36,16 @@ angular.module('springBootAdmin')
ApplicationOverview.refresh(application);
};
$scope.remove = function(application) {
Application.remove({ id: application.id }, function () {
var index = $scope.applications.indexOf(application);
if (index > -1) {
$scope.applications.splice(index, 1);
}
});
}
// reload site every 30 seconds
var task = $interval(function() {
$scope.loadData();
......
......@@ -26,7 +26,8 @@ angular.module('springBootAdmin.services', ['ngResource'])
.factory('Application', ['$resource', function($resource) {
return $resource(
'/api/application/:id', {}, {
query: { method:'GET'}
query: { method:'GET'},
remove: {method: 'DELETE'}
});
}
])
......
......@@ -17,7 +17,7 @@
</thead>
<tbody>
<tr ng-repeat="application in applications track by application.id">
<td>{{ application.id }}</td>
<td><span title="{{application.url}}">{{ application.id }}</span></td>
<td>{{ application.version }}</td>
<td><span class="status-{{application.status}}">{{ application.status }}</span></td>
<td>
......@@ -27,6 +27,9 @@
<a ui-sref="apps.logging({id: application.id})" class="btn btn-success">Logging</a>
<a ui-sref="apps.jmx({id: application.id})" class="btn btn-success">JMX</a>
</span>
<span class="pull-right" ng-show="application.status == null || application.status != 'UP'">
<a class="btn btn-danger" ng-click="remove(application)"><i class="icon-remove icon-white"></i>Remove</a>
</span>
</td>
</tr>
</tbody>
......
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