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

100% Statements 17/17
100% Branches 4/4
100% Functions 5/5
100% Lines 15/15
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                     75×                   75× 75× 75×             75× 14699×   1093×   75×   75×   76×          
import { Component, 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
     */
    constructor(public router: Router,
                public pageService: PageService,
                public configService: ConfigService) {
    }
 
    /**
     * 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;
            });
    }
 
}