aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/app.component.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-08-12 16:52:10 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-08-12 16:53:32 +0200
commit602eb142bebb62f1774d6e17c211eef99ace584b (patch)
tree9410d3b225f5a904a41d7c8f3c3035375dc4268a /client/src/app/app.component.ts
parent7da18e4420c4b71a8ecfda07f39324fbfec081c3 (diff)
downloadPeerTube-602eb142bebb62f1774d6e17c211eef99ace584b.tar.gz
PeerTube-602eb142bebb62f1774d6e17c211eef99ace584b.tar.zst
PeerTube-602eb142bebb62f1774d6e17c211eef99ace584b.zip
Client: make an admin menu and a classic menu component
Diffstat (limited to 'client/src/app/app.component.ts')
-rw-r--r--client/src/app/app.component.ts74
1 files changed, 11 insertions, 63 deletions
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts
index 444b6b3b4..d9549ad5b 100644
--- a/client/src/app/app.component.ts
+++ b/client/src/app/app.component.ts
@@ -1,79 +1,27 @@
1import { Component } from '@angular/core'; 1import { Component } from '@angular/core';
2import { ActivatedRoute, Router, ROUTER_DIRECTIVES } from '@angular/router'; 2import { ROUTER_DIRECTIVES } from '@angular/router';
3 3
4import { FriendService } from './friends'; 4import { MenuAdminComponent } from './admin';
5import { 5import { MenuComponent } from './menu.component';
6 AuthService, 6import { SearchComponent, SearchService } from './shared';
7 AuthStatus,
8 SearchComponent,
9 SearchService
10} from './shared';
11import { VideoService } from './videos'; 7import { VideoService } from './videos';
12 8
13@Component({ 9@Component({
14 selector: 'my-app', 10 selector: 'my-app',
15 template: require('./app.component.html'), 11 template: require('./app.component.html'),
16 styles: [ require('./app.component.scss') ], 12 styles: [ require('./app.component.scss') ],
17 directives: [ ROUTER_DIRECTIVES, SearchComponent ], 13 directives: [ MenuAdminComponent, MenuComponent, ROUTER_DIRECTIVES, SearchComponent ],
18 providers: [ FriendService, VideoService, SearchService ] 14 providers: [ VideoService, SearchService ]
19}) 15})
20 16
21export class AppComponent { 17export class AppComponent {
22 choices = []; 18 isInAdmin = false;
23 isLoggedIn: boolean;
24 19
25 constructor( 20 onEnteredInAdmin() {
26 private authService: AuthService, 21 this.isInAdmin = true;
27 private friendService: FriendService,
28 private route: ActivatedRoute,
29 private router: Router
30 ) {
31 this.isLoggedIn = this.authService.isLoggedIn();
32
33 this.authService.loginChangedSource.subscribe(
34 status => {
35 if (status === AuthStatus.LoggedIn) {
36 this.isLoggedIn = true;
37 console.log('Logged in.');
38 } else if (status === AuthStatus.LoggedOut) {
39 this.isLoggedIn = false;
40 console.log('Logged out.');
41 } else {
42 console.error('Unknown auth status: ' + status);
43 }
44 }
45 );
46 }
47
48 isUserAdmin() {
49 return this.authService.isAdmin();
50 }
51
52 logout() {
53 this.authService.logout();
54 // Redirect to home page
55 this.router.navigate(['/videos/list']);
56 }
57
58 makeFriends() {
59 this.friendService.makeFriends().subscribe(
60 status => {
61 if (status === 409) {
62 alert('Already made friends!');
63 } else {
64 alert('Made friends!');
65 }
66 },
67 error => alert(error)
68 );
69 } 22 }
70 23
71 quitFriends() { 24 onQuittedAdmin() {
72 this.friendService.quitFriends().subscribe( 25 this.isInAdmin = false;
73 status => {
74 alert('Quit friends!');
75 },
76 error => alert(error)
77 );
78 } 26 }
79} 27}