import { Component , OnInit , ViewChild } from "@angular/core" ; import { SessionService } from "../../session/session-service/session.service" ; import { AppConfig } from "../../app-config/app-config" ; import { Title } from "@angular/platform-browser" ; import { MediaChange , MediaObserver } from "@angular/flex-layout" ; import { UntilDestroy , untilDestroyed } from "@ngneat/until-destroy" ; import { MatDrawerMode } from "@angular/material/sidenav" ; import { ConfigService } from "../../config/config.service" ; import { UiConfig } from "../ui-config" ; /**
 * The main user interface component as root element for the app structure
 * which also ties different components together into the overall app layout.
 */ @ UntilDestroy ( ) @ Component ( { moduleId : module . id , selector : "app-ui" , templateUrl : "./ui.component.html" , styleUrls : [ "./ui.component.scss" ] , } ) export class UiComponent implements OnInit { /** display mode for the menu to make it responsive and usable on smaller screens */ sideNavMode : MatDrawerMode ; /** reference to sideNav component in template, required for toggling the menu on user actions */ @ ViewChild ( "sideNav" ) sideNav ; /** title displayed in the app header bar */ title : string ; /** path to the image of a logo */ logo_path : string ; showLanguageSelect : boolean = false ; constructor ( private _sessionService , private titleService , private configService , mediaObserver ) { mediaObserver . asObservable ( ) . pipe ( untilDestroyed ( this ) ) . subscribe ( ( change ) => { if ( change [ 0 ] . mqAlias === "xs" || change [ 0 ] . mqAlias === "sm" ) { this . sideNavMode = "over" ; } else { this . sideNavMode = "side" ; } } ) ; this . configService . configUpdates . pipe ( untilDestroyed ( this ) ) . subscribe ( ( ) => { const uiConfig = this . configService . getConfig < UiConfig > ( "appConfig" ) ; this . logo_path = uiConfig ?. logo_path ; this . showLanguageSelect = uiConfig ?. displayLanguageSelect === true ; } ) ; } ngOnInit ( ) { this . title = AppConfig ?. settings ?. site_name ; this . titleService . setTitle ( this . title ) ; } /**
     * Check if user is logged in.
     */ isLoggedIn ( ) { return this . _sessionService . isLoggedIn ( ) ; } /**
     * Trigger logout of user.
     */ logout ( ) { this . _sessionService . logout ( ) ; } }