Commit d9a76934 by Thomas Bosch

get single app

parent c5428c53
......@@ -32,6 +32,13 @@ public class RegistryController {
registry.register(app);
}
@RequestMapping(value = "/api/application", method = RequestMethod.GET)
@ResponseBody
public Application get(@RequestBody String id) {
LOGGER.debug("Deliver registered application with ID '{}'", id);
return registry.getApplication(id);
}
@RequestMapping(value = "/api/applications", method = RequestMethod.GET)
@ResponseBody
public List<Application> applications() {
......
package de.codecentric.boot.admin.service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.Validate;
import org.springframework.stereotype.Service;
......@@ -15,7 +16,7 @@ import de.codecentric.boot.admin.model.Application;
@Service
public class ApplicationRegistry {
private final List<Application> registry = new ArrayList<>();
private final Map<String, Application> registry = new HashMap<>();
/**
* Register application.
......@@ -27,18 +28,18 @@ public class ApplicationRegistry {
Validate.notNull(app, "Application must not be null");
Validate.notNull(app.getId(), "Application ID must not be null");
Validate.notNull(app.getUrl(), "Application URL must not be null");
registry.add(app);
registry.put(app.getId(), app);
}
/**
* Checks, if an application is already registerd.
*
* @param app
* The application.
* @param id
* The application ID.
* @return exists?
*/
public boolean isRegistered(Application app) {
return registry.contains(app);
public boolean isRegistered(String id) {
return registry.containsKey(id);
}
/**
......@@ -47,7 +48,21 @@ public class ApplicationRegistry {
* @return List.
*/
public List<Application> getApplications() {
return Collections.unmodifiableList(registry);
return new ArrayList<>(registry.values());
}
/**
* Get a specific application inside the registry.
*
* @param id
* Id.
* @return Application.
*/
public Application getApplication(String id) {
if (!isRegistered(id)) {
throw new IllegalArgumentException("Application with ID " + id + " is not registered");
}
return registry.get(id);
}
}
......@@ -29,11 +29,12 @@ angular.module('springBootAdmin', [
templateUrl: 'views/apps/details.html'
})
.state('apps.details.infos', {
url: '/infos',
templateUrl: 'views/apps/details/infos.html'
url: '/infos/{id}',
templateUrl: 'views/apps/details/infos.html',
controller: 'infosCtrl'
})
.state('apps.details.metrics', {
url: '/metrics',
url: '/metrics/{id}',
templateUrl: 'views/apps/details/metrics.html'
});
})
......
'use strict';
angular.module('springBootAdmin')
.controller('overviewCtrl', function ($scope, Application, ApplicationInfo, $location, $http) {
// Gets the service from /api/services
$scope.applications = Application.query({}, function(applications) {
// Get details from applications
for (var i = 0; i < applications.length; i++) {
var app = applications[i];
ApplicationInfo.getInfo(app);
ApplicationInfo.getHealth(app);
}
.controller('overviewCtrl', function ($scope, Applications, ApplicationInfo, $location, $http) {
$scope.applications = Applications.query({}, function(applications) {
for (var i = 0; i < applications.length; i++) {
var app = applications[i];
ApplicationInfo.getInfo(app);
ApplicationInfo.getHealth(app);
}
});
})
.controller('navCtrl', function ($scope, $location) {
$scope.navClass = function(page) {
......@@ -20,6 +16,8 @@ angular.module('springBootAdmin')
return page == currentRoute ? 'active' : '';
};
})
.controller('metricsCtrl', function ($scope, $location) {
.controller('infosCtrl', function ($scope, Application, ApplicationInfo) {
$scope.application = Application.query({}, function(application) {
ApplicationInfo.getInfo(application);
});
});
\ No newline at end of file
'use strict';
angular.module('springBootAdmin.services', ['ngResource'])
.factory('Application', ['$resource',
function($resource){
return $resource(
.factory('Applications', ['$resource',
function($resource){
return $resource(
'/api/applications', {}, {
query: { method:'GET', isArray:true }
});
}])
}
])
.factory('Application', ['$resource',
function($resource){
return $resource(
'/api/application', {}, {
query: { method:'GET', isArray:true }
});
}
])
.service('ApplicationInfo', ['$http',
function($http){
this.getInfo = function(app) {
......
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