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 {
43 title: 'Created Date',
45 valuePrepareFunction: Utils.dateToHuman
51 private notificationsService: NotificationsService,
52 private confirmService: ConfirmService,
53 private friendService: FriendService
55 this.friendsSource = this.friendService.getDataSource();
59 return this.friendsSource.count() != 0;
63 const confirmMessage = 'Do you really want to quit your friends? All their videos will be deleted.';
64 this.confirmService.confirm(confirmMessage, 'Quit friends').subscribe(
66 if (res === false) return;
68 this.friendService.quitFriends().subscribe(
70 this.notificationsService.success('Sucess', 'Friends left!');
72 this.friendsSource.refresh();
75 err => this.notificationsService.error('Error', err.text)