1- import { Component , OnDestroy , OnInit , inject } from '@angular/core' ;
1+ import { Component , OnDestroy , OnInit , Renderer2 , inject } from '@angular/core' ;
22import { Title } from '@angular/platform-browser' ;
33import { AuthService , TitleService , UserSettingsService } from 'src/app/common/services' ;
44import { Router } from '@angular/router' ;
99 AuthSyncStorageService ,
1010 updateUserInfo ,
1111} from 'src/app/state' ;
12+ import { loadCmsConfig , selectCmsThemeVariant } from 'src/app/state/cms' ;
1213import { AuthStateService } from 'src/app/common/store' ;
1314import { TranslateService } from '@ngx-translate/core' ;
1415
@@ -27,11 +28,17 @@ export class AppComponent implements OnInit, OnDestroy {
2728 private ngTitle = inject ( Title ) ;
2829 private titleService = inject ( TitleService ) ;
2930 private authSyncStorageService = inject ( AuthSyncStorageService ) ;
31+ private renderer = inject ( Renderer2 ) ;
3032
3133 public selectIsAuth$ = this . authStore . select ( selectAuthIsAuth ) ;
34+ private selectCmsThemeVariant$ = this . authStore . select ( selectCmsThemeVariant ) ;
3235
3336 ngOnInit ( ) : void {
3437 this . authSyncStorageService . init ( ) ;
38+ this . authStore . dispatch ( loadCmsConfig ( ) ) ;
39+ this . selectCmsThemeVariant$ . subscribe ( ( variant ) => {
40+ this . applyThemeVariant ( variant ?? 'eform' ) ;
41+ } ) ;
3542 this . selectIsAuth$ . pipe ( debounceTime ( 1000 ) , take ( 1 ) ) . subscribe ( ( isAuth ) => {
3643 if ( isAuth ) {
3744 zip ( this . userSettings . getUserSettings ( ) , this . service . obtainUserClaims ( ) )
@@ -70,6 +77,13 @@ export class AppComponent implements OnInit, OnDestroy {
7077 } ) ;
7178 }
7279
80+ private applyThemeVariant ( variant : 'eform' | 'workspace' ) {
81+ const body = document . body ;
82+ this . renderer . removeClass ( body , 'theme-eform' ) ;
83+ this . renderer . removeClass ( body , 'theme-workspace' ) ;
84+ this . renderer . addClass ( body , `theme-${ variant } ` ) ;
85+ }
86+
7387 ngOnDestroy ( ) : void {
7488 }
7589}
0 commit comments