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 { Friend, FriendService } from '../shared'
11 selector: 'my-friend-list',
12 templateUrl: './friend-list.component.html',
13 styleUrls: [ './friend-list.component.scss' ]
15 export class FriendListComponent {
47 title: 'Created Date',
49 valuePrepareFunction: Utils.dateToHuman
55 private notificationsService: NotificationsService,
56 private confirmService: ConfirmService,
57 private friendService: FriendService
59 this.friendsSource = this.friendService.getDataSource()
63 return this.friendsSource.count() !== 0
67 const confirmMessage = 'Do you really want to quit your friends? All their videos will be deleted.'
68 this.confirmService.confirm(confirmMessage, 'Quit friends').subscribe(
70 if (res === false) return
72 this.friendService.quitFriends().subscribe(
74 this.notificationsService.success('Sucess', 'Friends left!')
76 this.friendsSource.refresh()
79 err => this.notificationsService.error('Error', err.text)