]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/friends/friend-list/friend-list.component.ts
Client: fix lint
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / friends / friend-list / friend-list.component.ts
CommitLineData
28798b5d 1import { Component } from '@angular/core';
e2f555ca 2
7ddd02c9 3import { NotificationsService } from 'angular2-notifications';
28798b5d 4import { ServerDataSource } from 'ng2-smart-table';
7ddd02c9 5
5769e1db 6import { ConfirmService } from '../../../core';
28798b5d 7import { Utils } from '../../../shared';
e2f555ca
C
8import { Friend, FriendService } from '../shared';
9
10@Component({
11 selector: 'my-friend-list',
ec8d8440
C
12 templateUrl: './friend-list.component.html',
13 styleUrls: [ './friend-list.component.scss' ]
e2f555ca 14})
28798b5d
C
15export class FriendListComponent {
16 friendsSource = null;
17 tableSettings = {
18 attr: {
19 class: 'table-hover'
20 },
21 hideSubHeader: true,
22 actions: {
23 position: 'right',
24 add: false,
25 edit: false,
26 delete: false
27 },
28 columns: {
29 id: {
30 title: 'ID',
31 sort: false,
32 sortDirection: 'asc'
33 },
34 host: {
35 title: 'Host',
36 sort: false
37 },
38 score: {
39 title: 'Score',
40 sort: false
41 },
42 createdAt: {
43 title: 'Created Date',
44 sort: false,
45 valuePrepareFunction: Utils.dateToHuman
46 }
47 }
7af75da4 48 };
e2f555ca 49
7ddd02c9
C
50 constructor(
51 private notificationsService: NotificationsService,
5769e1db 52 private confirmService: ConfirmService,
7ddd02c9 53 private friendService: FriendService
28798b5d
C
54 ) {
55 this.friendsSource = this.friendService.getDataSource();
56 }
e2f555ca 57
28798b5d 58 hasFriends() {
7af75da4 59 return this.friendsSource.count() !== 0;
e2f555ca
C
60 }
61
e2f555ca 62 quitFriends() {
5769e1db
C
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(
65 res => {
66 if (res === false) return;
e2f555ca 67
5769e1db
C
68 this.friendService.quitFriends().subscribe(
69 status => {
70 this.notificationsService.success('Sucess', 'Friends left!');
7ddd02c9 71
28798b5d 72 this.friendsSource.refresh();
5769e1db 73 },
7ddd02c9 74
5769e1db
C
75 err => this.notificationsService.error('Error', err.text)
76 );
77 }
e2f555ca
C
78 );
79 }
80}