/** Angular Imports */ import { Component , OnInit , Input , EventEmitter , Output } from '@angular/core' ; import { MatDialog } from '@angular/material/dialog' ; import { MatSidenav } from '@angular/material/sidenav' ; import { BreakpointObserver , Breakpoints } from '@angular/cdk/layout' ; import { Router } from '@angular/router' ; /** rxjs Imports */ import { Observable } from 'rxjs' ; import { map } from 'rxjs/operators' ; /** Custom Services */ import { AuthenticationService } from '../../authentication/authentication.service' ; /**
 * Toolbar component.
 */ @ Component ( { selector : 'mifosx-toolbar' , templateUrl : './toolbar.component.html' , styleUrls : [ './toolbar.component.scss' ] } ) export class ToolbarComponent implements OnInit { /** Subscription to breakpoint observer for handset. */ isHandset$ : Observable < boolean > = this . breakpointObserver . observe ( Breakpoints . Handset ) . pipe ( map ( result => result . matches ) ) ; /** Sets the initial state of sidenav as collapsed. Not collapsed if false. */ sidenavCollapsed = true ; /** Instance of sidenav. */ @ Input ( ) sidenav : MatSidenav ; /** Sidenav collapse event. */ @ Output ( ) collapse = new EventEmitter < boolean > ( ) ; param { BreakpointObserver } breakpointObserver param { Router } router param { AuthenticationService } authenticationService constructor ( private breakpointObserver , private router , private authenticationService , private dialog ) { } /**
     * Subscribes to breakpoint for handset.
     */ ngOnInit ( ) { this . isHandset$ . subscribe ( isHandset => { if ( isHandset && this . sidenavCollapsed ) { this . toggleSidenavCollapse ( false ) ; } } ) ; } /**
     * Toggles the current state of sidenav.
     */ toggleSidenav ( ) { this . sidenav . toggle ( ) ; } /**
     * Toggles the current collapsed state of sidenav.
     */ toggleSidenavCollapse ( sidenavCollapsed ? ) { this . sidenavCollapsed = sidenavCollapsed || ! this . sidenavCollapsed ; this . collapse . emit ( this . sidenavCollapsed ) ; } /**
     * Logs out the authenticated user and redirects to login page.
     */ logout ( ) { this . authenticationService . logout ( ) . subscribe ( ( ) => this . router . navigate ( [ '/login' ] , { replaceUrl : true } ) ) ; } /**
     * Opens Mifos JIRA Wiki page.
     */ help ( ) { window . open ( 'https://mifosforge.jira.com/wiki/spaces/docs/pages/52035622/User+Manual' , '_blank' ) ; } }