]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+admin/friends/friend-list/friend-list.component.ts
700ea7a69fa5175d8e6c425b32630d1363192a68
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / friends / friend-list / friend-list.component.ts
1 import { Component, OnInit } from '@angular/core';
2
3 import { NotificationsService } from 'angular2-notifications';
4
5 import { Friend, FriendService } from '../shared';
6
7 @Component({
8 selector: 'my-friend-list',
9 templateUrl: './friend-list.component.html',
10 styleUrls: [ './friend-list.component.scss' ]
11 })
12 export class FriendListComponent implements OnInit {
13 friends: Friend[];
14
15 constructor(
16 private notificationsService: NotificationsService,
17 private friendService: FriendService
18 ) { }
19
20 ngOnInit() {
21 this.getFriends();
22 }
23
24 quitFriends() {
25 if (!confirm('Are you sure?')) return;
26
27 this.friendService.quitFriends().subscribe(
28 status => {
29 this.notificationsService.success('Sucess', 'Friends left!');
30
31 this.getFriends();
32 },
33
34 err => this.notificationsService.error('Error', err.text)
35 );
36 }
37
38 private getFriends() {
39 this.friendService.getFriends().subscribe(
40 res => this.friends = res.friends,
41
42 err => this.notificationsService.error('Error', err.text)
43 );
44 }
45 }