Commit 44b6acec by Thomas Bosch

CSS

parent e0e201d2
...@@ -5,8 +5,7 @@ ...@@ -5,8 +5,7 @@
<artifactId>spring-boot-admin</artifactId> <artifactId>spring-boot-admin</artifactId>
<version>1.0.0-RC1</version> <version>1.0.0-RC1</version>
<properties> <properties>
<spring-boot.version>1.0.2.RELEASE</spring-boot.version> <spring-boot.version>1.1.0.RELEASE</spring-boot.version>
<spring.version>4.0.3.RELEASE</spring.version>
<bootstrap.version>2.3.2</bootstrap.version> <bootstrap.version>2.3.2</bootstrap.version>
<jquery.version>1.11.0</jquery.version> <jquery.version>1.11.0</jquery.version>
<angularjs.version>1.2.12</angularjs.version> <angularjs.version>1.2.12</angularjs.version>
...@@ -61,12 +60,6 @@ ...@@ -61,12 +60,6 @@
<version>4.10</version> <version>4.10</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<repositories> <repositories>
<repository> <repository>
......
...@@ -2,12 +2,14 @@ package de.codecentric.boot.admin; ...@@ -2,12 +2,14 @@ package de.codecentric.boot.admin;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import de.codecentric.boot.admin.config.WebappConfig;
@Configuration @Configuration
@EnableAutoConfiguration @EnableAutoConfiguration
@ComponentScan @Import(WebappConfig.class)
public class SpringBootAdmin { public class SpringBootAdmin {
public static void main(String[] args) { public static void main(String[] args) {
......
...@@ -2,13 +2,15 @@ package de.codecentric.boot.admin.config; ...@@ -2,13 +2,15 @@ package de.codecentric.boot.admin.config;
import java.util.List; import java.util.List;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import de.codecentric.boot.admin.controller.RegistryController;
import de.codecentric.boot.admin.service.ApplicationRegistry;
@Configuration @Configuration
public class WebappConfig extends WebMvcConfigurerAdapter { public class WebappConfig extends WebMvcConfigurerAdapter {
...@@ -17,12 +19,14 @@ public class WebappConfig extends WebMvcConfigurerAdapter { ...@@ -17,12 +19,14 @@ public class WebappConfig extends WebMvcConfigurerAdapter {
converters.add(new MappingJackson2HttpMessageConverter()); converters.add(new MappingJackson2HttpMessageConverter());
} }
@Controller @Bean
static class Routes { public RegistryController registryController() {
@RequestMapping({ "/applications", "/applications/{id:\\w+}" }) return new RegistryController();
public String index() {
return "/index.html";
} }
@Bean
public ApplicationRegistry applicationRegistry() {
return new ApplicationRegistry();
} }
} }
'use strict'; 'use strict';
angular.module('springBootAdmin') angular.module('springBootAdmin')
.controller('overviewCtrl', function ($scope, Applications, ApplicationOverview, $location) { .controller('overviewCtrl', function ($scope, Applications, Application, ApplicationOverview, $location) {
$scope.applications = Applications.query({}, function(applications) { $scope.applications = Applications.query({}, function(applications) {
for (var i = 0; i < applications.length; i++) { for (var i = 0; i < applications.length; i++) {
var app = applications[i]; var app = applications[i];
...@@ -13,6 +13,12 @@ angular.module('springBootAdmin') ...@@ -13,6 +13,12 @@ angular.module('springBootAdmin')
$scope.showDetails = function(id) { $scope.showDetails = function(id) {
$location.path('/apps/details/' + id + '/infos'); $location.path('/apps/details/' + id + '/infos');
}; };
// callback for ng-click 'refresh':
$scope.refresh = function(id) {
$scope.application = Application.query({id: id}, function(application) {
ApplicationOverview.refresh(application);
});
};
}) })
.controller('navCtrl', function ($scope, $location) { .controller('navCtrl', function ($scope, $location) {
$scope.navClass = function(page) { $scope.navClass = function(page) {
......
...@@ -25,15 +25,20 @@ angular.module('springBootAdmin.services', ['ngResource']) ...@@ -25,15 +25,20 @@ angular.module('springBootAdmin.services', ['ngResource'])
} }
this.getHealth = function(app) { this.getHealth = function(app) {
return $http.get(app.url + '/health').success(function(response) { return $http.get(app.url + '/health').success(function(response) {
if (response.indexOf('ok') != -1 || response.status.indexOf('ok') != -1) { if (typeof(response) === 'string' && response.indexOf('ok') != -1
app.status = 'online'; || typeof(response.status) === 'string' &&
(response.status.indexOf('ok') != -1 || response.status.indexOf('UP') != -1)) {
app.online = true;
} else { } else {
app.status = 'offline'; app.online = false;
} }
}).error(function() { }).error(function() {
app.status = 'offline'; app.online = false;
}); });
} }
this.refresh = function(app) {
return $http.post(app.url + '/refresh');
};
}]) }])
.service('ApplicationDetails', ['$http', function($http) { .service('ApplicationDetails', ['$http', function($http) {
this.getInfo = function(app) { this.getInfo = function(app) {
......
...@@ -48,3 +48,12 @@ a.spring-boot-logo span { ...@@ -48,3 +48,12 @@ a.spring-boot-logo span {
a:hover.spring-boot-logo span { a:hover.spring-boot-logo span {
opacity: 1; opacity: 1;
} }
span.online {
color: #00AA00;
}
span.offline {
color: #DD0000;
font-weight: bold;
}
\ No newline at end of file
...@@ -14,19 +14,19 @@ ...@@ -14,19 +14,19 @@
<th>Version</th> <th>Version</th>
<th>Status</th> <th>Status</th>
<th></th> <th></th>
<th></th>
<th></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr ng-repeat="application in applications"> <tr ng-repeat="application in applications">
<td>{{ application.id }}</td> <td>{{ application.id }}</td>
<td>{{ application.version }}</td> <td>{{ application.version }}</td>
<td>{{ application.status }}</td>
<td></td>
<td></td>
<td> <td>
<span ng-show="application.online" class="online">online</span>
<span ng-show="!application.online" class="offline">offline</span>
</td>
<td align="right">
<button type="button" ng-click="showDetails(application.id)" class="btn btn-success">Details</button> <button type="button" ng-click="showDetails(application.id)" class="btn btn-success">Details</button>
<!-- <button type="button" ng-click="refresh(application.id)" class="btn btn-success">Refresh</button> -->
</td> </td>
</tr> </tr>
</tbody> </tbody>
......
package de.codecentric.boot.admin;
import org.springframework.web.client.RestTemplate;
import de.codecentric.boot.admin.model.Application;
public class RegisterExampleApp {
public static void main(String[] args) {
RestTemplate template = new RestTemplate();
Application app = new Application();
app.setId("app");
app.setUrl("http://localhost:8081");
template.postForObject("http://localhost:8080/api/applications", app, String.class);
}
}
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