]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/core/menu/menu.component.ts
Client: try to be responsive
[github/Chocobozzz/PeerTube.git] / client / src / app / core / menu / menu.component.ts
CommitLineData
beacf699 1import { Component, OnInit } from '@angular/core';
ab32b0fc 2import { Router } from '@angular/router';
602eb142 3
e2a2d6c8 4import { AuthService, AuthStatus } from '../auth';
a184c71b 5import { ConfigService } from '../config';
602eb142
C
6
7@Component({
8 selector: 'my-menu',
383bfc83 9 templateUrl: './menu.component.html',
3eeeb87f 10 styleUrls: [ './menu.component.scss' ]
602eb142
C
11})
12export class MenuComponent implements OnInit {
602eb142
C
13 isLoggedIn: boolean;
14
15 constructor (
16 private authService: AuthService,
a184c71b 17 private configService: ConfigService,
602eb142
C
18 private router: Router
19 ) {}
20
21 ngOnInit() {
22 this.isLoggedIn = this.authService.isLoggedIn();
23
24 this.authService.loginChangedSource.subscribe(
25 status => {
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.');
32 } else {
33 console.error('Unknown auth status: ' + status);
34 }
35 }
36 );
37 }
38
a184c71b
C
39 isRegistrationEnabled() {
40 return this.configService.getConfig().signup.enabled;
41 }
42
602eb142
C
43 isUserAdmin() {
44 return this.authService.isAdmin();
45 }
46
47 logout() {
48 this.authService.logout();
49 // Redirect to home page
50 this.router.navigate(['/videos/list']);
51 }
52}