import {
  ChangeDetectionStrategy, ChangeDetectorRef,
  Component
} from "@angular/core";
import {ErvuDataService} from "../service/ervu-data.service";
import {CookieService} from "ngx-cookie";
import {NavigationStart, Router} from "@angular/router";

@Component({
  moduleId: module.id,
  selector: "app-header",
  templateUrl: "../../../../../src/resources/template/app/component/app_header.html",
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class AppHeaderComponent {
  public isLanding: boolean = false;

  constructor(protected cookieService: CookieService, protected ervuDataService: ErvuDataService,
              protected router: Router,  private cd: ChangeDetectorRef) {
    if (cookieService.get("webbpm.ervu-lkrp-fl")) {
      this.ervuDataService.getData();
    }
    router.events.subscribe((event) => {
      if (event instanceof NavigationStart) {
        this.isLanding = event.url == '/home';
        this.cd.markForCheck();
      }
    })
  }
}
