All files / app app.component.ts

93.75% Statements 15/16
50% Branches 2/4
66.66% Functions 2/3
93.33% Lines 14/15

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 341x 1x 1x 1x 1x 1x               1x 3x   3x 3x 3x     3x     3x       3x          
import { LayoutComponent } from './layout/layout.component';
import { Component, inject } from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
import { ActivatedRoute, NavigationEnd, Router, RouterModule } from '@angular/router';
import { LoggerService } from '@drevo-web/core';
import { filter, map, startWith } from 'rxjs/operators';
 
@Component({
    imports: [RouterModule, LayoutComponent],
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrl: './app.component.scss',
})
export class AppComponent {
    title = 'Древо';
 
    private readonly router = inject(Router);
    private readonly route = inject(ActivatedRoute);
    private readonly logger = inject(LoggerService).withContext('AppComponent');
 
    constructor() {
        this.logger.info('App initialized');
    }
 
    readonly showLayout = toSignal(
        this.router.events.pipe(
            filter(event => event instanceof NavigationEnd),
            startWith(undefined),
            map(() => this.route.firstChild?.snapshot.data['layout'] !== 'none')
        ),
        { initialValue: true }
    );
}