]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/follows/followers-list/followers-list.component.ts
Increase global font size
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / follows / followers-list / followers-list.component.ts
CommitLineData
41b15c89 1import { SortMeta } from 'primeng/api'
67ed6552
C
2import { Component, OnInit } from '@angular/core'
3import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core'
4import { InstanceFollowService } from '@app/shared/shared-instance'
67ed6552 5import { ActorFollow } from '@shared/models'
51548b31
C
6
7@Component({
8 selector: 'my-followers-list',
9 templateUrl: './followers-list.component.html',
eeae8142 10 styleUrls: [ './followers-list.component.scss' ]
51548b31 11})
ab998f7b 12export class FollowersListComponent extends RestTable implements OnInit {
c48e82b5 13 followers: ActorFollow[] = []
51548b31 14 totalRecords = 0
bb152476 15 sort: SortMeta = { field: 'createdAt', order: -1 }
51548b31
C
16 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
17
18 constructor (
0dc64777 19 private confirmService: ConfirmService,
f8b2c1b4 20 private notifier: Notifier,
67ed6552 21 private followService: InstanceFollowService
51548b31
C
22 ) {
23 super()
24 }
25
ab998f7b 26 ngOnInit () {
24b9417c 27 this.initialize()
ab998f7b
C
28 }
29
8e11a1b3
C
30 getIdentifier () {
31 return 'FollowersListComponent'
32 }
33
0dc64777
C
34 acceptFollower (follow: ActorFollow) {
35 follow.state = 'accepted'
36
37 this.followService.acceptFollower(follow)
1378c0d3
C
38 .subscribe({
39 next: () => {
0dc64777 40 const handle = follow.follower.name + '@' + follow.follower.host
66357162 41 this.notifier.success($localize`${handle} accepted in instance followers`)
0dc64777
C
42 },
43
1378c0d3 44 error: err => {
0dc64777
C
45 follow.state = 'pending'
46 this.notifier.error(err.message)
47 }
1378c0d3 48 })
0dc64777
C
49 }
50
51 async rejectFollower (follow: ActorFollow) {
66357162
C
52 const message = $localize`Do you really want to reject this follower?`
53 const res = await this.confirmService.confirm(message, $localize`Reject`)
0dc64777
C
54 if (res === false) return
55
56 this.followService.rejectFollower(follow)
1378c0d3
C
57 .subscribe({
58 next: () => {
0dc64777 59 const handle = follow.follower.name + '@' + follow.follower.host
66357162 60 this.notifier.success($localize`${handle} rejected from instance followers`)
0dc64777 61
2e46eb97 62 this.reloadData()
0dc64777
C
63 },
64
1378c0d3 65 error: err => {
0dc64777
C
66 follow.state = 'pending'
67 this.notifier.error(err.message)
68 }
1378c0d3 69 })
0dc64777
C
70 }
71
72 async deleteFollower (follow: ActorFollow) {
66357162
C
73 const message = $localize`Do you really want to delete this follower?`
74 const res = await this.confirmService.confirm(message, $localize`Delete`)
0dc64777
C
75 if (res === false) return
76
77 this.followService.removeFollower(follow)
1378c0d3
C
78 .subscribe({
79 next: () => {
0dc64777 80 const handle = follow.follower.name + '@' + follow.follower.host
66357162 81 this.notifier.success($localize`${handle} removed from instance followers`)
0dc64777 82
2e46eb97 83 this.reloadData()
0dc64777
C
84 },
85
1378c0d3
C
86 error: err => this.notifier.error(err.message)
87 })
0dc64777
C
88 }
89
2e46eb97 90 protected reloadData () {
b8f4167f 91 this.followService.getFollowers({ pagination: this.pagination, sort: this.sort, search: this.search })
1378c0d3
C
92 .subscribe({
93 next: resultList => {
51548b31
C
94 this.followers = resultList.data
95 this.totalRecords = resultList.total
96 },
97
1378c0d3
C
98 error: err => this.notifier.error(err.message)
99 })
51548b31
C
100 }
101}