Project

General

Profile

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])
42
      }
43
      //console.debug(item.route + " " + this.router.url.split('?')[0] + MenuItem.isTheActiveMenu(item,this.router.url.split('?')[0]))
44
      return MenuItem.isTheActiveMenu(item,this.router.url.split('?')[0]);
45
    }
46
  }
47
  
48
  isTheActiveUrl(menuItemURL): boolean {
49
    return (menuItemURL == this.router.url.split('?')[0])
50
  }
51
  
52
  satinizeHTML(html) {
53
    return this.sanitizer.bypassSecurityTrustHtml(html);
54
  }
55
  
56
  public get isSmallScreen() {
57
    return this.layoutService.isSmallScreen;
58
  }
59
  
60
  public get open() {
61
    return this.layoutService.open;
62
  }
63
  
64
  public toggleOpen(event: MouseEvent) {
65
    event.preventDefault();
66
    this.layoutService.setOpen(!this.open);
67
  }
68
}
(3-3/4)