@@ -3,7 +3,10 @@ import {
33 Inject ,
44 InjectionToken ,
55 OnInit ,
6- ChangeDetectionStrategy
6+ OnDestroy ,
7+ AfterContentInit ,
8+ ChangeDetectionStrategy ,
9+ ViewChild
710} from '@angular/core' ;
811import {
912 trigger ,
@@ -14,9 +17,13 @@ import {
1417} from '@angular/animations' ;
1518import { Router , ActivatedRoute } from '@angular/router' ;
1619import { BreakpointObserver } from '@angular/cdk/layout' ;
20+ import { MatSidenav } from '@angular/material' ;
1721import { Subscription } from 'rxjs/Subscription' ;
22+ import { Subject } from 'rxjs/Subject' ;
1823import { Observable } from 'rxjs/Observable' ;
24+ import { filter , takeUntil } from 'rxjs/operators' ;
1925import { OperatorDoc } from '../../operator-docs/operator.model' ;
26+ import { OperatorMenuService } from '../core/services/operator-menu.service' ;
2027
2128const OPERATOR_MENU_GAP_LARGE = 64 ;
2229const OPERATOR_MENU_GAP_SMALL = 54 ;
@@ -53,12 +60,15 @@ interface OperatorDocMap {
5360 ] )
5461 ]
5562} )
56- export class OperatorsComponent implements OnInit {
63+ export class OperatorsComponent implements OnInit , AfterContentInit , OnDestroy {
64+ @ViewChild ( MatSidenav ) _sidenav : MatSidenav ;
5765 public groupedOperators : OperatorDocMap ;
5866 public categories : string [ ] ;
67+ private _onDestroy = new Subject ( ) ;
5968
6069 constructor (
6170 private _breakpointObserver : BreakpointObserver ,
71+ private _operatorMenuService : OperatorMenuService ,
6272 @Inject ( OPERATORS_TOKEN ) public operators : OperatorDoc [ ]
6373 ) { }
6474
@@ -67,6 +77,13 @@ export class OperatorsComponent implements OnInit {
6777 this . categories = Object . keys ( this . groupedOperators ) ;
6878 }
6979
80+ ngAfterContentInit ( ) {
81+ this . _operatorMenuService
82+ . menuStatus ( )
83+ . pipe ( filter ( s => ! ! s ) , takeUntil ( this . _onDestroy ) )
84+ . subscribe ( _ => this . _sidenav . open ( ) ) ;
85+ }
86+
7087 get extraSmallScreen ( ) {
7188 return this . _breakpointObserver . isMatched ( '(max-width: 601px)' ) ;
7289 }
@@ -84,6 +101,10 @@ export class OperatorsComponent implements OnInit {
84101 get sidenavMode ( ) {
85102 return this . smallScreen ? 'over' : 'side' ;
86103 }
104+
105+ ngOnDestroy ( ) {
106+ this . _onDestroy . next ( ) ;
107+ }
87108}
88109
89110export function groupOperatorsByType ( operators : OperatorDoc [ ] ) : OperatorDocMap {
0 commit comments