import { Component, OnInit } from '@angular/core';
import { environment } from '../../../../environments/environment';
import { AlertService } from '../../../ui/infrastructure/alert.service';
import { SecurityService } from '../../../logic/services/security.service';

@Component({
  selector: 'app-header',
  templateUrl: './header.component.html',
  styleUrls: ['./header.component.css']
})
export class HeaderComponent implements OnInit {

  versionText = '';
  userInfo: any;

  constructor(public alertService: AlertService,
              public securityService: SecurityService) {
    this.versionText = environment.version;
  }

  ngOnInit() {
    if (this.securityService.loggedIn()) {
      this.securityService.getUserInfo().subscribe(userInfo => {
        this.userInfo = userInfo;
      });
    }
  }

  logout() {
    this.securityService.logout();
  }
}
