]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/friends/friend-list/friend-list.component.ts
Remove ng2 file upload module
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / friends / friend-list / friend-list.component.ts
CommitLineData
d592e0a9 1import { Component, OnInit } from '@angular/core'
e2f555ca 2
df98563e 3import { NotificationsService } from 'angular2-notifications'
7ddd02c9 4
df98563e 5import { ConfirmService } from '../../../core'
154898b0 6import { FriendService } from '../shared'
d5f5a670 7import { Pod } from '../../../../../../shared'
e2f555ca
C
8
9@Component({
10 selector: 'my-friend-list',
ec8d8440 11 templateUrl: './friend-list.component.html',
d592e0a9 12 styleUrls: ['./friend-list.component.scss']
e2f555ca 13})
d592e0a9
C
14export class FriendListComponent implements OnInit {
15 friends: Pod[] = []
e2f555ca 16
df98563e 17 constructor (
7ddd02c9 18 private notificationsService: NotificationsService,
5769e1db 19 private confirmService: ConfirmService,
7ddd02c9 20 private friendService: FriendService
d592e0a9
C
21 ) {}
22
23 ngOnInit () {
24 this.loadData()
28798b5d 25 }
e2f555ca 26
df98563e 27 hasFriends () {
d592e0a9 28 return this.friends.length !== 0
e2f555ca
C
29 }
30
df98563e
C
31 quitFriends () {
32 const confirmMessage = 'Do you really want to quit your friends? All their videos will be deleted.'
5769e1db
C
33 this.confirmService.confirm(confirmMessage, 'Quit friends').subscribe(
34 res => {
df98563e 35 if (res === false) return
e2f555ca 36
5769e1db
C
37 this.friendService.quitFriends().subscribe(
38 status => {
d5f5a670 39 this.notificationsService.success('Success', 'Friends left!')
d592e0a9 40 this.loadData()
5769e1db 41 },
7ddd02c9 42
bfb3a98f 43 err => this.notificationsService.error('Error', err.message)
df98563e 44 )
5769e1db 45 }
df98563e 46 )
e2f555ca 47 }
d5f5a670 48
d592e0a9 49 removeFriend (friend: Pod) {
d5f5a670 50 const confirmMessage = 'Do you really want to remove this friend ? All its videos will be deleted.'
d5f5a670
GS
51
52 this.confirmService.confirm(confirmMessage, 'Remove').subscribe(
53 res => {
54 if (res === false) return
55
56 this.friendService.removeFriend(friend).subscribe(
d592e0a9
C
57 status => {
58 this.notificationsService.success('Success', 'Friend removed')
59 this.loadData()
60 },
d5f5a670 61
bfb3a98f 62 err => this.notificationsService.error('Error', err.message)
d592e0a9 63 )
d5f5a670
GS
64 }
65 )
66 }
d592e0a9
C
67
68 private loadData () {
69 this.friendService.getFriends()
70 .subscribe(
71 resultList => {
72 this.friends = resultList.data
73 },
74
bfb3a98f 75 err => this.notificationsService.error('Error', err.message)
d592e0a9
C
76 )
77 }
e2f555ca 78}