]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/angular/app/app.component.ts
Add separations in the panel
[github/Chocobozzz/PeerTube.git] / client / angular / app / app.component.ts
CommitLineData
dc8bc31b 1import { Component, ElementRef } from 'angular2/core';
98b01bac
C
2import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, Router } from 'angular2/router';
3import { HTTP_PROVIDERS } from 'angular2/http';
dc8bc31b
C
4
5import { VideosAddComponent } from '../videos/components/add/videos-add.component';
6import { VideosListComponent } from '../videos/components/list/videos-list.component';
7import { VideosWatchComponent } from '../videos/components/watch/videos-watch.component';
8import { VideosService } from '../videos/services/videos.service';
9import { FriendsService } from '../friends/services/friends.service';
10
11@RouteConfig([
12 {
13 path: '/videos/list',
14 name: 'VideosList',
15 component: VideosListComponent,
16 useAsDefault: true
17 },
18 {
19 path: '/videos/watch/:id',
20 name: 'VideosWatch',
21 component: VideosWatchComponent
22 },
23 {
24 path: '/videos/add',
25 name: 'VideosAdd',
26 component: VideosAddComponent
27 }
28])
29
30@Component({
31 selector: 'my-app',
32 templateUrl: 'app/angular/app/app.component.html',
33 styleUrls: [ 'app/angular/app/app.component.css' ],
34 directives: [ ROUTER_DIRECTIVES ],
35 providers: [ ROUTER_PROVIDERS, HTTP_PROVIDERS, ElementRef, VideosService, FriendsService ]
36})
37
38export class AppComponent {
98b01bac
C
39 constructor(private _friendsService: FriendsService, private _router: Router) {}
40
41 doSearch(search: string) {
42 if (search !== '') {
43 this._router.navigate(['VideosList', { search: search }]);
44 } else {
45 this._router.navigate(['VideosList']);
46 }
47 }
dc8bc31b
C
48
49 makeFriends() {
50 this._friendsService.makeFriends().subscribe(
51 status => {
52 if (status === 409) {
53 alert('Already made friends!');
98b01bac 54 } else {
dc8bc31b
C
55 alert('Made friends!');
56 }
57 },
58 error => alert(error)
59 )
60 }
61
62 quitFriends() {
63 this._friendsService.quitFriends().subscribe(
64 status => {
65 alert('Quit friends!');
66 },
67 error => alert(error)
68 )
69 }
70}