-
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 branch 'main' into multitenancy_main
# Conflicts: # backend/src/main/resources/application-staging.properties # backend/src/main/resources/application.properties # frontend/src/app/app.module.ts # frontend/src/app/application-top-bar/application-top-bar.component.ts # frontend/src/app/components/action-plan/action-plan.component.ts # frontend/src/app/components/application-top-bar/application-top-bar.component.html # frontend/src/app/objective-filter/objective-filter.component.scss # frontend/src/app/services/customization.service.spec.ts # frontend/src/app/services/customization.service.ts
- Loading branch information
Showing
44 changed files
with
1,445 additions
and
684 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,42 +97,24 @@ jobs: | |
- name: Push | ||
run: docker push ${{ needs.extract-version.outputs.okr-docker-image}} | ||
|
||
- name: Trigger Deployment Workflow with latest Version | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ vars.TARGET_REPOSITORY }} | ||
ref: ${{ vars.TARGET_REFERENCE }} | ||
path: ccy-repo | ||
token: ${{secrets.VERSION_TOKEN}} | ||
|
||
- name: Change Yaml | ||
- name: Install yq | ||
shell: bash | ||
env: | ||
FILEPATH: ${{ vars.FILEPATH }} | ||
YAMLPATH: ${{ vars.YAML_PATH }} | ||
NEWVALUE: ${{ needs.extract-version.outputs.okr-docker-image}} | ||
VERSION: v4.25.2 | ||
BINARY: yq_linux_amd64 | ||
run: | | ||
wget -q https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - |\ | ||
tar xz && mv ${BINARY} /usr/local/bin/yq | ||
yq -i "${YAMLPATH} = \"${NEWVALUE}\"" ccy-repo/${FILEPATH} | ||
- name: Commit and Push Changes | ||
working-directory: ccy-repo | ||
- name: Update YAML file | ||
shell: bash | ||
env: | ||
COMMITPREFIX: '[CTS]' | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "GitHub Actions" | ||
git add ${{ vars.FILEPATH }} || { | ||
echo "No files were changed, so we did not commit anything" | ||
exit 1 | ||
} && \ | ||
git commit -m "$COMMITPREFIX Automated changes to ${{ vars.FILEPATH }}" && \ | ||
git push origin ${{ vars.TARGET_REFERENCE }} | ||
- run: rm -rf ccy-repo | ||
shell: bash | ||
curl -s --header "PRIVATE-TOKEN: ${{secrets.GITLAB_ACCESS_TOKEN}}" "${{vars.TARGET_GITLAB_REPOSITORY}}/files/${{vars.GITLAB_FILEPATH}}?ref=${{vars.TARGET_GITLAB_REFERENCE}}" -H "Accept: application/json" -H "Content-Type: application/json" | jq -r '.content' | base64 --decode > response.yaml | ||
yq -i "${{vars.YAML_PATH}} = \"${{needs.extract-version.outputs.okr-docker-image}}\"" response.yaml | ||
UPDATED_CONTENT=$(cat response.yaml) | ||
curl --request PUT --header 'PRIVATE-TOKEN: ${{secrets.GITLAB_ACCESS_TOKEN}}' -F "branch=${{vars.TARGET_GITLAB_REFERENCE}}" -F "[email protected]" -F "author_name=GitLab Actions" -F "content=${UPDATED_CONTENT}" -F "commit_message=$COMMITPREFIX Automated changes to ${{vars.FILEPATH_COMMIT}}" "${{vars.TARGET_GITLAB_REPOSITORY}}/files/${{vars.GITLAB_FILEPATH}}" | ||
generate-and-push-sbom: | ||
runs-on: ubuntu-latest | ||
|
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 |
---|---|---|
|
@@ -179,44 +179,24 @@ jobs: | |
- name: Push | ||
run: docker push ${{ needs.update-version.outputs.okr-docker-image}} | ||
|
||
- name: Trigger Deployment Workflow with latest Version | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ vars.TARGET_REPOSITORY }} | ||
ref: ${{ vars.TARGET_REFERENCE }} | ||
path: ccy-repo | ||
token: ${{secrets.VERSION_TOKEN}} | ||
|
||
- name: Change Yaml | ||
- name: Install yq | ||
shell: bash | ||
env: | ||
FILEPATH: ${{ vars.FILEPATH }} | ||
YAMLPATH: ${{ vars.YAML_PATH }} | ||
NEWVALUE: ${{ needs.update-version.outputs.okr-docker-image}} | ||
VERSION: v4.25.2 | ||
BINARY: yq_linux_amd64 | ||
run: | | ||
wget -q https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - |\ | ||
tar xz && mv ${BINARY} /usr/local/bin/yq | ||
yq -i "${YAMLPATH} = \"${NEWVALUE}\"" ccy-repo/${FILEPATH} | ||
- name: Commit and Push Changes | ||
working-directory: ccy-repo | ||
- name: Update YAML file | ||
shell: bash | ||
env: | ||
COMMITPREFIX: '[CTS]' | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "GitHub Actions" | ||
git add ${{ vars.FILEPATH }} || { | ||
echo "No files were changed, so we did not commit anything" | ||
exit 1 | ||
} && \ | ||
git commit -m "$COMMITPREFIX Automated changes to ${{ vars.FILEPATH }}" && \ | ||
git push origin ${{ vars.TARGET_REFERENCE }} | ||
- run: rm -rf ccy-repo | ||
shell: bash | ||
curl -s --header "PRIVATE-TOKEN: ${{secrets.GITLAB_ACCESS_TOKEN}}" "${{vars.TARGET_GITLAB_REPOSITORY}}/files/${{vars.GITLAB_FILEPATH}}?ref=${{vars.TARGET_GITLAB_REFERENCE}}" -H "Accept: application/json" -H "Content-Type: application/json" | jq -r '.content' | base64 --decode > response.yaml | ||
yq -i "${{vars.YAML_PATH}} = \"${{needs.update-version.outputs.okr-docker-image}}\"" response.yaml | ||
UPDATED_CONTENT=$(cat response.yaml) | ||
curl --request PUT --header 'PRIVATE-TOKEN: ${{secrets.GITLAB_ACCESS_TOKEN}}' -F "branch=${{vars.TARGET_GITLAB_REFERENCE}}" -F "[email protected]" -F "author_name=GitLab Actions" -F "content=${UPDATED_CONTENT}" -F "commit_message=$COMMITPREFIX Automated changes to ${{vars.FILEPATH_COMMIT}}" "${{vars.TARGET_GITLAB_REPOSITORY}}/files/${{vars.GITLAB_FILEPATH}}" | ||
generate-and-push-sbom: | ||
runs-on: ubuntu-latest | ||
|
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 |
---|---|---|
@@ -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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,8 @@ | |
logging.level.org.springframework=debug | ||
|
||
okr.user.champion.emails=[email protected] | ||
|
||
spring.security.oauth2.resourceserver.opaquetoken.client-id=pitc_okr_staging | ||
|
||
okr.user.champion.usernames=peggimann | ||
okr.clientcustomization.customstyles.okr-topbar-background-color=#ab31ad |
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")); | ||
} | ||
|
||
} |
Oops, something went wrong.