1 import { Component } from '@angular/core'
3 import { NotificationsService } from 'angular2-notifications'
4 import { ServerDataSource } from 'ng2-smart-table'
6 import { ConfirmService } from '../../../core'
7 import { Utils } from '../../../shared'
8 import { FriendService } from '../shared'
9 import { Pod } from '../../../../../../shared'
12 selector: 'my-friend-list',
13 templateUrl: './friend-list.component.html',
14 styleUrls: [ './friend-list.component.scss' ]
16 export class FriendListComponent {
31 deleteButtonContent: Utils.getRowDeleteButton()
52 title: 'Created Date',
54 valuePrepareFunction: Utils.dateToHuman
60 private notificationsService: NotificationsService,
61 private confirmService: ConfirmService,
62 private friendService: FriendService
64 this.friendsSource = this.friendService.getDataSource()
68 return this.friendsSource.count() !== 0
72 const confirmMessage = 'Do you really want to quit your friends? All their videos will be deleted.'
73 this.confirmService.confirm(confirmMessage, 'Quit friends').subscribe(
75 if (res === false) return
77 this.friendService.quitFriends().subscribe(
79 this.notificationsService.success('Success', 'Friends left!')
80 this.friendsSource.refresh()
83 err => this.notificationsService.error('Error', err.text)
89 removeFriend ({ data }) {
90 const confirmMessage = 'Do you really want to remove this friend ? All its videos will be deleted.'
91 const friend: Pod = data
93 this.confirmService.confirm(confirmMessage, 'Remove').subscribe(
95 if (res === false) return
97 this.friendService.removeFriend(friend).subscribe(
99 this.notificationsService.success('Success', 'Friend removed')
100 this.friendsSource.refresh()
103 err => this.notificationsService.error('Error', err.text)