import { AfterViewInit , Component , OnInit , ViewChild } from '@angular/core' ; import { NavigationEnd , Router , RouterEvent } from '@angular/router' ; import { Breakpoints , BreakpointObserver , BreakpointState } from '@angular/cdk/layout' ; import { delay } from 'rxjs/operators' ; import { MatSidenav } from '@angular/material' ; import { ActivityService , AuthenticationService } from './core/services/index.service' ; import { Navigation , ProfileModel } from './shared/models/index.model' ; import { environment } from './../environments/environment' ; /**
 * App component
 */ @ Component ( { selector : 'dashboard-app' , templateUrl : './app.component.html' , styleUrls : [ './app.component.scss' ] , } ) export class AppComponent implements AfterViewInit , OnInit { private ga : Function = ( < any > window ) . ga ; public progress : number = 0 ; public publicRoutes : Navigation [ ] = [ { title : 'Homepage' , route : '/' , icon : 'home' , } , ] ; public privateRoutes : Navigation [ ] = [ { title : 'My Projects' , route : '/projects' , icon : 'dashboard' , } , { title : 'Add Project' , route : '/projects/create' , icon : 'add_to_photos' , } , { title : 'Profile' , route : '/profile' , icon : 'person' , } , ] ; public generalRoutes : Navigation [ ] = [ { title : 'Features' , route : '/features' , icon : 'poll' , } , { title : 'Help' , route : '/help' , icon : 'help_outline' , } , ] ; public adminRoutes : Navigation [ ] = [ { title : 'List users' , route : '/admin/users' , icon : 'person' , } , ] ; public version : string ; public isSmallScreen : boolean ; public menuTriger : boolean ; public sideNavMode : string ; @ ViewChild ( 'sidenav' ) public menu : MatSidenav ; param _iconRegistry param _domSanitizer param authService param activityService param breakpointObserver constructor ( private authService , private activityService , private breakpointObserver , private router ) { this . breakpointObserver . observe ( [ Breakpoints . XSmall ] ) . subscribe ( ( state ) => { if ( state . matches ) { this . menuTriger = true ; this . isSmallScreen = true ; this . sideNavMode = 'over' ; } else { this . isSmallScreen = false ; this . sideNavMode = 'side' ; } } ) ; this . version = environment . version ; } /**
     * Initializing the google analytics router events
     */ public ngOnInit ( ) { this . ga ( 'create' , environment . tracking , 'auto' ) ; this . ga ( 'send' , 'pageview' ) ; this . router . events . subscribe ( ( event ) => { if ( event instanceof NavigationEnd ) { window . scrollTo ( 0 , 0 ) ; this . ga ( 'set' , 'page' , event . urlAfterRedirects ) ; this . ga ( 'send' , 'pageview' ) ; } } ) ; } /**
     * Life cycle after view init method
     */ ngAfterViewInit ( ) { this . activityService . getProgressBar ( ) . pipe ( delay ( 0 ) ) . subscribe ( ( progress ) => this . progress = progress ) ; } /**
     * Return the profile
     */ public getProfile ( ) { return this . authService . profile ; } /**
     * Check if user is authenticated
     */ public isAuthenticated ( ) { return this . authService . isAuthenticated ; } /**
     * Login in the system
     */ public login ( ) { this . authService . login ( ) ; } /**
     * Logout from the system
     */ public logout ( ) { this . authService . logout ( ) ; } /**
     * Close the menu
     */ public closeMenu ( ) { if ( this . isSmallScreen ) { this . menu . opened = false ; } } param event public openMenu ( event ) { event . stopPropagation ( ) ; if ( ! this . isSmallScreen ) { this . menuTriger = ! this . menuTriger ; } } /**
     * Show door bell
     */ public showDoorbell ( ) { ( < any > window ) . doorbell . show ( ) ; } }