1 import { Component, EventEmitter, OnInit, Output } from '@angular/core';
2 import { Router, ROUTER_DIRECTIVES } from '@angular/router';
4 import { AuthService, AuthStatus } from './shared';
8 template: require('./menu.component.html'),
9 directives: [ ROUTER_DIRECTIVES ]
11 export class MenuComponent implements OnInit {
12 @Output() enteredInAdmin = new EventEmitter<boolean>();
16 private authService: AuthService,
17 private router: Router
21 this.isLoggedIn = this.authService.isLoggedIn();
23 this.authService.loginChangedSource.subscribe(
25 if (status === AuthStatus.LoggedIn) {
26 this.isLoggedIn = true;
27 console.log('Logged in.');
28 } else if (status === AuthStatus.LoggedOut) {
29 this.isLoggedIn = false;
30 console.log('Logged out.');
32 console.error('Unknown auth status: ' + status);
39 this.enteredInAdmin.emit(true);
43 return this.authService.isAdmin();
47 this.authService.logout();
48 // Redirect to home page
49 this.router.navigate(['/videos/list']);