diff --git a/backend/src/main/java/ch/puzzle/okr/OkrApplication.java b/backend/src/main/java/ch/puzzle/okr/OkrApplication.java index 1219e9af06..f9273892a7 100644 --- a/backend/src/main/java/ch/puzzle/okr/OkrApplication.java +++ b/backend/src/main/java/ch/puzzle/okr/OkrApplication.java @@ -1,15 +1,14 @@ package ch.puzzle.okr; -import ch.puzzle.okr.service.clientconfig.ClientConfigProperties; +import ch.puzzle.okr.service.clientcustomization.ClientCustomizationProperties; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication @EnableScheduling -@EnableConfigurationProperties(ClientConfigProperties.class) +@EnableConfigurationProperties(ClientCustomizationProperties.class) public class OkrApplication { public static void main(String[] args) { SpringApplication.run(OkrApplication.class, args); diff --git a/backend/src/main/java/ch/puzzle/okr/controller/ClientConfigController.java b/backend/src/main/java/ch/puzzle/okr/controller/ClientConfigController.java index 218da02f8a..43b9f9f50f 100644 --- a/backend/src/main/java/ch/puzzle/okr/controller/ClientConfigController.java +++ b/backend/src/main/java/ch/puzzle/okr/controller/ClientConfigController.java @@ -1,7 +1,7 @@ package ch.puzzle.okr.controller; import ch.puzzle.okr.dto.ClientConfigDto; -import ch.puzzle.okr.service.clientconfig.ClientConfigService; +import ch.puzzle.okr.service.clientcustomization.ClientConfigService; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; diff --git a/backend/src/main/java/ch/puzzle/okr/service/clientconfig/ClientConfigService.java b/backend/src/main/java/ch/puzzle/okr/service/clientcustomization/ClientConfigService.java similarity index 50% rename from backend/src/main/java/ch/puzzle/okr/service/clientconfig/ClientConfigService.java rename to backend/src/main/java/ch/puzzle/okr/service/clientcustomization/ClientConfigService.java index c8262d2615..f7e48dd497 100644 --- a/backend/src/main/java/ch/puzzle/okr/service/clientconfig/ClientConfigService.java +++ b/backend/src/main/java/ch/puzzle/okr/service/clientcustomization/ClientConfigService.java @@ -1,13 +1,9 @@ -package ch.puzzle.okr.service.clientconfig; +package ch.puzzle.okr.service.clientcustomization; import ch.puzzle.okr.dto.ClientConfigDto; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.stereotype.Service; -import java.util.HashMap; - @Service public class ClientConfigService { @@ -19,16 +15,16 @@ public class ClientConfigService { @Value("${spring.security.oauth2.resourceserver.opaquetoken.client-id}") private String clientId; - private final ClientConfigProperties clientConfigProperties; + private final ClientCustomizationProperties clientCustomizationProperties; - public ClientConfigService(ClientConfigProperties clientConfigProperties) { - this.clientConfigProperties = clientConfigProperties; + public ClientConfigService(ClientCustomizationProperties clientCustomizationProperties) { + this.clientCustomizationProperties = clientCustomizationProperties; } public ClientConfigDto getConfigBasedOnActiveEnv() { - return new ClientConfigDto(activeProfile, issuer, clientId, this.clientConfigProperties.getFavicon(), - this.clientConfigProperties.getLogo(), this.clientConfigProperties.getTitle(), - this.clientConfigProperties.getCustomStyles()); + return new ClientConfigDto(activeProfile, issuer, clientId, this.clientCustomizationProperties.getFavicon(), + this.clientCustomizationProperties.getLogo(), this.clientCustomizationProperties.getTitle(), + this.clientCustomizationProperties.getCustomStyles()); } } diff --git a/backend/src/main/java/ch/puzzle/okr/service/clientconfig/ClientConfigProperties.java b/backend/src/main/java/ch/puzzle/okr/service/clientcustomization/ClientCustomizationProperties.java similarity index 85% rename from backend/src/main/java/ch/puzzle/okr/service/clientconfig/ClientConfigProperties.java rename to backend/src/main/java/ch/puzzle/okr/service/clientcustomization/ClientCustomizationProperties.java index 7e4f067620..094ff5918f 100644 --- a/backend/src/main/java/ch/puzzle/okr/service/clientconfig/ClientConfigProperties.java +++ b/backend/src/main/java/ch/puzzle/okr/service/clientcustomization/ClientCustomizationProperties.java @@ -1,11 +1,11 @@ -package ch.puzzle.okr.service.clientconfig; +package ch.puzzle.okr.service.clientcustomization; import org.springframework.boot.context.properties.ConfigurationProperties; import java.util.HashMap; -@ConfigurationProperties("okr.clientconfig") -public class ClientConfigProperties { +@ConfigurationProperties("okr.clientcustomization") +public class ClientCustomizationProperties { private String favicon; private String logo; private String title; diff --git a/backend/src/main/resources/application-staging.properties b/backend/src/main/resources/application-staging.properties index 8aabb902fd..a4f58cfba7 100644 --- a/backend/src/main/resources/application-staging.properties +++ b/backend/src/main/resources/application-staging.properties @@ -4,4 +4,4 @@ logging.level.org.springframework=debug spring.security.oauth2.resourceserver.opaquetoken.client-id=pitc_okr_staging okr.user.champion.usernames=peggimann -okr.clientconfig.customstyles.okr-topbar-background-color=#ab31ad \ No newline at end of file +okr.clientcustomization.customstyles.okr-topbar-background-color=#ab31ad \ No newline at end of file diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 528f21be38..d0c0ad39de 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -51,6 +51,6 @@ okr.jwt.user.firstname=given_name okr.jwt.user.lastname=family_name okr.jwt.user.email=email -okr.clientconfig.favicon=assets/favicon.png -okr.clientconfig.logo=assets/images/okr-logo.svg -okr.clientconfig.title=Puzzle OKR \ No newline at end of file +okr.clientcustomization.favicon=assets/favicon.png +okr.clientcustomization.logo=assets/images/okr-logo.svg +okr.clientcustomization.title=Puzzle OKR diff --git a/backend/src/test/java/ch/puzzle/okr/controller/ClientConfigControllerIT.java b/backend/src/test/java/ch/puzzle/okr/controller/ClientConfigControllerIT.java index 0be1e46dbe..c39e250d3a 100644 --- a/backend/src/test/java/ch/puzzle/okr/controller/ClientConfigControllerIT.java +++ b/backend/src/test/java/ch/puzzle/okr/controller/ClientConfigControllerIT.java @@ -1,6 +1,6 @@ package ch.puzzle.okr.controller; -import ch.puzzle.okr.service.clientconfig.ClientConfigService; +import ch.puzzle.okr.service.clientcustomization.ClientConfigService; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; diff --git a/backend/src/test/java/ch/puzzle/okr/service/ClientConfigServiceIT.java b/backend/src/test/java/ch/puzzle/okr/service/ClientConfigServiceIT.java index a11a62c71e..b545c3df38 100644 --- a/backend/src/test/java/ch/puzzle/okr/service/ClientConfigServiceIT.java +++ b/backend/src/test/java/ch/puzzle/okr/service/ClientConfigServiceIT.java @@ -1,7 +1,7 @@ package ch.puzzle.okr.service; import ch.puzzle.okr.dto.ClientConfigDto; -import ch.puzzle.okr.service.clientconfig.ClientConfigService; +import ch.puzzle.okr.service.clientcustomization.ClientConfigService; import ch.puzzle.okr.test.SpringIntegrationTest; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; diff --git a/frontend/src/app/shared/services/chustomization.service.spec.ts b/frontend/src/app/shared/services/chustomization.service.spec.ts deleted file mode 100644 index d209fe0ecd..0000000000 --- a/frontend/src/app/shared/services/chustomization.service.spec.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { TestBed } from '@angular/core/testing'; -import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -import { CustomizationService } from "./customization.service"; -import { DOCUMENT } from "@angular/common"; -import { ConfigService } from "../../config.service"; -import { Observable, of } from "rxjs"; - -describe('CustomizationService', () => { - let service: CustomizationService; - - const body = { - title: "title", - favicon: "favicon", - logo: "logo", - customStyles: {cssVar1: "foo"} - }; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - providers: [ - { provide: DOCUMENT, useValue: undefined}, - { provide: ConfigService, useValue: { - config$: of(body) - }} - ] - }); - service = TestBed.inject(CustomizationService); - }); - - it('should be created', () => { - const currentConfig = service.getCurrentConfig(); - expect(currentConfig?.title).toBe(body.title) - expect(currentConfig?.logo).toBe(body.logo) - expect(currentConfig?.favicon).toBe(body.favicon) - expect(currentConfig?.customStyles['cssVar1']).toBe(body.customStyles['cssVar1']) - }); -}); diff --git a/frontend/src/app/shared/services/customization.service.spec.ts b/frontend/src/app/shared/services/customization.service.spec.ts new file mode 100644 index 0000000000..2a5701e1a4 --- /dev/null +++ b/frontend/src/app/shared/services/customization.service.spec.ts @@ -0,0 +1,41 @@ +import { TestBed } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { CustomizationService } from './customization.service'; +import { DOCUMENT } from '@angular/common'; +import { ConfigService } from '../../config.service'; +import { Observable, of } from 'rxjs'; + +describe('CustomizationService', () => { + let service: CustomizationService; + + const body = { + title: 'title', + favicon: 'favicon', + logo: 'logo', + customStyles: { cssVar1: 'foo' }, + }; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], + providers: [ + { provide: DOCUMENT, useValue: undefined }, + { + provide: ConfigService, + useValue: { + config$: of(body), + }, + }, + ], + }); + service = TestBed.inject(CustomizationService); + }); + + it('should be created', () => { + const currentConfig = service.getCurrentConfig(); + expect(currentConfig?.title).toBe(body.title); + expect(currentConfig?.logo).toBe(body.logo); + expect(currentConfig?.favicon).toBe(body.favicon); + expect(currentConfig?.customStyles['cssVar1']).toBe(body.customStyles['cssVar1']); + }); +});