import {Component} from "@angular/core";
import {
  Event,
  NavigationCancel,
  NavigationEnd,
  NavigationError,
  NavigationStart,
  Router
} from "@angular/router";
import {ProgressIndicationService} from "@webbpm/base-package";
import {SharedModule} from "shared";
import {AppHeaderComponent} from "./app-header.component";
import {AppFooterComponent} from "./app-footer.component";

@Component({
             selector: 'app-root',
             templateUrl: './webbpm.html',
             imports: [
               SharedModule,
               AppHeaderComponent,
               AppFooterComponent
             ]
           })
export class WebbpmComponent {
  public headerVisible: boolean = true;
  public footerVisible: boolean = false;

  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();
      }
    })
  }
}
