Project

General

Profile

1 57387 k.triantaf
import {Component, Input, OnInit} from '@angular/core';
2
import {RootMenuItem, SideMenuItem} from '../menu';
3
import {ActivatedRoute, Router} from '@angular/router';
4
import {Observable} from 'rxjs/Observable';
5 50169 argiro.kok
6
@Component({
7 55405 k.triantaf
  selector: 'sidebar',
8
  templateUrl: 'sideBar.component.html'
9 50169 argiro.kok
})
10 57387 k.triantaf
export class SideBarComponent implements OnInit {
11 55405 k.triantaf
  @Input() communityId: string = '';
12
  @Input() menuItems: SideMenuItem[] = [];
13 57387 k.triantaf
  currentParams: any = {};
14 50286 argiro.kok
15 57387 k.triantaf
  constructor(private router: Router,
16
              private route: ActivatedRoute) {
17
  }
18
19
  ngOnInit(): void {
20
    this.route.queryParams.subscribe(params => {
21
      this.currentParams = params;
22
    });
23
  }
24
25
  private getCurrentRoute(): string {
26
    return this.router.url.split('?')[0];
27
  }
28
29
  isTheActiveMenu(route: string, params: any): boolean {
30
    return route === this.getCurrentRoute() &&
31
      (!params || JSON.stringify(this.currentParams) === JSON.stringify(params));
32
  }
33 50169 argiro.kok
}