aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+admin')
-rw-r--r--client/src/app/+admin/follows/followers-list/followers-list.component.html26
-rw-r--r--client/src/app/+admin/follows/followers-list/followers-list.component.ts105
-rw-r--r--client/src/app/+admin/follows/following-list/following-list.component.html24
-rw-r--r--client/src/app/+admin/follows/following-list/following-list.component.ts46
4 files changed, 155 insertions, 46 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 4f11f261d..8fe0d2348 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
@@ -9,9 +9,18 @@
9 [lazy]="true" (onLazyLoad)="loadLazy($event)" [lazyLoadOnInit]="false" 9 [lazy]="true" (onLazyLoad)="loadLazy($event)" [lazyLoadOnInit]="false"
10 [showCurrentPageReport]="true" i18n-currentPageReportTemplate 10 [showCurrentPageReport]="true" i18n-currentPageReportTemplate
11 currentPageReportTemplate="Showing {{'{first}'}} to {{'{last}'}} of {{'{totalRecords}'}} followers" 11 currentPageReportTemplate="Showing {{'{first}'}} to {{'{last}'}} of {{'{totalRecords}'}} followers"
12 [(selection)]="selectedFollows"
12> 13>
13 <ng-template pTemplate="caption"> 14 <ng-template pTemplate="caption">
14 <div class="caption"> 15 <div class="caption">
16 <div class="left-buttons">
17 <my-action-dropdown
18 *ngIf="isInSelectionMode()" i18n-label label="Batch actions" theme="orange"
19 [actions]="bulkFollowsActions" [entry]="selectedFollows"
20 >
21 </my-action-dropdown>
22 </div>
23
15 <div class="ms-auto"> 24 <div class="ms-auto">
16 <my-advanced-input-filter [filters]="searchFilters" (search)="onSearch($event)"></my-advanced-input-filter> 25 <my-advanced-input-filter [filters]="searchFilters" (search)="onSearch($event)"></my-advanced-input-filter>
17 </div> 26 </div>
@@ -20,6 +29,9 @@
20 29
21 <ng-template pTemplate="header"> 30 <ng-template pTemplate="header">
22 <tr> 31 <tr>
32 <th style="width: 40px">
33 <p-tableHeaderCheckbox ariaLabel="Select all rows" i18n-ariaLabel></p-tableHeaderCheckbox>
34 </th>
23 <th style="width: 150px;" i18n>Actions</th> 35 <th style="width: 150px;" i18n>Actions</th>
24 <th i18n>Follower</th> 36 <th i18n>Follower</th>
25 <th style="width: 100px;" i18n pSortableColumn="state">State <p-sortIcon field="state"></p-sortIcon></th> 37 <th style="width: 100px;" i18n pSortableColumn="state">State <p-sortIcon field="state"></p-sortIcon></th>
@@ -30,15 +42,19 @@
30 42
31 <ng-template pTemplate="body" let-follow> 43 <ng-template pTemplate="body" let-follow>
32 <tr> 44 <tr>
45 <td class="checkbox-cell">
46 <p-tableCheckbox [value]="follow" ariaLabel="Select this row" i18n-ariaLabel></p-tableCheckbox>
47 </td>
48
33 <td class="action-cell"> 49 <td class="action-cell">
34 <my-button *ngIf="follow.state !== 'accepted'" i18n-title title="Accept" icon="tick" (click)="acceptFollower(follow)"></my-button> 50 <my-button *ngIf="follow.state !== 'accepted'" i18n-title title="Accept" icon="tick" (click)="acceptFollower([ follow ])"></my-button>
35 <my-button *ngIf="follow.state !== 'rejected'" i18n-title title="Refuse" icon="cross" (click)="rejectFollower(follow)"></my-button> 51 <my-button *ngIf="follow.state !== 'rejected'" i18n-title title="Reject" icon="cross" (click)="rejectFollower([ follow ])"></my-button>
36 52
37 <my-delete-button *ngIf="follow.state === 'rejected'" (click)="deleteFollower(follow)"></my-delete-button> 53 <my-delete-button *ngIf="follow.state === 'rejected'" (click)="deleteFollowers([ follow ])"></my-delete-button>
38 </td> 54 </td>
39 <td> 55 <td>
40 <a [href]="follow.follower.url" i18n-title title="Open actor page in a new tab" target="_blank" rel="noopener noreferrer"> 56 <a [href]="follow.follower.url" i18n-title title="Open actor page in a new tab" target="_blank" rel="noopener noreferrer">
41 {{ follow.follower.name + '@' + follow.follower.host }} 57 {{ buildFollowerName(follow) }}
42 <my-global-icon iconName="external-link"></my-global-icon> 58 <my-global-icon iconName="external-link"></my-global-icon>
43 </a> 59 </a>
44 </td> 60 </td>
@@ -56,7 +72,7 @@
56 72
57 <ng-template pTemplate="emptymessage"> 73 <ng-template pTemplate="emptymessage">
58 <tr> 74 <tr>
59 <td colspan="5"> 75 <td colspan="6">
60 <div class="no-results"> 76 <div class="no-results">
61 <ng-container *ngIf="search" i18n>No follower found matching current filters.</ng-container> 77 <ng-container *ngIf="search" i18n>No follower found matching current filters.</ng-container>
62 <ng-container *ngIf="!search" i18n>Your instance doesn't have any follower.</ng-container> 78 <ng-container *ngIf="!search" i18n>Your instance doesn't have any follower.</ng-container>
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 d09e74fef..b2d333e83 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,8 +1,10 @@
1import { SortMeta } from 'primeng/api' 1import { SortMeta } from 'primeng/api'
2import { Component, OnInit } from '@angular/core' 2import { Component, OnInit } from '@angular/core'
3import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core' 3import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core'
4import { prepareIcu } from '@app/helpers'
4import { AdvancedInputFilter } from '@app/shared/shared-forms' 5import { AdvancedInputFilter } from '@app/shared/shared-forms'
5import { InstanceFollowService } from '@app/shared/shared-instance' 6import { InstanceFollowService } from '@app/shared/shared-instance'
7import { DropdownAction } from '@app/shared/shared-main'
6import { ActorFollow } from '@shared/models' 8import { ActorFollow } from '@shared/models'
7 9
8@Component({ 10@Component({
@@ -16,7 +18,10 @@ export class FollowersListComponent extends RestTable implements OnInit {
16 sort: SortMeta = { field: 'createdAt', order: -1 } 18 sort: SortMeta = { field: 'createdAt', order: -1 }
17 pagination: RestPagination = { count: this.rowsPerPage, start: 0 } 19 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
18 20
19 searchFilters: AdvancedInputFilter[] 21 searchFilters: AdvancedInputFilter[] = []
22
23 selectedFollows: ActorFollow[] = []
24 bulkFollowsActions: DropdownAction<ActorFollow[]>[] = []
20 25
21 constructor ( 26 constructor (
22 private confirmService: ConfirmService, 27 private confirmService: ConfirmService,
@@ -24,66 +29,104 @@ export class FollowersListComponent extends RestTable implements OnInit {
24 private followService: InstanceFollowService 29 private followService: InstanceFollowService
25 ) { 30 ) {
26 super() 31 super()
27
28 this.searchFilters = this.followService.buildFollowsListFilters()
29 } 32 }
30 33
31 ngOnInit () { 34 ngOnInit () {
32 this.initialize() 35 this.initialize()
36
37 this.searchFilters = this.followService.buildFollowsListFilters()
38
39 this.bulkFollowsActions = [
40 {
41 label: $localize`Reject`,
42 handler: follows => this.rejectFollower(follows),
43 isDisplayed: follows => follows.every(f => f.state !== 'rejected')
44 },
45 {
46 label: $localize`Accept`,
47 handler: follows => this.acceptFollower(follows),
48 isDisplayed: follows => follows.every(f => f.state !== 'accepted')
49 },
50 {
51 label: $localize`Delete`,
52 handler: follows => this.deleteFollowers(follows),
53 isDisplayed: follows => follows.every(f => f.state === 'rejected')
54 }
55 ]
33 } 56 }
34 57
35 getIdentifier () { 58 getIdentifier () {
36 return 'FollowersListComponent' 59 return 'FollowersListComponent'
37 } 60 }
38 61
39 acceptFollower (follow: ActorFollow) { 62 acceptFollower (follows: ActorFollow[]) {
40 follow.state = 'accepted' 63 this.followService.acceptFollower(follows)
41
42 this.followService.acceptFollower(follow)
43 .subscribe({ 64 .subscribe({
44 next: () => { 65 next: () => {
45 const handle = follow.follower.name + '@' + follow.follower.host 66 // eslint-disable-next-line max-len
46 this.notifier.success($localize`${handle} accepted in instance followers`) 67 const message = prepareIcu($localize`Accepted {count, plural, =1 {{followerName} follow request} other {{count} follow requests}}`)(
68 { count: follows.length, followerName: this.buildFollowerName(follows[0]) },
69 $localize`Follow requests accepted`
70 )
71 this.notifier.success(message)
72
73 this.reloadData()
47 }, 74 },
48 75
49 error: err => { 76 error: err => this.notifier.error(err.message)
50 follow.state = 'pending'
51 this.notifier.error(err.message)
52 }
53 }) 77 })
54 } 78 }
55 79
56 async rejectFollower (follow: ActorFollow) { 80 async rejectFollower (follows: ActorFollow[]) {
57 const message = $localize`Do you really want to reject this follower?` 81 // eslint-disable-next-line max-len
82 const message = prepareIcu($localize`Do you really want to reject {count, plural, =1 {{followerName} follow request?} other {{count} follow requests?}}`)(
83 { count: follows.length, followerName: this.buildFollowerName(follows[0]) },
84 $localize`Do you really want to reject these follow requests?`
85 )
86
58 const res = await this.confirmService.confirm(message, $localize`Reject`) 87 const res = await this.confirmService.confirm(message, $localize`Reject`)
59 if (res === false) return 88 if (res === false) return
60 89
61 this.followService.rejectFollower(follow) 90 this.followService.rejectFollower(follows)
62 .subscribe({ 91 .subscribe({
63 next: () => { 92 next: () => {
64 const handle = follow.follower.name + '@' + follow.follower.host 93 // eslint-disable-next-line max-len
65 this.notifier.success($localize`${handle} rejected from instance followers`) 94 const message = prepareIcu($localize`Rejected {count, plural, =1 {{followerName} follow request} other {{count} follow requests}}`)(
95 { count: follows.length, followerName: this.buildFollowerName(follows[0]) },
96 $localize`Follow requests rejected`
97 )
98 this.notifier.success(message)
66 99
67 this.reloadData() 100 this.reloadData()
68 }, 101 },
69 102
70 error: err => { 103 error: err => this.notifier.error(err.message)
71 follow.state = 'pending'
72 this.notifier.error(err.message)
73 }
74 }) 104 })
75 } 105 }
76 106
77 async deleteFollower (follow: ActorFollow) { 107 async deleteFollowers (follows: ActorFollow[]) {
78 const message = $localize`Do you really want to delete this follower? It will be able to send again another follow request.` 108 let message = $localize`Deleted followers will be able to send again a follow request.`
109 message += '<br /><br />'
110
111 // eslint-disable-next-line max-len
112 message += prepareIcu($localize`Do you really want to delete {count, plural, =1 {{followerName} follow request?} other {{count} follow requests?}}`)(
113 { count: follows.length, followerName: this.buildFollowerName(follows[0]) },
114 $localize`Do you really want to delete these follow requests?`
115 )
116
79 const res = await this.confirmService.confirm(message, $localize`Delete`) 117 const res = await this.confirmService.confirm(message, $localize`Delete`)
80 if (res === false) return 118 if (res === false) return
81 119
82 this.followService.removeFollower(follow) 120 this.followService.removeFollower(follows)
83 .subscribe({ 121 .subscribe({
84 next: () => { 122 next: () => {
85 const handle = follow.follower.name + '@' + follow.follower.host 123 // eslint-disable-next-line max-len
86 this.notifier.success($localize`${handle} removed from instance followers`) 124 const message = prepareIcu($localize`Removed {count, plural, =1 {{followerName} follow request} other {{count} follow requests}}`)(
125 { count: follows.length, followerName: this.buildFollowerName(follows[0]) },
126 $localize`Follow requests removed`
127 )
128
129 this.notifier.success(message)
87 130
88 this.reloadData() 131 this.reloadData()
89 }, 132 },
@@ -92,6 +135,14 @@ export class FollowersListComponent extends RestTable implements OnInit {
92 }) 135 })
93 } 136 }
94 137
138 buildFollowerName (follow: ActorFollow) {
139 return follow.follower.name + '@' + follow.follower.host
140 }
141
142 isInSelectionMode () {
143 return this.selectedFollows.length !== 0
144 }
145
95 protected reloadData () { 146 protected reloadData () {
96 this.followService.getFollowers({ pagination: this.pagination, sort: this.sort, search: this.search }) 147 this.followService.getFollowers({ pagination: this.pagination, sort: this.sort, search: this.search })
97 .subscribe({ 148 .subscribe({
diff --git a/client/src/app/+admin/follows/following-list/following-list.component.html b/client/src/app/+admin/follows/following-list/following-list.component.html
index 856c4a31f..4554bf151 100644
--- a/client/src/app/+admin/follows/following-list/following-list.component.html
+++ b/client/src/app/+admin/follows/following-list/following-list.component.html
@@ -9,11 +9,18 @@
9 [lazy]="true" (onLazyLoad)="loadLazy($event)" [lazyLoadOnInit]="false" 9 [lazy]="true" (onLazyLoad)="loadLazy($event)" [lazyLoadOnInit]="false"
10 [showCurrentPageReport]="true" i18n-currentPageReportTemplate 10 [showCurrentPageReport]="true" i18n-currentPageReportTemplate
11 currentPageReportTemplate="Showing {{'{first}'}} to {{'{last}'}} of {{'{totalRecords}'}} hosts" 11 currentPageReportTemplate="Showing {{'{first}'}} to {{'{last}'}} of {{'{totalRecords}'}} hosts"
12 [(selection)]="selectedFollows"
12> 13>
13 <ng-template pTemplate="caption"> 14 <ng-template pTemplate="caption">
14 <div class="caption"> 15 <div class="caption">
15 <div class="left-buttons"> 16 <div class="left-buttons">
16 <a class="follow-button" (click)="openFollowModal()" (key.enter)="openFollowModal()"> 17 <my-action-dropdown
18 *ngIf="isInSelectionMode()" i18n-label label="Batch actions" theme="orange"
19 [actions]="bulkFollowsActions" [entry]="selectedFollows"
20 >
21 </my-action-dropdown>
22
23 <a *ngIf="!isInSelectionMode()" class="follow-button" (click)="openFollowModal()" (key.enter)="openFollowModal()">
17 <my-global-icon iconName="following" aria-hidden="true"></my-global-icon> 24 <my-global-icon iconName="following" aria-hidden="true"></my-global-icon>
18 <ng-container i18n>Follow</ng-container> 25 <ng-container i18n>Follow</ng-container>
19 </a> 26 </a>
@@ -27,6 +34,9 @@
27 34
28 <ng-template pTemplate="header"> 35 <ng-template pTemplate="header">
29 <tr> 36 <tr>
37 <th style="width: 40px">
38 <p-tableHeaderCheckbox ariaLabel="Select all rows" i18n-ariaLabel></p-tableHeaderCheckbox>
39 </th>
30 <th style="width: 150px;" i18n>Action</th> 40 <th style="width: 150px;" i18n>Action</th>
31 <th i18n>Following</th> 41 <th i18n>Following</th>
32 <th style="width: 100px;" i18n pSortableColumn="state">State <p-sortIcon field="state"></p-sortIcon></th> 42 <th style="width: 100px;" i18n pSortableColumn="state">State <p-sortIcon field="state"></p-sortIcon></th>
@@ -35,14 +45,18 @@
35 </tr> 45 </tr>
36 </ng-template> 46 </ng-template>
37 47
38 <ng-template pTemplate="body" let-follow> 48 <ng-template pSelectableRow="follow" pTemplate="body" let-follow>
39 <tr> 49 <tr>
50 <td class="checkbox-cell">
51 <p-tableCheckbox [value]="follow" ariaLabel="Select this row" i18n-ariaLabel></p-tableCheckbox>
52 </td>
53
40 <td class="action-cell"> 54 <td class="action-cell">
41 <my-delete-button label (click)="removeFollowing(follow)"></my-delete-button> 55 <my-delete-button label (click)="removeFollowing([ follow ])"></my-delete-button>
42 </td> 56 </td>
43 <td> 57 <td>
44 <a [href]="follow.following.url" i18n-title title="Open instance in a new tab" target="_blank" rel="noopener noreferrer"> 58 <a [href]="follow.following.url" i18n-title title="Open instance in a new tab" target="_blank" rel="noopener noreferrer">
45 {{ follow.following.name + '@' + follow.following.host }} 59 {{ buildFollowingName(follow) }}
46 <my-global-icon iconName="external-link"></my-global-icon> 60 <my-global-icon iconName="external-link"></my-global-icon>
47 </a> 61 </a>
48 </td> 62 </td>
@@ -65,7 +79,7 @@
65 79
66 <ng-template pTemplate="emptymessage"> 80 <ng-template pTemplate="emptymessage">
67 <tr> 81 <tr>
68 <td colspan="5"> 82 <td colspan="6">
69 <div class="no-results"> 83 <div class="no-results">
70 <ng-container *ngIf="search" i18n>No host found matching current filters.</ng-container> 84 <ng-container *ngIf="search" i18n>No host found matching current filters.</ng-container>
71 <ng-container *ngIf="!search" i18n>Your instance is not following anyone.</ng-container> 85 <ng-container *ngIf="!search" i18n>Your instance is not following anyone.</ng-container>
diff --git a/client/src/app/+admin/follows/following-list/following-list.component.ts b/client/src/app/+admin/follows/following-list/following-list.component.ts
index 7a854be81..e3a56651a 100644
--- a/client/src/app/+admin/follows/following-list/following-list.component.ts
+++ b/client/src/app/+admin/follows/following-list/following-list.component.ts
@@ -5,6 +5,8 @@ import { AdvancedInputFilter } from '@app/shared/shared-forms'
5import { InstanceFollowService } from '@app/shared/shared-instance' 5import { InstanceFollowService } from '@app/shared/shared-instance'
6import { ActorFollow } from '@shared/models' 6import { ActorFollow } from '@shared/models'
7import { FollowModalComponent } from './follow-modal.component' 7import { FollowModalComponent } from './follow-modal.component'
8import { DropdownAction } from '@app/shared/shared-main'
9import { prepareIcu } from '@app/helpers'
8 10
9@Component({ 11@Component({
10 templateUrl: './following-list.component.html', 12 templateUrl: './following-list.component.html',
@@ -18,7 +20,10 @@ export class FollowingListComponent extends RestTable implements OnInit {
18 sort: SortMeta = { field: 'createdAt', order: -1 } 20 sort: SortMeta = { field: 'createdAt', order: -1 }
19 pagination: RestPagination = { count: this.rowsPerPage, start: 0 } 21 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
20 22
21 searchFilters: AdvancedInputFilter[] 23 searchFilters: AdvancedInputFilter[] = []
24
25 selectedFollows: ActorFollow[] = []
26 bulkFollowsActions: DropdownAction<ActorFollow[]>[] = []
22 27
23 constructor ( 28 constructor (
24 private notifier: Notifier, 29 private notifier: Notifier,
@@ -26,12 +31,19 @@ export class FollowingListComponent extends RestTable implements OnInit {
26 private followService: InstanceFollowService 31 private followService: InstanceFollowService
27 ) { 32 ) {
28 super() 33 super()
29
30 this.searchFilters = this.followService.buildFollowsListFilters()
31 } 34 }
32 35
33 ngOnInit () { 36 ngOnInit () {
34 this.initialize() 37 this.initialize()
38
39 this.searchFilters = this.followService.buildFollowsListFilters()
40
41 this.bulkFollowsActions = [
42 {
43 label: $localize`Delete`,
44 handler: follows => this.removeFollowing(follows)
45 }
46 ]
35 } 47 }
36 48
37 getIdentifier () { 49 getIdentifier () {
@@ -46,17 +58,33 @@ export class FollowingListComponent extends RestTable implements OnInit {
46 return follow.following.name === 'peertube' 58 return follow.following.name === 'peertube'
47 } 59 }
48 60
49 async removeFollowing (follow: ActorFollow) { 61 isInSelectionMode () {
50 const res = await this.confirmService.confirm( 62 return this.selectedFollows.length !== 0
51 $localize`Do you really want to unfollow ${follow.following.host}?`, 63 }
52 $localize`Unfollow` 64
65 buildFollowingName (follow: ActorFollow) {
66 return follow.following.name + '@' + follow.following.host
67 }
68
69 async removeFollowing (follows: ActorFollow[]) {
70 const message = prepareIcu($localize`Do you really want to unfollow {count, plural, =1 {{entryName}?} other {{count} entries?}}`)(
71 { count: follows.length, entryName: this.buildFollowingName(follows[0]) },
72 $localize`Do you really want to unfollow these entries?`
53 ) 73 )
74
75 const res = await this.confirmService.confirm(message, $localize`Unfollow`)
54 if (res === false) return 76 if (res === false) return
55 77
56 this.followService.unfollow(follow) 78 this.followService.unfollow(follows)
57 .subscribe({ 79 .subscribe({
58 next: () => { 80 next: () => {
59 this.notifier.success($localize`You are not following ${follow.following.host} anymore.`) 81 // eslint-disable-next-line max-len
82 const message = prepareIcu($localize`You are not following {count, plural, =1 {{entryName} anymore.} other {these {count} entries anymore.}}`)(
83 { count: follows.length, entryName: this.buildFollowingName(follows[0]) },
84 $localize`You are not following them anymore.`
85 )
86
87 this.notifier.success(message)
60 this.reloadData() 88 this.reloadData()
61 }, 89 },
62 90