All files sidebar-root.component.ts

100% Statements 10/10
100% Branches 0/0
100% Functions 5/5
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46                            1x 4x   4x   4x             3x             1x 1x             1x 1x      
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { Router } from '@angular/router';
import { httpProgressSelector, IHttpProgressState } from '@app/client-store-http-progress';
import { sidebarAction } from '@app/client-store-sidebar';
import { Store } from '@ngrx/store';
import { map } from 'rxjs';
 
@Component({
  selector: 'app-sidebar-root',
  templateUrl: './sidebar-root.component.html',
  styleUrls: ['./sidebar-root.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
  standalone: false,
})
export class AppSidebarRootComponent {
  private readonly store = inject(Store<IHttpProgressState>);
 
  private readonly router = inject(Router);
 
  public readonly loading$ = this.store.select(httpProgressSelector.sidebar).pipe(map(state => state.loading));
 
  /**
   * Sidebar close handler.
   * Propagates sidebar close event from UI to state store.
   */
  public sidebarCloseHandler(): void {
    this.store.dispatch(sidebarAction.close({ payload: { navigate: true } }));
  }
 
  /**
   * Closes the sidebar, and navigates to the info view.
   */
  public navigateToInfoPage(): void {
    this.sidebarCloseHandler();
    void this.router.navigate([{ outlets: { primary: 'info' } }]);
  }
 
  /**
   * Closes the sidebar, and navigates to the chart examples view.
   */
  public navigateToChartExamples(): void {
    this.sidebarCloseHandler();
    void this.router.navigate([{ outlets: { primary: 'charts' } }]);
  }
}