1
|
import {Component, Input, OnInit} from '@angular/core';
|
2
|
import {MenuItem} from "../../../sharedComponents/menu";
|
3
|
import {Router} from "@angular/router";
|
4
|
import {DomSanitizer} from "@angular/platform-browser";
|
5
|
import {properties} from "../../../../../environments/environment";
|
6
|
import {LayoutService} from "./layout.service";
|
7
|
|
8
|
@Component({
|
9
|
selector: 'dashboard-sidebar',
|
10
|
templateUrl: 'sideBar.component.html'
|
11
|
})
|
12
|
export class SideBarComponent implements OnInit {
|
13
|
@Input() items: MenuItem[] = [];
|
14
|
@Input() logoLabel: string;
|
15
|
@Input() headerName: string;
|
16
|
@Input() headerPosition: "left" | "center" | "right" = "center";
|
17
|
@Input() headerLogoUrl: string;
|
18
|
@Input() headerUrl: string;
|
19
|
@Input() showHeader: boolean = true;
|
20
|
@Input() activeItem: string = '';
|
21
|
@Input() activeSubItem: string = '';
|
22
|
@Input() specialMenuItem: MenuItem = null;
|
23
|
@Input() searchParams = {};
|
24
|
@Input() queryParamsHandling = "";
|
25
|
properties;
|
26
|
|
27
|
constructor(private router: Router, private sanitizer: DomSanitizer, private layoutService: LayoutService) {
|
28
|
this.properties = properties;
|
29
|
}
|
30
|
|
31
|
ngOnInit(): void {
|
32
|
}
|
33
|
|
34
|
|
35
|
isTheActiveMenuItem(item: MenuItem, subItem: MenuItem = null): boolean {
|
36
|
if (this.activeItem || this.activeSubItem) {
|
37
|
return (!subItem && this.activeItem === item.id) ||
|
38
|
(subItem && this.activeItem === item.id && this.activeSubItem === subItem.id);
|
39
|
} else {
|
40
|
if (subItem) {
|
41
|
return MenuItem.isTheActiveMenu(subItem, this.router.url.split('?')[0]) || MenuItem.isTheActiveMenu(subItem, this.router.url.split('#')[0]);
|
42
|
}
|
43
|
return MenuItem.isTheActiveMenu(item,this.router.url.split('?')[0]) || MenuItem.isTheActiveMenu(item,this.router.url.split('#')[0]);
|
44
|
}
|
45
|
}
|
46
|
|
47
|
isTheActiveUrl(menuItemURL): boolean {
|
48
|
return (menuItemURL == this.router.url.split('?')[0])
|
49
|
}
|
50
|
|
51
|
satinizeHTML(html) {
|
52
|
return this.sanitizer.bypassSecurityTrustHtml(html);
|
53
|
}
|
54
|
|
55
|
public get isSmallScreen() {
|
56
|
return this.layoutService.isSmallScreen;
|
57
|
}
|
58
|
|
59
|
public get open() {
|
60
|
return this.layoutService.open;
|
61
|
}
|
62
|
|
63
|
public toggleOpen(event: MouseEvent) {
|
64
|
event.preventDefault();
|
65
|
this.layoutService.setOpen(!this.open);
|
66
|
}
|
67
|
}
|