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