diff --git a/apps/client-asset-sg/src/app/app.component.ts b/apps/client-asset-sg/src/app/app.component.ts index 981899f4..a2679677 100644 --- a/apps/client-asset-sg/src/app/app.component.ts +++ b/apps/client-asset-sg/src/app/app.component.ts @@ -5,6 +5,7 @@ import { appSharedStateActions, AuthService, AuthState, + ConfigService, ErrorService, setCssCustomProperties, } from '@asset-sg/client-shared'; @@ -13,6 +14,7 @@ import { Store } from '@ngrx/store'; import { WINDOW } from 'ngx-window-token'; import { debounceTime, fromEvent, startWith, switchMap } from 'rxjs'; import { assert } from 'tsafe'; +import { environment } from '../environments/environment'; import { AppState } from './state/app-state'; const fullHdWidth = 1920; @@ -31,8 +33,10 @@ export class AppComponent { readonly errorService = inject(ErrorService); readonly authService = inject(AuthService); private readonly store = inject(Store); + private readonly configService = inject(ConfigService); constructor() { + this.configService.setHideDisclaimer(environment.hideDisclaimer); this._httpClient .get>('api/oauth-config/config') .pipe(switchMap(async (config) => await this.authService.initialize(config))) diff --git a/apps/client-asset-sg/src/app/app.module.ts b/apps/client-asset-sg/src/app/app.module.ts index 4b0bedb2..5f274936 100644 --- a/apps/client-asset-sg/src/app/app.module.ts +++ b/apps/client-asset-sg/src/app/app.module.ts @@ -29,7 +29,6 @@ import { LanguageSelectorComponent, TranslateTsLoader, } from '@asset-sg/client-shared'; -import { environment } from '@asset-sg/client-shared'; import { storeLogger } from '@asset-sg/core'; import { provideSvgIcons, SvgIconComponent } from '@ngneat/svg-icon'; import { EffectsModule } from '@ngrx/effects'; @@ -40,6 +39,7 @@ import { ForModule } from '@rx-angular/template/for'; import { LetModule } from '@rx-angular/template/let'; import { PushModule } from '@rx-angular/template/push'; +import { environment } from '../environments/environment'; import { adminGuard } from './app-guards'; import { AppComponent } from './app.component'; import { AppBarComponent, MenuBarComponent, NotFoundComponent, RedirectToLangComponent } from './components'; diff --git a/libs/client-shared/src/lib/environments/environment-type.ts b/apps/client-asset-sg/src/environments/environment-type.ts similarity index 100% rename from libs/client-shared/src/lib/environments/environment-type.ts rename to apps/client-asset-sg/src/environments/environment-type.ts diff --git a/apps/client-asset-sg/src/environments/environment.prod.ts b/apps/client-asset-sg/src/environments/environment.prod.ts index bffa65d1..8b5f7283 100644 --- a/apps/client-asset-sg/src/environments/environment.prod.ts +++ b/apps/client-asset-sg/src/environments/environment.prod.ts @@ -1,4 +1,4 @@ -import { CompileTimeEnvironment } from '@asset-sg/client-shared'; +import { CompileTimeEnvironment } from './environment-type'; export const environment: CompileTimeEnvironment = { ngrxStoreLoggerEnabled: false, diff --git a/libs/client-shared/src/lib/environments/environment.ts b/apps/client-asset-sg/src/environments/environment.ts similarity index 81% rename from libs/client-shared/src/lib/environments/environment.ts rename to apps/client-asset-sg/src/environments/environment.ts index acd3627a..32dd082d 100644 --- a/libs/client-shared/src/lib/environments/environment.ts +++ b/apps/client-asset-sg/src/environments/environment.ts @@ -1,6 +1,6 @@ import { CompileTimeEnvironment } from './environment-type'; export const environment: CompileTimeEnvironment = { - ngrxStoreLoggerEnabled: true, + ngrxStoreLoggerEnabled: false, hideDisclaimer: true, }; diff --git a/libs/client-shared/src/index.ts b/libs/client-shared/src/index.ts index 9d8bf528..6d1136b9 100644 --- a/libs/client-shared/src/index.ts +++ b/libs/client-shared/src/index.ts @@ -26,5 +26,3 @@ export * from './lib/directives/can-create.directive'; export * from './lib/directives/can-delete.directive'; export * from './lib/directives/can-show.directive'; export * from './lib/directives/can-update.directive'; -export * from './lib/environments/environment'; -export * from './lib/environments/environment-type'; diff --git a/libs/client-shared/src/lib/components/disclaimer-dialog/disclaimer-dialog.component.ts b/libs/client-shared/src/lib/components/disclaimer-dialog/disclaimer-dialog.component.ts index a55029a9..4ddf9d7a 100644 --- a/libs/client-shared/src/lib/components/disclaimer-dialog/disclaimer-dialog.component.ts +++ b/libs/client-shared/src/lib/components/disclaimer-dialog/disclaimer-dialog.component.ts @@ -2,7 +2,7 @@ import { AsyncPipe } from '@angular/common'; import { Component, inject } from '@angular/core'; import { MatDialogActions, MatDialogContent, MatDialogRef } from '@angular/material/dialog'; import { MatDivider } from '@angular/material/divider'; -import { TranslateService } from '@ngx-translate/core'; +import { TranslateModule, TranslateService } from '@ngx-translate/core'; import { map } from 'rxjs'; import { ButtonComponent } from '../../components/button'; import { LanguageSelectorComponent } from '../../components/language-selector'; @@ -15,7 +15,15 @@ const LEGAL_BASE_URL = 'https://www.swissgeol.ch/datenschutz'; selector: 'asset-sg-disclaimer-dialog', templateUrl: './disclaimer-dialog.component.html', styleUrl: './disclaimer-dialog.component.scss', - imports: [LanguageSelectorComponent, MatDivider, MatDialogActions, MatDialogContent, ButtonComponent, AsyncPipe], + imports: [ + LanguageSelectorComponent, + MatDivider, + MatDialogActions, + MatDialogContent, + ButtonComponent, + AsyncPipe, + TranslateModule, + ], }) export class DisclaimerDialogComponent { public text = ''; diff --git a/libs/client-shared/src/lib/features/auth/auth.service.ts b/libs/client-shared/src/lib/features/auth/auth.service.ts index 324dfca3..e1da50f7 100644 --- a/libs/client-shared/src/lib/features/auth/auth.service.ts +++ b/libs/client-shared/src/lib/features/auth/auth.service.ts @@ -10,7 +10,7 @@ import { OAuthService } from 'angular-oauth2-oidc'; import { plainToInstance } from 'class-transformer'; import { BehaviorSubject, map, Observable, startWith } from 'rxjs'; import { DisclaimerDialogComponent } from '../../components/disclaimer-dialog/disclaimer-dialog.component'; -import { environment } from '../../environments/environment'; +import { ConfigService } from '../../services'; import { appSharedStateActions, AppState } from '../../state'; import { ApiError } from '../../utils'; @@ -21,6 +21,7 @@ export class AuthService { private readonly store = inject(Store); private readonly router = inject(Router); private readonly dialogService = inject(MatDialog); + private readonly configService = inject(ConfigService); private readonly _state$ = new BehaviorSubject(AuthState.Ongoing); private readonly _isInitialized$ = new BehaviorSubject(false); @@ -62,7 +63,7 @@ export class AuthService { if (this._state$.value === AuthState.Ongoing) { this._state$.next(AuthState.Success); - if (!environment.hideDisclaimer) { + if (!this.configService.getHideDisclaimer()) { this.dialogService.open(DisclaimerDialogComponent, { width: '500px', disableClose: true, diff --git a/libs/client-shared/src/lib/services/config.service.ts b/libs/client-shared/src/lib/services/config.service.ts new file mode 100644 index 00000000..4901e483 --- /dev/null +++ b/libs/client-shared/src/lib/services/config.service.ts @@ -0,0 +1,14 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ providedIn: 'root' }) +export class ConfigService { + private hideDisclaimer = false; + + public setHideDisclaimer(value: boolean): void { + this.hideDisclaimer = value; + } + + public getHideDisclaimer(): boolean { + return this.hideDisclaimer; + } +} diff --git a/libs/client-shared/src/lib/services/index.ts b/libs/client-shared/src/lib/services/index.ts index f23dcc11..a0aa85ec 100644 --- a/libs/client-shared/src/lib/services/index.ts +++ b/libs/client-shared/src/lib/services/index.ts @@ -1,3 +1,4 @@ export * from './app-portal.service'; export * from './dateid-module'; export * from './window.service'; +export * from './config.service';