Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

visualize environment #1208

Merged
merged 37 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
fbc517e
make topbar background color of staging violet to visualize its stagi…
nevio18324 Nov 25, 2024
a9c54e3
add new okr demo logo
nevio18324 Nov 28, 2024
be26796
change styling of logo to fit okr demo logo
nevio18324 Nov 28, 2024
4728320
create new customstyles so background color of overview is changeable
nevio18324 Nov 28, 2024
4d86829
change overviewBg to an css root variable so its changeable during ru…
nevio18324 Nov 28, 2024
91b6b6c
add two new customstyles for team title and add objective so they sta…
nevio18324 Nov 28, 2024
22763ca
add new addlogo for demo environment
nevio18324 Nov 28, 2024
5f78848
refactor extraction of customstyles in backend and add a new property…
nevio18324 Nov 28, 2024
3e242e2
change extraction of add-objective-icon to be more generic
nevio18324 Nov 28, 2024
85a81a0
change naming and add white-outline when hovering add objective button
nevio18324 Dec 2, 2024
09c73be
clean up getCustomCssStyles method and write comment
nevio18324 Dec 2, 2024
cc9a822
revert changes done to TenantClientCustomizationProvider because it i…
nevio18324 Dec 2, 2024
8a681a5
add another customstyles variable to select outline color of add obje…
nevio18324 Dec 2, 2024
907cfe3
change colors to match the colors used in mockup
nevio18324 Dec 2, 2024
eebe8e1
make addiconsrc an behaviorsubject
nevio18324 Dec 2, 2024
a22f1eb
change name of bg-grey class to bg-color
nevio18324 Dec 2, 2024
372fa72
fix add-objective-icon for prod
nevio18324 Dec 5, 2024
1c75d8b
fix wrong path for objective add icon
nevio18324 Dec 5, 2024
982e969
remove redundant null check and add unittest to make sure the add obj…
nevio18324 Dec 5, 2024
fa821a9
delete compiled typescripts that were added accidentaly
nevio18324 Dec 5, 2024
b7087a1
add undefined/null check to addIconSrc so theres always a icon
nevio18324 Dec 5, 2024
82760a9
Move check for undefined config value to ts and adjust tests
RandomTannenbaum Dec 6, 2024
6b4a136
Add new describe block to team component tests to test default value …
RandomTannenbaum Dec 6, 2024
912989a
Rename new describe block and remove unused id
RandomTannenbaum Dec 6, 2024
d6bafe2
Make background color a gradient
RandomTannenbaum Dec 6, 2024
c743bf3
change demo-new-icon to right color
nevio18324 Dec 9, 2024
9211cfd
make no team selected text also white
nevio18324 Dec 9, 2024
bb8fec2
Remove unused ngoninit and only take first value when subscribing to …
RandomTannenbaum Dec 11, 2024
a112a7a
remove gradient from background and make it solid instead
nevio18324 Dec 12, 2024
2e85ac7
change topbar background color back to lightblue
nevio18324 Dec 12, 2024
415e190
Revert "Remove unused ngoninit and only take first value when subscri…
nevio18324 Dec 12, 2024
5f15111
Revert "remove gradient from background and make it solid instead"
nevio18324 Dec 12, 2024
cbff1a7
make background-color solid
nevio18324 Dec 12, 2024
3d1a173
revert changes of application-dev properties
nevio18324 Dec 12, 2024
19fca20
Remove unused ngoninit and only take first value when subscribing to …
nevio18324 Dec 12, 2024
b7f6666
readd right logo in dev environment fix naming of customization in de…
nevio18324 Dec 12, 2024
9755837
revert formatting changes in run config for dev
nevio18324 Dec 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ public class TenantClientCustomizationProvider {
private static final String CUSTOM_STYLES_PREFIX = "okr.tenants.{0}.clientcustomization.customstyles";
private static final String TOPBAR_BACKGROUND_COLOR = ".okr-topbar-background-color";
private static final String BANNER_BACKGROUND_COLOR = ".okr-banner-background-color";
private static final String OVERVIEW_BACKGROUND_COLOR = ".okr-overview-background-color";
private static final String TEAM_HEADER_COLOR = ".okr-team-header-color";
private static final String ADD_OBJECTIVE_TEXT_COLOR = ".okr-add-objective-text-color";
private static final String ADD_OBJECTIVE_ICON = ".okr-add-objective-icon";
private static final String ADD_OBJECTIVE_OUTLINE_COLOR = ".okr-add-objective-outline-color";

private final Map<String, TenantClientCustomization> tenantCustomizations = new HashMap<>();
private final List<String> customCssStyles = List.of(TOPBAR_BACKGROUND_COLOR, BANNER_BACKGROUND_COLOR);
private final List<String> customCssStyles = List.of(TOPBAR_BACKGROUND_COLOR, BANNER_BACKGROUND_COLOR,
OVERVIEW_BACKGROUND_COLOR, TEAM_HEADER_COLOR, ADD_OBJECTIVE_TEXT_COLOR, ADD_OBJECTIVE_ICON,
ADD_OBJECTIVE_OUTLINE_COLOR);
private final Environment env;

record CssConfigItem(String cssName, String cssValue) implements Serializable {
}

public TenantClientCustomizationProvider(final @Value("${okr.tenant-ids}") String[] tenantIds, Environment env) {
this.env = env;
for (String tenantId : tenantIds) {
Expand Down Expand Up @@ -78,4 +82,7 @@ String extractCssNameFromPropertyName(String propertyName, String tenantId) {
private String formatWithTenant(String stringWithTenantPlaceholder, String tenantId) {
return MessageFormat.format(stringWithTenantPlaceholder, tenantId);
}

record CssConfigItem(String cssName, String cssValue) implements Serializable {
}
}
16 changes: 8 additions & 8 deletions backend/src/main/resources/application-demo.properties
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# logging level for staging
logging.level.org.springframework=debug

spring.security.oauth2.resourceserver.opaquetoken.client-id=pitc_okr_demo

# flyway fill database with demo data
spring.flyway.locations=classpath:db/migration,classpath:db/data-migration-demo,classpath:db/callback

# pit client customization
okr.tenants.pitc.clientcustomization.logo=assets/images/okr-logo.svg
# pitc client customization
okr.tenants.pitc.clientcustomization.logo=assets/images/okr-demo-logo.svg
okr.tenants.pitc.clientcustomization.triangles=assets/images/triangles-okr-header.svg
okr.tenants.pitc.clientcustomization.background-logo=assets/images/puzzle-p.svg
okr.tenants.pitc.clientcustomization.favicon=assets/favicon.png
okr.tenants.pitc.clientcustomization.title=Puzzle OKR
okr.tenants.pitc.clientcustomization.helpSiteUrl=https://wiki.puzzle.ch/Puzzle/OKRs
okr.tenants.pitc.clientcustomization.customstyles.okr-topbar-background-color=#1e5a96
okr.tenants.pitc.clientcustomization.customstyles.okr-banner-background-color=#dcedf9
okr.tenants.pitc.clientcustomization.helpSiteUrl=https://wiki.puzzle.ch/Puzzle/OKRs


okr.tenants.pitc.clientcustomization.customstyles.okr-overview-background-color=#1e5a96
okr.tenants.pitc.clientcustomization.customstyles.okr-team-header-color=#ffffff
okr.tenants.pitc.clientcustomization.customstyles.okr-add-objective-text-color=#e5e8eb
okr.tenants.pitc.clientcustomization.customstyles.okr-add-objective-icon=/assets/icons/new-icon-demo.svg
okr.tenants.pitc.clientcustomization.customstyles.okr-add-objective-outline-color=#e5e8eb
# acme client customization
okr.tenants.acme.clientcustomization.logo=assets/images/okr-logo-acme.svg
okr.tenants.acme.clientcustomization.triangles=assets/images/triangles-okr-acme-header.svg
Expand Down
10 changes: 1 addition & 9 deletions backend/src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
# show actions from entity manager
#spring.jpa.show-sql=true
#spring.jpa.properties.hibernate.format_sql=true

# debug options
logging.level.ch.puzzle.okr=DEBUG
logging.level.org.springframework.security=DEBUG
# server.servlet.context-path=/resource-server
# flyway fill database with data
spring.flyway.locations=classpath:db/migration,classpath:db/data-migration,classpath:db/callback

# TENANT Configuration
okr.tenant-ids=pitc,acme
okr.datasource.driver-class-name=org.postgresql.Driver

# security
connect.src=http://localhost:8544 http://localhost:8545

# hibernate
hibernate.connection.url=jdbc:postgresql://localhost:5432/okr
hibernate.connection.username=user
hibernate.connection.password=pwd
hibernate.multiTenancy=SCHEMA

# pitc
okr.tenants.pitc.datasource.url=jdbc:postgresql://localhost:5432/okr
okr.tenants.pitc.datasource.username=pitc
Expand All @@ -31,7 +26,6 @@ [email protected]
okr.tenants.pitc.security.oauth2.resourceserver.jwt.jwk-set-uri=http://localhost:8544/realms/pitc/protocol/openid-connect/certs
okr.tenants.pitc.security.oauth2.frontend.issuer-url=http://localhost:8544/realms/pitc
okr.tenants.pitc.security.oauth2.frontend.client-id=pitc_okr_staging

# acme
okr.tenants.acme.datasource.url=jdbc:postgresql://localhost:5432/okr
okr.tenants.acme.datasource.username=acme
Expand All @@ -41,8 +35,7 @@ [email protected]
okr.tenants.acme.security.oauth2.resourceserver.jwt.jwk-set-uri=http://localhost:8545/realms/acme/protocol/openid-connect/certs
okr.tenants.acme.security.oauth2.frontend.issuer-url=http://localhost:8545/realms/acme
okr.tenants.acme.security.oauth2.frontend.client-id=acme_okr_staging

# pit client customization
# pitc client customization
okr.tenants.pitc.clientcustomization.logo=assets/images/okr-logo.svg
okr.tenants.pitc.clientcustomization.triangles=assets/images/triangles-okr-header.svg
okr.tenants.pitc.clientcustomization.background-logo=assets/images/puzzle-p.svg
Expand All @@ -51,7 +44,6 @@ okr.tenants.pitc.clientcustomization.title=Puzzle OKR
okr.tenants.pitc.clientcustomization.helpSiteUrl=https://wiki.puzzle.ch/Puzzle/OKRs
okr.tenants.pitc.clientcustomization.customstyles.okr-topbar-background-color=#1e5a96
okr.tenants.pitc.clientcustomization.customstyles.okr-banner-background-color=#dcedf9

# acme client customization
okr.tenants.acme.clientcustomization.logo=assets/images/okr-logo-acme.svg
okr.tenants.acme.clientcustomization.triangles=assets/images/triangles-okr-acme-header.svg
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/resources/application-staging.properties
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ okr.tenants.pitc.clientcustomization.triangles=assets/images/triangles-okr-heade
okr.tenants.pitc.clientcustomization.background-logo=assets/images/puzzle-p.svg
okr.tenants.pitc.clientcustomization.favicon=assets/favicon.png
okr.tenants.pitc.clientcustomization.title=Puzzle OKR
okr.tenants.pitc.clientcustomization.customstyles.okr-topbar-background-color=#1e5a96
okr.tenants.pitc.clientcustomization.customstyles.okr-topbar-background-color=#641e96
okr.tenants.pitc.clientcustomization.customstyles.okr-banner-background-color=#dcedf9
okr.tenants.pitc.clientcustomization.helpSiteUrl=https://wiki.puzzle.ch/Puzzle/OKRs

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
<div id="topBarHeight">
<div id="okrTopbar">
<a routerLink="/" queryParamsHandling="preserve" class="d-flex h-100 align-items-center ps-4">
<img
[attr.data-testId]="'logo'"
alt="okr-logo"
height="32"
ngSrc="{{ this.logoSrc$ | async }}"
width="140"
priority
/>
<img [attr.data-testId]="'logo'" alt="okr-logo" height="32" src="{{ this.logoSrc$ | async }}" priority />
</a>
<div class="d-flex align-items-center me-md-5 me-1">
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
>
</app-team>
<div *ngIf="(overviewEntities$ | async)?.length == 0" class="d-flex align-items-center flex-column pt-5 gap-5">
<p>Kein Team ausgewählt</p>
<p id="no-team-text">Kein Team ausgewählt</p>
<img src="{{ this.backgroundLogoSrc$ | async }}" alt="Greyed out company logo" width="242" class="puzzle-logo" />
</div>
</div>
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/app/components/overview/overview.component.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
@import "../style/variables";

.overview-container {
overflow-x: hidden;
background-color: $overview-bg;
background: var(--okr-overview-background-color);
transition: 0.5s;
}

Expand All @@ -13,3 +11,6 @@
.puzzle-logo {
filter: invert(38%) sepia(31%) saturate(216%) hue-rotate(167deg) brightness(96%) contrast(85%);
}
#no-team-text {
color: var(--okr-team-header-color);
}
13 changes: 9 additions & 4 deletions frontend/src/app/components/team/team.component.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
<div *ngIf="overviewEntity as OVEntity" class="bg-grey justify-content-between pt-3">
<div *ngIf="overviewEntity as OVEntity" class="justify-content-between pt-3">
<section class="team-header">
<div class="d-flex align-items-center gap-2 flex-row">
<h1 class="team-title">{{ OVEntity.team.name }}</h1>
</div>
<button
(click)="createObjective()"
*ngIf="OVEntity.writeable"
id="add-objective"
[attr.data-testId]="'add-objective'"
class="px-0 mt-1 mb-3 pe-2 h-50 align-new-icon"
color="primary"
mat-button
>
<span class="d-flex align-items-center add-text">
<img alt="Add key-result button" class="add-cross-button" src="../../../assets/icons/new-icon.svg" />
<span id="add-objective-span" class="d-flex align-items-center add-text">
<img
alt="Add objective button"
class="add-cross-button"
[attr.data-testId]="'add-objective-icon'"
src="{{ addIconSrc | async }}"
/>
Objective hinzufügen
</span>
</button>
Expand All @@ -30,7 +36,6 @@ <h1 class="team-title">{{ OVEntity.team.name }}</h1>
class="col-xs-12 col-md-6 col-xl-4 pb-3 column-width"
id="objective-column"
></app-objective-column>

<div *ngFor="let placeholder of [].constructor(2)" class="col-xs-12 col-md-6 col-xl-4 column-width h-0"></div>
</div>
</div>
13 changes: 13 additions & 0 deletions frontend/src/app/components/team/team.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,16 @@
align-items: center;
justify-content: center;
}

.team-title {
color: var(--okr-team-header-color);
}

#add-objective-span {
color: var(--okr-add-objective-text-color);
}

#add-objective:hover,
#add-objective:focus {
outline: 1px solid var(--okr-add-objective-outline-color);
}
71 changes: 69 additions & 2 deletions frontend/src/app/components/team/team.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { RouterTestingModule } from '@angular/router/testing';
import { MatMenuModule } from '@angular/material/menu';
import { KeyresultComponent } from '../keyresult/keyresult.component';
import { MatDialogModule } from '@angular/material/dialog';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { By } from '@angular/platform-browser';
import { RefreshDataService } from '../../services/refresh-data.service';
import { TranslateTestingModule } from 'ngx-translate-testing';
Expand All @@ -18,11 +17,30 @@ import { ConfidenceComponent } from '../confidence/confidence.component';
import { ScoringComponent } from '../../shared/custom/scoring/scoring.component';
import { ChangeDetectionStrategy } from '@angular/core';
import { DialogService } from '../../services/dialog.service';
import { ConfigService } from '../../services/config.service';
import { of } from 'rxjs';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';

const dialogService = {
open: jest.fn(),
};

const configServiceDefined = {
config$: of({
customStyles: {
'okr-add-objective-icon': 'new-icon-from-config-service.svg',
},
}),
};

const configServiceUndefined = {
config$: of({
customStyles: {
'okr-add-objective-icon': undefined,
},
}),
};

const refreshDataServiceMock = {
markDataRefresh: jest.fn(),
};
Expand All @@ -37,7 +55,6 @@ describe('TeamComponent', () => {
RouterTestingModule,
MatMenuModule,
MatDialogModule,
HttpClientTestingModule,
MatTooltipModule,
TranslateTestingModule.withTranslations({
de: de,
Expand All @@ -50,10 +67,15 @@ describe('TeamComponent', () => {
provide: DialogService,
useValue: dialogService,
},
{
provide: ConfigService,
useValue: configServiceDefined,
},
{
provide: RefreshDataService,
useValue: refreshDataServiceMock,
},
provideHttpClient(withInterceptorsFromDi()),
],
})
.overrideComponent(TeamComponent, {
Expand Down Expand Up @@ -85,4 +107,49 @@ describe('TeamComponent', () => {
const button = fixture.debugElement.query(By.css('[data-testId="add-objective"]'));
expect(button).toBeFalsy();
});

it('should set value of addIconSrc if src from config service is defined', () => {
expect(component.addIconSrc.value).toBe('new-icon-from-config-service.svg');
const addObjectiveIcon = fixture.debugElement.query(By.css('[data-testId="add-objective-icon"]'));
expect(addObjectiveIcon.attributes['src']).toBe('new-icon-from-config-service.svg');
});
});

describe('TeamComponent undefined values in config service', () => {
let component: TeamComponent;
let fixture: ComponentFixture<TeamComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
MatMenuModule,
TranslateTestingModule.withTranslations({
de: de,
}),
],
declarations: [TeamComponent],
providers: [
{
provide: ConfigService,
useValue: configServiceUndefined,
},
provideHttpClient(withInterceptorsFromDi()),
],
})
.overrideComponent(TeamComponent, {
set: { changeDetection: ChangeDetectionStrategy.Default },
})
.compileComponents();

fixture = TestBed.createComponent(TeamComponent);
component = fixture.componentInstance;
component.overviewEntity = overViewEntity1;
fixture.detectChanges();
});

it('should keep default value of addIconSrc if src from config service is undefined', () => {
expect(component.addIconSrc.value).toBe('assets/icons/new-icon.svg');
const addObjectiveIcon = fixture.debugElement.query(By.css('[data-testId="add-objective-icon"]'));
expect(addObjectiveIcon.attributes['src']).toBe('assets/icons/new-icon.svg');
});
});
16 changes: 12 additions & 4 deletions frontend/src/app/components/team/team.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,34 @@ import { Objective } from '../../shared/types/model/Objective';
import { KeyresultDialogComponent } from '../keyresult-dialog/keyresult-dialog.component';
import { ObjectiveMin } from '../../shared/types/model/ObjectiveMin';
import { DialogService } from '../../services/dialog.service';
import { ConfigService } from '../../services/config.service';
import { ClientConfig } from '../../shared/types/model/ClientConfig';
import { BehaviorSubject, first } from 'rxjs';

@Component({
selector: 'app-team',
templateUrl: './team.component.html',
styleUrls: ['./team.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TeamComponent implements OnInit {
export class TeamComponent {
@Input({ required: true })
public overviewEntity!: OverviewEntity;
addIconSrc: BehaviorSubject<string> = new BehaviorSubject('assets/icons/new-icon.svg');

constructor(
private dialogService: DialogService,
private refreshDataService: RefreshDataService,
) {}
private configService: ConfigService,
) {
this.configService.config$.pipe(first()).subscribe((config: ClientConfig) => {
const configuredIconSrc = config.customStyles['okr-add-objective-icon'];
if (configuredIconSrc) this.addIconSrc.next(configuredIconSrc);
});
}

trackByObjectiveId: TrackByFunction<ObjectiveMin> = (index, objective) => objective.id;

ngOnInit(): void {}

createObjective() {
const matDialogRef = this.dialogService.open(ObjectiveFormComponent, {
data: {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/assets/icons/new-icon-demo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading