]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/admin/friends/friend-list/friend-list.component.ts
Client: support the new make friends method
[github/Chocobozzz/PeerTube.git] / client / src / app / admin / friends / friend-list / friend-list.component.ts
1 import { Component, OnInit } from '@angular/core';
2 import { ROUTER_DIRECTIVES } from '@angular/router';
3
4 import { Friend, FriendService } from '../shared';
5
6 @Component({
7 selector: 'my-friend-list',
8 template: require('./friend-list.component.html'),
9 styles: [ require('./friend-list.component.scss') ],
10 directives: [ ROUTER_DIRECTIVES ]
11 })
12 export class FriendListComponent implements OnInit {
13 friends: Friend[];
14
15 constructor(private friendService: FriendService) { }
16
17 ngOnInit() {
18 this.friendService.getFriends().subscribe(
19 friends => this.friends = friends,
20
21 err => alert(err)
22 );
23 }
24
25 makeFriends() {
26 this.friendService.makeFriends().subscribe(
27 status => {
28 if (status === 409) {
29 alert('Already made friends!');
30 } else {
31 alert('Made friends!');
32 }
33 },
34 error => alert(error)
35 );
36 }
37
38 quitFriends() {
39 if (!confirm('Are you sure?')) return;
40
41 this.friendService.quitFriends().subscribe(
42 status => {
43 alert('Quit friends!');
44 },
45 error => alert(error)
46 );
47 }
48 }