import {Component} from "@angular/core";
import {
  Event,
  NavigationCancel,
  NavigationEnd,
  NavigationError,
  NavigationStart,
  Router
} from "@angular/router";
import {ProgressIndicationService} from "@webbpm/base-package";
import {AppJivoChatWidgetService} from "../../app/service/app-jivo-chat.service";

@Component({
  moduleId: module.id,
  selector: '[webbpm]',
  templateUrl: './../../../../../src/resources/template/webbpm/webbpm.html'
})
export class WebbpmComponent {
  public headerVisible: boolean = true;
  public footerVisible: boolean = true;

  constructor(private router: Router,
              private progressIndicationService: ProgressIndicationService,
              private appJivoChatWidgetService: AppJivoChatWidgetService) {
    router.events.subscribe((event: Event) => {
      if (event instanceof NavigationStart) {
        progressIndicationService.showProgressBar();
      }
      else if (event instanceof NavigationEnd
          || event instanceof NavigationError
          || event instanceof NavigationCancel) {
        progressIndicationService.hideProgressBar();
      }
    })
  }
}
