import { Component , Inject , OnDestroy , OnInit , Input } from '@angular/core' ; import { DOCUMENT } from '@angular/common' ; import { Platform } from '@angular/cdk/platform' ; import { Subject } from 'rxjs' ; import { takeUntil } from 'rxjs/operators' ; import { FuseConfigService } from '@fuse/services/config.service' ; import { FuseNavigationService } from '@fuse/components/navigation/navigation.service' ; import { FuseSidebarService } from '@fuse/components/sidebar/sidebar.service' ; import { FuseSplashScreenService } from '@fuse/services/splash-screen.service' ; import { FuseTranslationLoaderService } from '@fuse/services/translation-loader.service' ; import { navigation } from 'app/navigation/navigation' ; @ Component ( { selector : 'main' , templateUrl : './main.component.html' , styleUrls : [ './main.component.scss' ] } ) export class MainComponent implements OnInit , OnDestroy { fuseConfig : any ; navigation : any ; @ Input ( 'selectedAccount' ) selectedAccount : Account ; @ Input ( 'accounts' ) accounts : Account [ ] ; private _unsubscribeAll : Subject < any > ; constructor ( @ Inject ( DOCUMENT ) private document , private _fuseConfigService , private _fuseNavigationService , private _fuseSidebarService , private _fuseSplashScreenService , private _fuseTranslationLoaderService , private _platform ) { this . navigation = navigation ; this . _fuseNavigationService . register ( 'main' , this . navigation ) ; this . _fuseNavigationService . setCurrentNavigation ( 'main' ) ; if ( this . _platform . ANDROID || this . _platform . IOS ) { this . document . body . classList . add ( 'is-mobile' ) ; } this . _unsubscribeAll = new Subject ( ) ; } /**
     * On init
     */ ngOnInit ( ) { this . _fuseConfigService . config . pipe ( takeUntil ( this . _unsubscribeAll ) ) . subscribe ( ( config ) => { this . fuseConfig = config ; if ( this . fuseConfig . layout . width === 'boxed' ) { this . document . body . classList . add ( 'boxed' ) ; } else { this . document . body . classList . remove ( 'boxed' ) ; } for ( let i = 0 ; i < this . document . body . classList . length ; i ++ ) { const className = this . document . body . classList [ i ] ; if ( className . startsWith ( 'theme-' ) ) { this . document . body . classList . remove ( className ) ; } } this . document . body . classList . add ( this . fuseConfig . colorTheme ) ; } ) ; } /**
     * On destroy
     */ ngOnDestroy ( ) { this . _unsubscribeAll . next ( ) ; this . _unsubscribeAll . complete ( ) ; } param key toggleSidebarOpen ( key ) { this . _fuseSidebarService . getSidebar ( key ) . toggleOpen ( ) ; } }