Skip to content

Commit

Permalink
Show environment in top bar (if defined)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brutus5000 committed Jan 26, 2022
1 parent 2170db6 commit 5d38b5d
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import javax.validation.constraints.NotBlank
@Validated
@ConstructorBinding
data class FafProperties(
val environment: String?,
@NotBlank
val passwordResetUrl: String,
@NotBlank
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.faforever.userservice.config

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.thymeleaf.spring5.view.reactive.ThymeleafReactiveViewResolver

@Configuration
class ThymeleafConfig {
@Autowired
private lateinit var thymeleafViewResolver: ThymeleafReactiveViewResolver

@Autowired
private lateinit var fafProperties: FafProperties

@Bean
fun staticVariableProvider() {
val map = mutableMapOf<String, Any>()
map["environment"] = fafProperties.environment?.let { "[$it] " } ?: ""
thymeleafViewResolver.staticVariables = map
}
}
8 changes: 8 additions & 0 deletions src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
faf:
environment: LOCAL

logging:
level:
org.springframework.security: INFO
com.faforever: INFO
org.thymeleaf: INFO
5 changes: 0 additions & 5 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ hydra:
fakeTlsForwarding: ${HYDRA_FAKE_TLS_FORWARDING:false}
acceptUntrustedTlsCertificates: ${HYDRA_ACCEPT_UNTRUSTED_TLS_CERTIFICATES:true}

logging:
level:
org.springframework.security: INFO
com.faforever: INFO

spring:
r2dbc:
url: ${DB_R2DBC_URL:r2dbc:pool:mysql://localhost:3306/faf?ssl=false}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/layout/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<body>
<div class="background"></div>
<header>
<h1 th:text="${headerText}" layout:fragment="header-title">FAForever</h1>
<h1 th:text="${environment} + ${headerText}" layout:fragment="header-title">[ENV] FAForever</h1>
</header>
<div layout:fragment="content">
<div class="main-card">
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/layout/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div id="leftheader">
<a href="https://www.faforever.com"><img src="https://faforever.com/images/faf-logo.png"
alt="FAForever Logo"></a>
<h1 th:text="#{title}" layout:fragment="header-title">FAForever</h1>
<h1 th:text="${environment} + #{title}" layout:fragment="header-title">[ENV] FAForever</h1>
</div>
<div id="rightheader">
<p th:if="${currentUser != null}" th:text="#{header.loggedInAs(${currentUser.username})}">You are logged in as [User]</p>
Expand Down

0 comments on commit 5d38b5d

Please sign in to comment.