Skip to content

Commit

Permalink
Add customization for navbar and title
Browse files Browse the repository at this point in the history
Using spring.boot.admin.ui.title/spring.boot.admin.ui.brand you can
customise the page title and logo/title shown in the navbar

closes #212
  • Loading branch information
dickerpulli authored and joshiste committed Jun 13, 2018
1 parent d7712b2 commit b247a82
Show file tree
Hide file tree
Showing 24 changed files with 85 additions and 37 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ Spring, Spring Boot and Spring Cloud are trademarks of [Pivotal Software, Inc.](
![Screenshot traces](/images/screenshot-trace.png)
*View http request traces*

![Screenshot hystrix](/images/screenshot-hystrix.png)
*View Hystrix dashboard*

![Screenshot journal](/images/screenshot-journal.png)
*View history of registered applications*

Expand Down
Binary file modified images/screenshot-details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/screenshot-environment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/screenshot-hystrix.png
Binary file not shown.
Binary file modified images/screenshot-jmx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/screenshot-journal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/screenshot-logfile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/screenshot-logging.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/screenshot-metrics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/screenshot-threads.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/screenshot-trace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions spring-boot-admin-docs/src/main/asciidoc/server.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
| Headers not to be forwarded when making requests to clients.
| `"Cookie", "Set-Cookie", "Authorization"

| spring.boot.admin.ui.brand
| Brand to be shown in then navbar.
| `"<img src="assets/img/icon-spring-boot-admin.svg"><span>Spring Boot Admin</span>"`

| spring.boot.admin.ui.title
| Page-Title to be shown.
| `"Spring Boot Admin"`

|===

include::server-discovery.adoc[]
Expand Down
32 changes: 16 additions & 16 deletions spring-boot-admin-server-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion spring-boot-admin-server-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"babel-eslint": "^8.2.3",
"babel-jest": "^23.0.1",
"babel-loader": "^7.1.4",
"babel-plugin-lodash": "^3.3.3",
"babel-plugin-lodash": "^3.3.4",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-2": "^6.24.1",
Expand Down
7 changes: 6 additions & 1 deletion spring-boot-admin-server-ui/src/main/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@
<meta name="theme-color" content="#42d3a5">
<link rel="shortcut icon" href="assets/img/favicon.png" type="image/png">
<link href="assets/css/sba-core.css" rel="stylesheet">
<title>Spring Boot Admin</title>
<title th:text="${uiSettings.title}">Spring Boot Admin</title>
</head>
<body>

<div id="app"></div>

<script th:inline="javascript">
var SBA = {
uiSettings: /*[[${uiSettings}]]*/ {}
}
</script>
<script lang="javascript" src="assets/js/vendors.js" defer></script>
<script lang="javascript" src="assets/js/sba-core.js" defer></script>
</body>
Expand Down
1 change: 1 addition & 0 deletions spring-boot-admin-server-ui/src/main/frontend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ new Vue({
render(h) {
return h(sbaShell, {
props: {
views: this.views,
applications: this.applications,
error: this.error
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<template>
<div class="instances">
<sba-instance-header :instance="instance" :application="application" :class="headerClass"/>
<sba-instance-tabs :views="instanceViews" :instance="instance" :application="application" :class="headerClass"/>
<sba-instance-tabs :views="views" :instance="instance" :application="application" :class="headerClass"/>
<router-view v-if="instance" :instance="instance"/>
</div>
</template>
Expand All @@ -33,6 +33,10 @@
type: String,
required: true
},
views: {
type: Array,
default: () => []
},
applications: {
type: Array,
default: () => [],
Expand All @@ -49,9 +53,6 @@
application() {
return this.applications.findApplicationForInstance(this.instanceId);
},
instanceViews() {
return this.$root.views.filter(view => view.name.lastIndexOf('instance/') === 0);
},
headerClass() {
if (!this.instance) {
return '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<template>
<div id="app">
<sba-navbar :views="mainViews" :applications="applications" :error="error"/>
<router-view :applications="applications" :error="error"/>
<router-view :views="subViews" :applications="applications" :error="error"/>
</div>
</template>

Expand All @@ -26,6 +26,10 @@

export default {
props: {
views: {
type: Array,
default: () => []
},
applications: {
type: Array,
default: () => [],
Expand All @@ -38,7 +42,14 @@
components: {sbaNavbar},
computed: {
mainViews() {
return this.$root.views.filter(view => view.name.lastIndexOf('/') < 0);
return this.views.filter(view => !view.name.includes('/'))
},
activeMainViewName() {
const idx = this.$route.name.indexOf('/');
return idx < 0 ? this.$route.name : this.$route.name.substr(0, idx);
},
subViews() {
return this.views.filter(view => view.name.includes(this.activeMainViewName))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
<nav id="navigation" class="navbar is-fixed-top">
<div class="container">
<div class="navbar-brand">
<router-link class="navbar-item logo" to="/">
<img src="assets/img/icon-spring-boot-admin.svg">
<span>Spring Boot Admin</span>
</router-link>
<router-link class="navbar-item logo" to="/" v-html="brand"/>

<div class="navbar-burger burger" @click.stop="showMenu = !showMenu">
<span/>
Expand Down Expand Up @@ -52,7 +49,8 @@
<script>
export default {
data: () => ({
showMenu: false
showMenu: false,
brand: '<img src="assets/img/icon-spring-boot-admin.svg"><span>Spring Boot Admin</span>'
}),
props: {
views: {
Expand All @@ -68,6 +66,12 @@
default: null
}
},
created() {
/* global SBA */
if (SBA && SBA.uiSettings) {
this.brand = SBA.uiSettings.brand || this.brand;
}
},
mounted() {
document.documentElement.classList.add('has-navbar-fixed-top');
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public AdminServerUiAutoConfiguration(AdminServerUiProperties uiProperties,
@Bean
@ConditionalOnMissingBean
public UiController homeUiController() {
return new UiController(adminServerProperties.getContextPath());
return new UiController(adminServerProperties.getContextPath(),
uiProperties.getTitle(),
uiProperties.getBrand());
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ public class AdminServerUiProperties {
*/
private String templateLocation = CLASSPATH_RESOURCE_LOCATIONS[0];

/**
* Page-Title to be shown.
*/
private String title = "Spring Boot Admin";

/**
* Brand to be shown in then navbar.
*/
private String brand = "<img src=\"assets/img/icon-spring-boot-admin.svg\"><span>Spring Boot Admin</span>";

private boolean cacheTemplates = true;

private final Cache cache = new Cache();
Expand All @@ -55,6 +65,7 @@ public static class Cache {
* include "no-cache" directive in Cache-Control http header.
*/
private Boolean noCache = false;

/**
* include "no-store" directive in Cache-Control http header.
*/
Expand All @@ -74,5 +85,4 @@ public CacheControl toCacheControl() {
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,34 @@

import de.codecentric.boot.admin.server.web.AdminController;

import java.util.HashMap;
import java.util.Map;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;

@AdminController
public class UiController {
private final String adminContextPath;
private final Map<String, Object> uiSettings;

public UiController(String adminContextPath) {
public UiController(String adminContextPath, String title, String brand) {
this.adminContextPath = adminContextPath;
this.uiSettings = new HashMap<>();
this.uiSettings.put("title", title);
this.uiSettings.put("brand", brand);
}

@ModelAttribute(value = "adminContextPath", binding = false)
public String getAdminContextPath() {
return adminContextPath;
}

@ModelAttribute(value = "uiSettings", binding = false)
public Map<String, Object> getUiSettings() {
return uiSettings;
}

@GetMapping(path = "/", produces = MediaType.TEXT_HTML_VALUE)
public String index() {
return "index";
Expand All @@ -44,5 +55,4 @@ public String index() {
public String login() {
return "login";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ public void test_update_down_noBody() {
.thenCancel()
.verify();


StepVerifier.create(repository.find(instance.getId())).assertNext(app -> {
assertThat(app.getStatusInfo().getStatus()).isEqualTo("DOWN");
assertThat(app.getStatusInfo().getDetails()).containsEntry("status", 503)
Expand Down

0 comments on commit b247a82

Please sign in to comment.