import {ChangeDetectionStrategy, ChangeDetectorRef, Component} from "@angular/core";
import {AuthorizationService} from "../service/authorization.service";

@Component({
  moduleId: module.id,
  selector: "app-header",
  templateUrl: "../../../../../src/resources/template/app/component/app_header.html",
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class AppHeaderComponent {

  name: string;
  realm: string;

  constructor(protected authService: AuthorizationService,
              protected cd: ChangeDetectorRef) {
    authService.onSessionUpdate
        .subscribe(session => {
          this.name = session.name;
          this.realm = session.realm;
          cd.markForCheck()
        })
  }
}
