import {Component, ViewEncapsulation} from "@angular/core";
import {
  Event,
  NavigationCancel,
  NavigationEnd,
  NavigationError,
  NavigationStart,
  Router
} from "@angular/router";
import {ProgressIndicationService} from "@webbpm/base-package";


@Component({
             moduleId: module.id,
             encapsulation: ViewEncapsulation.ShadowDom,
             selector: 'mfe-webbpm',
             templateUrl: './../../../../../src/resources/template/webbpm/mfe-webbpm.html',
             styleUrls: ['./../../../../../src/resources/css/style.css'],
           })
export class MfeWebbpmComponent {
  public headerVisible: boolean = true;
  public footerVisible: boolean = true;

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