diff options
Diffstat (limited to 'client/src/app/+admin/follows/followers-list')
3 files changed, 81 insertions, 11 deletions
diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.html b/client/src/app/+admin/follows/followers-list/followers-list.component.html index fc022bdb4..da0ba95e3 100644 --- a/client/src/app/+admin/follows/followers-list/followers-list.component.html +++ b/client/src/app/+admin/follows/followers-list/followers-list.component.html | |||
@@ -14,25 +14,33 @@ | |||
14 | <ng-template pTemplate="header"> | 14 | <ng-template pTemplate="header"> |
15 | <tr> | 15 | <tr> |
16 | <th i18n style="width: 60px">ID</th> | 16 | <th i18n style="width: 60px">ID</th> |
17 | <th i18n>Score</th> | 17 | <th i18n>Follower handle</th> |
18 | <th i18n>Name</th> | ||
19 | <th i18n>Host</th> | ||
20 | <th i18n>State</th> | 18 | <th i18n>State</th> |
19 | <th i18n>Score</th> | ||
21 | <th i18n pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th> | 20 | <th i18n pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th> |
21 | <th></th> | ||
22 | </tr> | 22 | </tr> |
23 | </ng-template> | 23 | </ng-template> |
24 | 24 | ||
25 | <ng-template pTemplate="body" let-follow> | 25 | <ng-template pTemplate="body" let-follow> |
26 | <tr> | 26 | <tr> |
27 | <td>{{ follow.id }}</td> | 27 | <td>{{ follow.id }}</td> |
28 | <td>{{ follow.score }}</td> | 28 | <td>{{ follow.follower.name + '@' + follow.follower.host }}</td> |
29 | <td>{{ follow.follower.name }}</td> | ||
30 | <td>{{ follow.follower.host }}</td> | ||
31 | 29 | ||
32 | <td *ngIf="follow.state === 'accepted'" i18n>Accepted</td> | 30 | <td *ngIf="follow.state === 'accepted'" i18n>Accepted</td> |
33 | <td *ngIf="follow.state === 'pending'" i18n>Pending</td> | 31 | <td *ngIf="follow.state === 'pending'" i18n>Pending</td> |
34 | 32 | ||
33 | <td>{{ follow.score }}</td> | ||
35 | <td>{{ follow.createdAt }}</td> | 34 | <td>{{ follow.createdAt }}</td> |
35 | |||
36 | <td class="action-cell"> | ||
37 | <ng-container *ngIf="follow.state === 'pending'"> | ||
38 | <my-button i18n-label label="Accept" icon="tick" (click)="acceptFollower(follow)"></my-button> | ||
39 | <my-button i18n-label label="Refuse" icon="cross" (click)="rejectFollower(follow)"></my-button> | ||
40 | </ng-container> | ||
41 | |||
42 | <my-delete-button *ngIf="follow.state === 'accepted'" (click)="deleteFollower(follow)"></my-delete-button> | ||
43 | </td> | ||
36 | </tr> | 44 | </tr> |
37 | </ng-template> | 45 | </ng-template> |
38 | </p-table> | 46 | </p-table> |
diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.scss b/client/src/app/+admin/follows/followers-list/followers-list.component.scss index a6f0656b8..964b3f99b 100644 --- a/client/src/app/+admin/follows/followers-list/followers-list.component.scss +++ b/client/src/app/+admin/follows/followers-list/followers-list.component.scss | |||
@@ -7,4 +7,10 @@ | |||
7 | input { | 7 | input { |
8 | @include peertube-input-text(250px); | 8 | @include peertube-input-text(250px); |
9 | } | 9 | } |
10 | } \ No newline at end of file | 10 | } |
11 | |||
12 | .action-cell { | ||
13 | my-button:first-child { | ||
14 | margin-right: 10px; | ||
15 | } | ||
16 | } | ||
diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.ts b/client/src/app/+admin/follows/followers-list/followers-list.component.ts index 9a8848bfb..b78cdf656 100644 --- a/client/src/app/+admin/follows/followers-list/followers-list.component.ts +++ b/client/src/app/+admin/follows/followers-list/followers-list.component.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component, OnInit } from '@angular/core' |
2 | 2 | import { ConfirmService, Notifier } from '@app/core' | |
3 | import { Notifier } from '@app/core' | ||
4 | import { SortMeta } from 'primeng/primeng' | 3 | import { SortMeta } from 'primeng/primeng' |
5 | import { ActorFollow } from '../../../../../../shared/models/actors/follow.model' | 4 | import { ActorFollow } from '../../../../../../shared/models/actors/follow.model' |
6 | import { RestPagination, RestTable } from '../../../shared' | 5 | import { RestPagination, RestTable } from '../../../shared' |
@@ -20,9 +19,10 @@ export class FollowersListComponent extends RestTable implements OnInit { | |||
20 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | 19 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } |
21 | 20 | ||
22 | constructor ( | 21 | constructor ( |
22 | private confirmService: ConfirmService, | ||
23 | private notifier: Notifier, | 23 | private notifier: Notifier, |
24 | private followService: FollowService, | 24 | private i18n: I18n, |
25 | private i18n: I18n | 25 | private followService: FollowService |
26 | ) { | 26 | ) { |
27 | super() | 27 | super() |
28 | } | 28 | } |
@@ -31,6 +31,62 @@ export class FollowersListComponent extends RestTable implements OnInit { | |||
31 | this.initialize() | 31 | this.initialize() |
32 | } | 32 | } |
33 | 33 | ||
34 | acceptFollower (follow: ActorFollow) { | ||
35 | follow.state = 'accepted' | ||
36 | |||
37 | this.followService.acceptFollower(follow) | ||
38 | .subscribe( | ||
39 | () => { | ||
40 | const handle = follow.follower.name + '@' + follow.follower.host | ||
41 | this.notifier.success(this.i18n('{{handle}} accepted in instance followers', { handle })) | ||
42 | }, | ||
43 | |||
44 | err => { | ||
45 | follow.state = 'pending' | ||
46 | this.notifier.error(err.message) | ||
47 | } | ||
48 | ) | ||
49 | } | ||
50 | |||
51 | async rejectFollower (follow: ActorFollow) { | ||
52 | const message = this.i18n('Do you really want to reject this follower?') | ||
53 | const res = await this.confirmService.confirm(message, this.i18n('Reject')) | ||
54 | if (res === false) return | ||
55 | |||
56 | this.followService.rejectFollower(follow) | ||
57 | .subscribe( | ||
58 | () => { | ||
59 | const handle = follow.follower.name + '@' + follow.follower.host | ||
60 | this.notifier.success(this.i18n('{{handle}} rejected from instance followers', { handle })) | ||
61 | |||
62 | this.loadData() | ||
63 | }, | ||
64 | |||
65 | err => { | ||
66 | follow.state = 'pending' | ||
67 | this.notifier.error(err.message) | ||
68 | } | ||
69 | ) | ||
70 | } | ||
71 | |||
72 | async deleteFollower (follow: ActorFollow) { | ||
73 | const message = this.i18n('Do you really want to delete this follower?') | ||
74 | const res = await this.confirmService.confirm(message, this.i18n('Delete')) | ||
75 | if (res === false) return | ||
76 | |||
77 | this.followService.removeFollower(follow) | ||
78 | .subscribe( | ||
79 | () => { | ||
80 | const handle = follow.follower.name + '@' + follow.follower.host | ||
81 | this.notifier.success(this.i18n('{{handle}} removed from instance followers', { handle })) | ||
82 | |||
83 | this.loadData() | ||
84 | }, | ||
85 | |||
86 | err => this.notifier.error(err.message) | ||
87 | ) | ||
88 | } | ||
89 | |||
34 | protected loadData () { | 90 | protected loadData () { |
35 | this.followService.getFollowers(this.pagination, this.sort, this.search) | 91 | this.followService.getFollowers(this.pagination, this.sort, this.search) |
36 | .subscribe( | 92 | .subscribe( |