Skip to content

Commit f660f29

Browse files
committed
Polish contribution
1 parent a811f3e commit f660f29

File tree

9 files changed

+45
-37
lines changed

9 files changed

+45
-37
lines changed

spring-boot-admin-docs/src/main/asciidoc/customizing.adoc

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,11 @@ or you must ensure yourself that the image gets served correctly (e.g. by regist
9696

9797
- **spring.boot.admin.ui.title**: Use this option to customize the browsers window title.
9898

99-
=== Customizing Page Favicon ===
100-
You can show custom browser favicon by using following configuration properties:
99+
=== Customizing Favicon ===
100+
It is possible to use a custom favicon, which is also used for desktop notifications. Spring Boot Admin uses a different icon when one or more application is down.
101101

102-
- **spring.boot.admin.ui.faviconBase**: Sets default icon, that is shown when all services are up.
103-
104-
- **spring.boot.admin.ui.faviconDanger**: Sets alerting icon that is shown when 1 or more services are down.
105-
106-
In first place you need get the icon of min 32x32 pixels in `.png` of `.ico` format - you can use one of online favicon generators for this).
107-
You should place the file into the assets folder of the ui subproject `/META-INF/spring-boot-admin-server-ui/assets/`.
108-
Then property should include path from root of the `/META-INF/spring-boot-admin-server-ui/` for example `assets/img/company-favicon.png`.
102+
1. Put the favicon (`.png` with at least 192x192 pixels) in a resource location which is served via http (e.g. `/META-INF/spring-boot-admin-server-ui/assets/img/`).
109103

104+
2. Configure the icons to use using the following properties:
105+
- `spring.boot.admin.ui.favicon`: Used as default icon. (e.g `assets/img/custom-favicon.png`
106+
- `spring.boot.admin.ui.favicon-danger`: Used when one or more service is down. (e.g `assets/img/custom-favicon-danger.png`)

spring-boot-admin-docs/src/main/asciidoc/server.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ In addition when the reverse proxy terminates the https connection, it may be ne
6363
| Page-Title to be shown.
6464
| `"Spring Boot Admin"`
6565

66-
| spring.boot.admin.ui.faviconBase
67-
| Custom favicon when all services are up
66+
| spring.boot.admin.ui.favicon
67+
| Icon used as default favicon and icon for desktop notifications.
6868
| `"assets/img/favicon.png"`
6969

70-
| spring.boot.admin.ui.faviconDanger
71-
| Custom favicon when one or more services is down
70+
| spring.boot.admin.ui.favicon-danger
71+
| Icon used as favicon when one or more service is down and for desktop notifications.
7272
| `"assets/img/favicon-danger.png"`
7373

7474
|===

spring-boot-admin-server-ui/src/main/frontend/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
~ Copyright 2014-2018 the original author or authors.
2+
~ Copyright 2014-2019 the original author or authors.
33
~
44
~ Licensed under the Apache License, Version 2.0 (the "License");
55
~ you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@
3535
<link th:href="${cssFile.resourcePath}" rel="stylesheet">
3636
</th:block>
3737

38-
<link rel="shortcut icon" href="assets/img/favicon.png" type="image/png">
38+
<link rel="shortcut icon" th:href="${uiSettings.favicon}" type="image/png">
3939
<title th:text="${uiSettings.title}">Spring Boot Admin</title>
4040
</head>
4141
<body>

spring-boot-admin-server-ui/src/main/frontend/login.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
~ Copyright 2014-2018 the original author or authors.
2+
~ Copyright 2014-2019 the original author or authors.
33
~
44
~ Licensed under the Apache License, Version 2.0 (the "License");
55
~ you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@
2323
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
2424
<meta name="format-detection" content="telephone=no,email=no">
2525
<meta name="theme-color" content="#42d3a5">
26-
<link rel="shortcut icon" href="assets/img/favicon.png" type="image/png">
26+
<link rel="shortcut icon" th:href="${uiSettings.favicon}" type="image/png">
2727
<title th:text="${uiSettings.title}">Spring Boot Admin - Login</title>
2828
</head>
2929
<body class="login">

spring-boot-admin-server-ui/src/main/frontend/notifications.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2018 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,6 +19,20 @@ import values from 'lodash/values';
1919

2020
let granted = false;
2121

22+
const config = {
23+
favicon: 'assets/img/favicon.png',
24+
faviconDanger: 'assets/img/favicon-danger.png',
25+
};
26+
27+
if (global.SBA && global.SBA.uiSettings) {
28+
if (global.SBA.uiSettings.favicon) {
29+
config.favicon = global.SBA.uiSettings.favicon
30+
}
31+
if (global.SBA.uiSettings.faviconDanger) {
32+
config.faviconDanger = global.SBA.uiSettings.faviconDanger
33+
}
34+
}
35+
2236
const requestPermissions = async () => {
2337
if ('Notification' in window) {
2438
granted = (window.Notification.permission === 'granted');
@@ -34,7 +48,7 @@ const notifyForSingleChange = (application, oldApplication) => {
3448
tag: `${application.name}-${application.status}`,
3549
lang: 'en',
3650
body: `was ${oldApplication.status}.`,
37-
icon: application.status === 'UP' ? 'assets/img/favicon.png' : 'assets/img/favicon-danger.png',
51+
icon: application.status === 'UP' ? config.favicon : config.faviconDanger,
3852
renotify: true,
3953
timeout: 5000
4054
});
@@ -44,7 +58,7 @@ const notifyForBulkChange = ({count, status, oldStatus}) => {
4458
return createNotification(`${count} applications are now ${status}`, {
4559
lang: 'en',
4660
body: `was ${oldStatus}.`,
47-
icon: status === 'UP' ? 'assets/img/favicon.png' : 'assets/img/favicon-danger.png',
61+
icon: status === 'UP' ? config.favicon : config.faviconDanger,
4862
timeout: 5000
4963
});
5064
};

spring-boot-admin-server-ui/src/main/frontend/views/applications/handle.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
- Copyright 2014-2018 the original author or authors.
2+
- Copyright 2014-2019 the original author or authors.
33
-
44
- Licensed under the Apache License, Version 2.0 (the "License");
55
- you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@
2828
<script>
2929
export default {
3030
data: () => ({
31-
faviconBase: 'assets/img/favicon.png',
31+
favicon: 'assets/img/favicon.png',
3232
faviconDanger: 'assets/img/favicon-danger.png',
3333
}),
3434
props: {
@@ -51,7 +51,7 @@
5151
created() {
5252
if (global.SBA && global.SBA.uiSettings) {
5353
if (global.SBA.uiSettings.favicon) {
54-
this.faviconBase = global.SBA.uiSettings.faviconBase
54+
this.favicon = global.SBA.uiSettings.favicon
5555
}
5656
if (global.SBA.uiSettings.faviconDanger) {
5757
this.faviconDanger = global.SBA.uiSettings.faviconDanger
@@ -67,7 +67,7 @@
6767
},
6868
methods: {
6969
updateFavicon(up) {
70-
document.querySelector('link[rel*="icon"]').href = up ? this.faviconBase : this.faviconDanger;
70+
document.querySelector('link[rel*="icon"]').href = up ? this.favicon : this.faviconDanger;
7171
}
7272
}
7373
};

spring-boot-admin-server-ui/src/main/java/de/codecentric/boot/admin/server/ui/config/AdminServerUiAutoConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2018 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -69,7 +69,7 @@ public UiController homeUiController() throws IOException {
6969
null ? this.uiProperties.getPublicUrl() : this.adminServerProperties.getContextPath(),
7070
this.uiProperties.getTitle(),
7171
this.uiProperties.getBrand(),
72-
this.uiProperties.getFaviconBase(),
72+
this.uiProperties.getFavicon(),
7373
this.uiProperties.getFaviconDanger(),
7474
this.uiExtensions(),
7575
!this.applicationContext.getBeansOfType(NotificationFilterController.class).isEmpty()

spring-boot-admin-server-ui/src/main/java/de/codecentric/boot/admin/server/ui/config/AdminServerUiProperties.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2018 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -46,14 +46,14 @@ public class AdminServerUiProperties {
4646
private String templateLocation = CLASSPATH_RESOURCE_LOCATIONS[0];
4747

4848
/**
49-
* Custom favicon. When all services are up
49+
* Icon used as default favicon and icon for desktop notifications.
5050
*/
51-
private String faviconBase = null;
51+
private String favicon = "assets/img/favicon.png";
5252

5353
/**
54-
* Custom favicon. When one or more services is down
54+
* Icon used as default favicon and icon for desktop notifications.
5555
*/
56-
private String faviconDanger = null;
56+
private String faviconDanger = "assets/img/favicon-danger.png";
5757

5858
/**
5959
* Page-Title to be shown.

spring-boot-admin-server-ui/src/main/java/de/codecentric/boot/admin/server/ui/web/UiController.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2018 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -41,18 +41,15 @@ public class UiController {
4141
private final List<UiExtension> jsExtensions;
4242
private final Map<String, Object> uiSettings;
4343

44-
public UiController(String publicUrl,
45-
String title,
46-
String brand,
47-
String faviconBase,
44+
public UiController(String publicUrl, String title, String brand, String favicon,
4845
String faviconDanger,
4946
List<UiExtension> uiExtensions,
5047
boolean notificationFilterEnabled) {
5148
this.publicUrl = publicUrl;
5249
this.uiSettings = new HashMap<>();
5350
this.uiSettings.put("title", title);
5451
this.uiSettings.put("brand", brand);
55-
this.uiSettings.put("faviconBase", faviconBase);
52+
this.uiSettings.put("favicon", favicon);
5653
this.uiSettings.put("faviconDanger", faviconDanger);
5754
this.uiSettings.put("notificationFilterEnabled", notificationFilterEnabled);
5855
this.cssExtensions = uiExtensions.stream()

0 commit comments

Comments
 (0)