import { Component , OnDestroy , OnInit } from '@angular/core' ; import { ActivatedRoute , Event , NavigationEnd , Router } from '@angular/router' ; import { AppLoadingService } from './services/app-loading.service' ; import { ReplaySubject } from 'rxjs' ; import { takeUntil } from 'rxjs/operators' ; declare type AppView = 'full' | 'embedded' ; @ Component ( { selector : 'cmdb-root' , templateUrl : './app.component.html' , styleUrls : [ './app.component.scss' ] } ) export class AppComponent implements OnInit , OnDestroy { private applicationSubscriber : ReplaySubject < void > = new ReplaySubject < void > ( ) ; public readonly defaultView : AppView = 'full' ; public view : AppView ; public initDone : boolean = false ; constructor ( private router , private route , private loadingIndicator ) { this . view = this . defaultView ; } public ngOnInit ( ) { this . router . events . subscribe ( ( e ) => { if ( e instanceof NavigationEnd ) { this . route . url . subscribe ( ( ) => { if ( this . route . snapshot . firstChild . data . view ) { this . view = this . route . snapshot . firstChild . data . view ; } else { this . view = this . defaultView ; } this . initDone = true ; } ) ; } } ) ; } public ngOnDestroy ( ) { this . applicationSubscriber . next ( ) ; this . applicationSubscriber . complete ( ) ; } }