Skip to content

Commit 5d38b5d

Browse files
committed
Show environment in top bar (if defined)
1 parent 2170db6 commit 5d38b5d

File tree

6 files changed

+33
-7
lines changed

6 files changed

+33
-7
lines changed

src/main/kotlin/com/faforever/userservice/config/FafProperties.kt

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import javax.validation.constraints.NotBlank
99
@Validated
1010
@ConstructorBinding
1111
data class FafProperties(
12+
val environment: String?,
1213
@NotBlank
1314
val passwordResetUrl: String,
1415
@NotBlank
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.faforever.userservice.config
2+
3+
import org.springframework.beans.factory.annotation.Autowired
4+
import org.springframework.context.annotation.Bean
5+
import org.springframework.context.annotation.Configuration
6+
import org.thymeleaf.spring5.view.reactive.ThymeleafReactiveViewResolver
7+
8+
@Configuration
9+
class ThymeleafConfig {
10+
@Autowired
11+
private lateinit var thymeleafViewResolver: ThymeleafReactiveViewResolver
12+
13+
@Autowired
14+
private lateinit var fafProperties: FafProperties
15+
16+
@Bean
17+
fun staticVariableProvider() {
18+
val map = mutableMapOf<String, Any>()
19+
map["environment"] = fafProperties.environment?.let { "[$it] " } ?: ""
20+
thymeleafViewResolver.staticVariables = map
21+
}
22+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
faf:
2+
environment: LOCAL
3+
4+
logging:
5+
level:
6+
org.springframework.security: INFO
7+
com.faforever: INFO
8+
org.thymeleaf: INFO

src/main/resources/application.yml

-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ hydra:
2222
fakeTlsForwarding: ${HYDRA_FAKE_TLS_FORWARDING:false}
2323
acceptUntrustedTlsCertificates: ${HYDRA_ACCEPT_UNTRUSTED_TLS_CERTIFICATES:true}
2424

25-
logging:
26-
level:
27-
org.springframework.security: INFO
28-
com.faforever: INFO
29-
3025
spring:
3126
r2dbc:
3227
url: ${DB_R2DBC_URL:r2dbc:pool:mysql://localhost:3306/faf?ssl=false}

src/main/resources/templates/layout/card.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<body>
66
<div class="background"></div>
77
<header>
8-
<h1 th:text="${headerText}" layout:fragment="header-title">FAForever</h1>
8+
<h1 th:text="${environment} + ${headerText}" layout:fragment="header-title">[ENV] FAForever</h1>
99
</header>
1010
<div layout:fragment="content">
1111
<div class="main-card">

src/main/resources/templates/layout/default.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<div id="leftheader">
1818
<a href="https://www.faforever.com"><img src="https://faforever.com/images/faf-logo.png"
1919
alt="FAForever Logo"></a>
20-
<h1 th:text="#{title}" layout:fragment="header-title">FAForever</h1>
20+
<h1 th:text="${environment} + #{title}" layout:fragment="header-title">[ENV] FAForever</h1>
2121
</div>
2222
<div id="rightheader">
2323
<p th:if="${currentUser != null}" th:text="#{header.loggedInAs(${currentUser.username})}">You are logged in as [User]</p>

0 commit comments

Comments
 (0)