import { Component, Input, OnInit} from '@angular/core'; import {MenuItem} from "../../../sharedComponents/menu"; import {Router} from "@angular/router"; import {DomSanitizer} from "@angular/platform-browser"; import {properties} from "../../../../../environments/environment"; @Component({ selector: 'dashboard-sidebar', templateUrl: 'sideBar.component.html' }) export class SideBarComponent implements OnInit { @Input() items: MenuItem[] = []; @Input() headerName: string; @Input() headerDashboard: string; @Input() headerLogoUrl: string; @Input() headerUrl: string; @Input() showHeader: boolean = true; @Input() activeItem: string = ''; @Input() activeSubItem: string = ''; @Input() searchLink = null; properties; constructor(private router: Router, private sanitizer: DomSanitizer) { this.properties = properties; } ngOnInit(): void {} isTheActiveMenuItem(item: MenuItem, subItem: MenuItem = null): boolean { if(this.activeItem || this.activeSubItem){ return (!subItem && this.activeItem === item.id) || (subItem && this.activeItem === item.id && this.activeSubItem === subItem.id); }else { if(subItem){ return MenuItem.isTheActiveMenu(subItem,this.router.url.split('?')[0]) } return MenuItem.isTheActiveMenu(item,this.router.url.split('?')[0]) } } satinizeHTML(html){ return this.sanitizer.bypassSecurityTrustHtml(html); } }