import { Component } from '@angular/core';
import { Router } from '@angular/router';

import { AuthenticationService } from './_services';
import { User } from './_models';
import data from '../../configuration.json';
import './_content/app.less';

@Component({ selector: 'app', templateUrl: 'app.component.html' })
export class AppComponent {
    currentUser: User;
    path;
    constructor(
        private router: Router,
        private authenticationService: AuthenticationService
    ) {
        this.authenticationService.currentUser.subscribe(x => this.currentUser = x);
        let t = 'General';
        if (this.currentUser != null && this.currentUser.site != null) {
            t = this.currentUser.site;
        }
        this.path = data.Configuration.Images[t];
    }

    logout() {
        this.authenticationService.logout();
        this.currentUser = null;
        this.router.navigate(['/login']);
    }
}