import {Component} from "@angular/core";
import {UserService, Session, AuthenticationMethodService} from "@webbpm/base-package";
import {Observable} from "rxjs";

@Component({
  moduleId: module.id,
  selector: "[log-out]",
  templateUrl: "../../../../../src/resources/template/app/component/log_out.html"
})
export class LogOutComponent {

  public currentSession: Observable<Session>;

  constructor(private userService: UserService, private authenticationMethodService: AuthenticationMethodService) {
    this.currentSession = userService.getCurrentSession();
  }

  public logout(): void {
    this.userService.logout();
  }

  public getCurrentUserName(): string {
    return this.userService.getCurrentUserName();
  }

  public getFullUserName(): string {
    return this.userService.getFullUserName();
  }

  public isLogoutButtonVisible(): boolean {
    return this.authenticationMethodService.isFormAuth();
  }

  public getOrgUnitName(): string {
    return this.userService.getOrgUnitName();
  }
}