All files / src/app/components/side-bar side-bar.component.ts

100% Statements 18/18
100% Branches 4/4
100% Functions 5/5
100% Lines 16/16

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 47 48 49 50 511x 1x 1x   1x                 1x   74x                     74x 74x 74x 74x             74x 14337x   1098x   74x   74x   76x          
import { Component, Inject, LOCALE_ID, OnInit } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { filter } from 'rxjs/internal/operators';
import { ConfigModel, CustomHtmlModel } from '../../models';
import { ConfigService, PageService } from '../../services';
 
/**
 * Side Bar Component
 */
@Component({
    selector: 'app-side-bar',
    templateUrl: './side-bar.component.html'
})
export class SideBarComponent implements OnInit {
    /** do you want to hide search widget */
    hideSearchWidget = false;
    /** primary custom html widget */
    customHtml: CustomHtmlModel;
 
    /**
     * constructor of SideBarComponent
     * @param router: Router
     * @param pageService: PageService
     * @param configService: ConfigService
     * @param locale: LOCALE_ID
     */
    constructor(public router: Router,
                public pageService: PageService,
                public configService: ConfigService,
                @Inject(LOCALE_ID) public locale: string) {
    }
 
    /**
     * ngOnInit
     */
    ngOnInit(): void {
        this.router.events
            .pipe(filter(event => event instanceof NavigationEnd))
            .subscribe((event: NavigationEnd) => {
                this.hideSearchWidget = this.router.url === '/search' || this.router.url.startsWith('/search?');
            });
        this.hideSearchWidget = this.router.url === '/search' || this.router.url.startsWith('/search?');
 
        this.configService.getConfig()
            .subscribe((config: ConfigModel) => {
                this.customHtml = config.primaryCustomHtmlWidget;
            });
    }
 
}