]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/app.component.ts
Client: save page params as well
[github/Chocobozzz/PeerTube.git] / client / src / app / app.component.ts
CommitLineData
230809ef 1import { Component } from '@angular/core';
230809ef 2import { HTTP_PROVIDERS } from '@angular/http';
bddab65a 3import { ActivatedRoute, Router, ROUTER_DIRECTIVES } from '@angular/router';
dc8bc31b 4
4a6995be 5import { FriendService } from './friends';
41a2aee3 6import {
41a2aee3 7 AuthService,
a840d396 8 AuthStatus,
0629423c
C
9 SearchComponent,
10 SearchService
4a6995be 11} from './shared';
0629423c 12import { VideoService } from './videos';
dc8bc31b
C
13
14@Component({
15 selector: 'my-app',
4a6995be
C
16 template: require('./app.component.html'),
17 styles: [ require('./app.component.scss') ],
471bc22f 18 directives: [ ROUTER_DIRECTIVES, SearchComponent ],
0629423c 19 providers: [ AuthService, FriendService, HTTP_PROVIDERS, VideoService, SearchService ]
dc8bc31b
C
20})
21
22export class AppComponent {
ccf6ed16 23 choices = [];
4fd8aa32 24 isLoggedIn: boolean;
a99593ed 25
4fd8aa32
C
26 constructor(
27 private authService: AuthService,
28 private friendService: FriendService,
bddab65a 29 private route: ActivatedRoute,
4fd8aa32 30 private router: Router
b1794c53 31 ) {
ccf6ed16 32 this.isLoggedIn = this.authService.isLoggedIn();
b1794c53 33
ccf6ed16 34 this.authService.loginChangedSource.subscribe(
b1794c53
C
35 status => {
36 if (status === AuthStatus.LoggedIn) {
37 this.isLoggedIn = true;
38 }
39 }
40 );
41 }
98b01bac 42
00a44645 43 // FIXME
b1794c53
C
44 logout() {
45 // this._authService.logout();
46 }
47
dc8bc31b 48 makeFriends() {
ccf6ed16 49 this.friendService.makeFriends().subscribe(
dc8bc31b
C
50 status => {
51 if (status === 409) {
52 alert('Already made friends!');
98b01bac 53 } else {
dc8bc31b
C
54 alert('Made friends!');
55 }
56 },
57 error => alert(error)
44124980 58 );
dc8bc31b
C
59 }
60
61 quitFriends() {
ccf6ed16 62 this.friendService.quitFriends().subscribe(
dc8bc31b 63 status => {
4fd8aa32 64 alert('Quit friends!');
dc8bc31b
C
65 },
66 error => alert(error)
44124980 67 );
dc8bc31b
C
68 }
69}