1 import { Component, OnInit } from '@angular/core'
2 import { Router } from '@angular/router'
4 import { AuthService, AuthStatus } from '../auth'
5 import { ServerService } from '../server'
9 templateUrl: './menu.component.html',
10 styleUrls: [ './menu.component.scss' ]
12 export class MenuComponent implements OnInit {
16 private authService: AuthService,
17 private serverService: ServerService,
18 private router: Router
22 this.isLoggedIn = this.authService.isLoggedIn()
24 this.authService.loginChangedSource.subscribe(
26 if (status === AuthStatus.LoggedIn) {
27 this.isLoggedIn = true
28 console.log('Logged in.')
29 } else if (status === AuthStatus.LoggedOut) {
30 this.isLoggedIn = false
31 console.log('Logged out.')
33 console.error('Unknown auth status: ' + status)
39 isRegistrationAllowed () {
40 return this.serverService.getConfig().signup.allowed
44 return this.authService.isAdmin()
48 this.authService.logout()
49 // Redirect to home page
50 this.router.navigate(['/videos/list'])