-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #868 from puzzle/feature/708-customizable-styles
Make logo, favicon and top-bar color customizable via spring application-properties.
- Loading branch information
Showing
23 changed files
with
396 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package ch.puzzle.okr.dto; | ||
|
||
import java.util.HashMap; | ||
|
||
public record ClientConfigDto(String activeProfile, String issuer, String clientId, String favicon, String logo, | ||
String title, HashMap<String, String> customStyles) { | ||
} |
29 changes: 0 additions & 29 deletions
29
backend/src/main/java/ch/puzzle/okr/service/ClientConfigService.java
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
backend/src/main/java/ch/puzzle/okr/service/clientconfig/ClientConfigService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package ch.puzzle.okr.service.clientconfig; | ||
|
||
import ch.puzzle.okr.dto.ClientConfigDto; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class ClientConfigService { | ||
|
||
@Value("${spring.security.oauth2.resourceserver.jwt.issuer-uri}") | ||
private String issuer; | ||
|
||
@Value("${spring.profiles.active}") | ||
private String activeProfile; | ||
|
||
@Value("${spring.security.oauth2.resourceserver.opaquetoken.client-id}") | ||
private String clientId; | ||
|
||
private final ClientCustomizationProperties clientCustomizationProperties; | ||
|
||
public ClientConfigService(ClientCustomizationProperties clientCustomizationProperties) { | ||
this.clientCustomizationProperties = clientCustomizationProperties; | ||
} | ||
|
||
public ClientConfigDto getConfigBasedOnActiveEnv() { | ||
return new ClientConfigDto(activeProfile, issuer, clientId, this.clientCustomizationProperties.getFavicon(), | ||
this.clientCustomizationProperties.getLogo(), this.clientCustomizationProperties.getTitle(), | ||
this.clientCustomizationProperties.getCustomStyles()); | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
backend/src/main/java/ch/puzzle/okr/service/clientconfig/ClientCustomizationProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package ch.puzzle.okr.service.clientconfig; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
import java.util.HashMap; | ||
|
||
@ConfigurationProperties("okr.clientcustomization") | ||
public class ClientCustomizationProperties { | ||
private String favicon; | ||
private String logo; | ||
private String title; | ||
private HashMap<String, String> customStyles = new HashMap<>(); | ||
|
||
public void setCustomStyles(HashMap<String, String> customStyles) { | ||
this.customStyles = customStyles; | ||
} | ||
|
||
public String getFavicon() { | ||
return favicon; | ||
} | ||
|
||
public void setFavicon(String favicon) { | ||
this.favicon = favicon; | ||
} | ||
|
||
public String getLogo() { | ||
return logo; | ||
} | ||
|
||
public void setLogo(String logo) { | ||
this.logo = logo; | ||
} | ||
|
||
public HashMap<String, String> getCustomStyles() { | ||
return customStyles; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
backend/src/test/java/ch/puzzle/okr/controller/ClientConfigControllerIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 13 additions & 6 deletions
19
backend/src/test/java/ch/puzzle/okr/service/ClientConfigServiceIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,32 @@ | ||
package ch.puzzle.okr.service; | ||
|
||
import ch.puzzle.okr.dto.ClientConfigDto; | ||
import ch.puzzle.okr.service.clientconfig.ClientConfigService; | ||
import ch.puzzle.okr.test.SpringIntegrationTest; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import java.util.Map; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@SpringIntegrationTest | ||
@SpringBootTest(properties = { "okr.clientcustomization.customstyles.okr-topbar-background-color=#affe00", | ||
"okr.clientcustomization.customstyles.okr-other-css-style=rgba(50,60,70,0.5)", }) | ||
class ClientConfigServiceIT { | ||
|
||
@Autowired | ||
private ClientConfigService clientConfigService; | ||
|
||
@Test | ||
void saveKeyResultShouldSaveNewKeyResult() { | ||
Map<String, String> configMap = clientConfigService.getConfigBasedOnActiveEnv(); | ||
|
||
assertEquals("prod", configMap.get("activeProfile")); | ||
assertEquals("http://localhost:8544/realms/pitc", configMap.get("issuer")); | ||
ClientConfigDto clientConfig = clientConfigService.getConfigBasedOnActiveEnv(); | ||
|
||
assertEquals("prod", clientConfig.activeProfile()); | ||
assertEquals("http://localhost:8544/realms/pitc", clientConfig.issuer()); | ||
assertEquals("assets/favicon.png", clientConfig.favicon()); | ||
assertEquals("assets/images/okr-logo.svg", clientConfig.logo()); | ||
assertEquals("#affe00", clientConfig.customStyles().get("okr-topbar-background-color")); | ||
assertEquals("rgba(50,60,70,0.5)", clientConfig.customStyles().get("okr-other-css-style")); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
frontend/src/app/application-top-bar/application-top-bar.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Observable, shareReplay } from 'rxjs'; | ||
import { ClientConfig } from './shared/types/model/ClientConfig'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class ConfigService { | ||
public config$: Observable<any>; | ||
public config$: Observable<ClientConfig>; | ||
|
||
constructor(private httpClient: HttpClient) { | ||
this.config$ = this.httpClient.get('/config').pipe(shareReplay()); | ||
this.config$ = this.httpClient.get<ClientConfig>('/config').pipe(shareReplay()); | ||
} | ||
} |
Oops, something went wrong.