/
AdminServerUiProperties.java
156 lines (126 loc) · 4.16 KB
/
AdminServerUiProperties.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.codecentric.boot.admin.server.ui.config;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.convert.DurationUnit;
import org.springframework.http.CacheControl;
import de.codecentric.boot.admin.server.ui.web.UiController;
@lombok.Data
@ConfigurationProperties("spring.boot.admin.ui")
public class AdminServerUiProperties {
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = { "classpath:/META-INF/spring-boot-admin-server-ui/" };
private static final String[] CLASSPATH_EXTENSION_RESOURCE_LOCATIONS = {
"classpath:/META-INF/spring-boot-admin-server-ui/extensions/" };
/**
* Locations of SBA ui resources.
*/
private String[] resourceLocations = CLASSPATH_RESOURCE_LOCATIONS;
/**
* Locations of SBA ui exentsion resources.
*/
private String[] extensionResourceLocations = CLASSPATH_EXTENSION_RESOURCE_LOCATIONS;
/**
* Locations of SBA ui template.
*/
private String templateLocation = CLASSPATH_RESOURCE_LOCATIONS[0];
/**
* Icon used as image on login page
*/
private String loginIcon = "assets/img/icon-spring-boot-admin.svg";
/**
* Icon used as default favicon and icon for desktop notifications.
*/
private String favicon = "assets/img/favicon.png";
/**
* Icon used as default favicon and icon for desktop notifications.
*/
private String faviconDanger = "assets/img/favicon-danger.png";
/**
* 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>";
/**
* If running behind a reverse proxy (using path rewriting) this can be used to output
* correct self references. If the host/port is omitted it will be inferred from the
* request.
*/
@Nullable
private String publicUrl = null;
/**
* Wether the thymeleaf templates should be cached.
*/
private boolean cacheTemplates = true;
/**
* Cache-Http-Header settings.
*/
private Cache cache = new Cache();
/**
* External views shown in the navbar.
*/
private List<UiController.ExternalView> externalViews = new ArrayList<>();
/**
* External views shown in the navbar.
*/
private List<UiController.ViewSettings> viewSettings = new ArrayList<>();
/**
* Whether the option to remember a user should be available.
*/
private boolean rememberMeEnabled = true;
/**
* Limit languages to this list. Intersection of all supported languages and this list
* will be used.
*/
private List<String> availableLanguages = new ArrayList<>();
@lombok.Data
public static class Cache {
/**
* include "max-age" directive in Cache-Control http header.
*/
@Nullable
@DurationUnit(ChronoUnit.SECONDS)
private Duration maxAge = Duration.ofSeconds(3600);
/**
* include "no-cache" directive in Cache-Control http header.
*/
private Boolean noCache = false;
/**
* include "no-store" directive in Cache-Control http header.
*/
private Boolean noStore = false;
public CacheControl toCacheControl() {
if (Boolean.TRUE.equals(this.noStore)) {
return CacheControl.noStore();
}
if (Boolean.TRUE.equals(this.noCache)) {
return CacheControl.noCache();
}
if (this.maxAge != null) {
return CacheControl.maxAge(this.maxAge.getSeconds(), TimeUnit.SECONDS);
}
return CacheControl.empty();
}
}
}