]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+admin/follows/following-list/following-list.component.ts
Begin moving video channel to actor
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / follows / following-list / following-list.component.ts
1 import { Component } from '@angular/core'
2 import { NotificationsService } from 'angular2-notifications'
3 import { SortMeta } from 'primeng/primeng'
4 import { AccountFollow } from '../../../../../../shared/models/actors/follow.model'
5 import { ConfirmService } from '../../../core/confirm/confirm.service'
6 import { RestPagination, RestTable } from '../../../shared'
7 import { FollowService } from '../shared'
8
9 @Component({
10 selector: 'my-followers-list',
11 templateUrl: './following-list.component.html'
12 })
13 export class FollowingListComponent extends RestTable {
14 following: AccountFollow[] = []
15 totalRecords = 0
16 rowsPerPage = 10
17 sort: SortMeta = { field: 'createdAt', order: 1 }
18 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
19
20 constructor (
21 private notificationsService: NotificationsService,
22 private confirmService: ConfirmService,
23 private followService: FollowService
24 ) {
25 super()
26 }
27
28 removeFollowing (follow: AccountFollow) {
29 this.confirmService.confirm(`Do you really want to unfollow ${follow.following.host}?`, 'Unfollow').subscribe(
30 res => {
31 if (res === false) return
32
33 this.followService.unfollow(follow).subscribe(
34 () => {
35 this.notificationsService.success('Success', `You are not following ${follow.following.host} anymore.`)
36 this.loadData()
37 },
38
39 err => this.notificationsService.error('Error', err.message)
40 )
41 }
42 )
43 }
44
45 protected loadData () {
46 this.followService.getFollowing(this.pagination, this.sort)
47 .subscribe(
48 resultList => {
49 this.following = resultList.data
50 this.totalRecords = resultList.total
51 },
52
53 err => this.notificationsService.error('Error', err.message)
54 )
55 }
56 }