aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/menu/menu.component.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-11-29 21:41:11 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-11-29 21:41:11 +0100
commit50b0c262fd446e9f57630aa5775e1b4708bdf4cb (patch)
tree8e7a899cb886b2f741546bd8fc2e7084c12deb1e /client/src/app/core/menu/menu.component.ts
parentf81bb2853cedd7e65859756a5941d5c7e8b3ca2d (diff)
downloadPeerTube-50b0c262fd446e9f57630aa5775e1b4708bdf4cb.tar.gz
PeerTube-50b0c262fd446e9f57630aa5775e1b4708bdf4cb.tar.zst
PeerTube-50b0c262fd446e9f57630aa5775e1b4708bdf4cb.zip
Client: move menu component in core module
Diffstat (limited to 'client/src/app/core/menu/menu.component.ts')
-rw-r--r--client/src/app/core/menu/menu.component.ts46
1 files changed, 46 insertions, 0 deletions
diff --git a/client/src/app/core/menu/menu.component.ts b/client/src/app/core/menu/menu.component.ts
new file mode 100644
index 000000000..f1bf6966d
--- /dev/null
+++ b/client/src/app/core/menu/menu.component.ts
@@ -0,0 +1,46 @@
1import { Component, OnInit } from '@angular/core';
2import { Router } from '@angular/router';
3
4import { AuthService } from '../auth';
5import { AuthStatus } from '../../shared';
6
7@Component({
8 selector: 'my-menu',
9 templateUrl: './menu.component.html'
10})
11export class MenuComponent implements OnInit {
12 isLoggedIn: boolean;
13
14 constructor (
15 private authService: AuthService,
16 private router: Router
17 ) {}
18
19 ngOnInit() {
20 this.isLoggedIn = this.authService.isLoggedIn();
21
22 this.authService.loginChangedSource.subscribe(
23 status => {
24 if (status === AuthStatus.LoggedIn) {
25 this.isLoggedIn = true;
26 console.log('Logged in.');
27 } else if (status === AuthStatus.LoggedOut) {
28 this.isLoggedIn = false;
29 console.log('Logged out.');
30 } else {
31 console.error('Unknown auth status: ' + status);
32 }
33 }
34 );
35 }
36
37 isUserAdmin() {
38 return this.authService.isAdmin();
39 }
40
41 logout() {
42 this.authService.logout();
43 // Redirect to home page
44 this.router.navigate(['/videos/list']);
45 }
46}