import {ChangeDetectionStrategy, Component} from "@angular/core";
import {Router} from "@angular/router";
import {UserService, Session} from "@webbpm/base-package";
import {Observable} from "rxjs";
import {AdminMenuComponent} from "./admin-menu.component";
import {SharedModule} from "shared";
import {LogOutComponent} from "./logout.component";
import {AsyncPipe} from "@angular/common";
import {ProcessListComponent} from "./process-list.component";

@Component({
    selector: "app-header",
    templateUrl: "./app_header.html",
    changeDetection: ChangeDetectionStrategy.OnPush,
    imports: [
      AsyncPipe,
      SharedModule,
      ProcessListComponent,
      AdminMenuComponent,
      LogOutComponent
    ]
})
export class AppHeaderComponent {

  public currentSession: Observable<Session>;

  constructor(protected userService: UserService,
              protected router: Router) {
    this.currentSession = this.userService.getCurrentSession();
  }

  public openTaskList(): void {
    this.router.navigateByUrl("/process/tasks");
  }
}
