diff options
author | Chocobozzz <me@florianbigard.com> | 2019-11-29 11:16:43 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-11-29 11:16:43 +0100 |
commit | cb5ce4cb13095dbea6e5f05b96eaa42ffccf0716 (patch) | |
tree | fbfcb2b23b78a7dc464df22c166bee34b5b8bcb0 | |
parent | 97ecddae104f4013d261f0e9645e8b319ff0f1a6 (diff) | |
download | PeerTube-cb5ce4cb13095dbea6e5f05b96eaa42ffccf0716.tar.gz PeerTube-cb5ce4cb13095dbea6e5f05b96eaa42ffccf0716.tar.zst PeerTube-cb5ce4cb13095dbea6e5f05b96eaa42ffccf0716.zip |
Add more filters to admin follows table
5 files changed, 23 insertions, 13 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 7d5711926..6b5f3b450 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 | |||
@@ -13,10 +13,9 @@ | |||
13 | 13 | ||
14 | <ng-template pTemplate="header"> | 14 | <ng-template pTemplate="header"> |
15 | <tr> | 15 | <tr> |
16 | <th i18n style="width: 60px">ID</th> | ||
17 | <th i18n>Follower handle</th> | 16 | <th i18n>Follower handle</th> |
18 | <th i18n>State</th> | 17 | <th i18n pSortableColumn="state">State <p-sortIcon field="state"></p-sortIcon></th> |
19 | <th i18n>Score</th> | 18 | <th i18n pSortableColumn="score">Score <p-sortIcon field="score"></p-sortIcon></th> |
20 | <th i18n pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th> | 19 | <th i18n pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th> |
21 | <th></th> | 20 | <th></th> |
22 | </tr> | 21 | </tr> |
@@ -24,7 +23,6 @@ | |||
24 | 23 | ||
25 | <ng-template pTemplate="body" let-follow> | 24 | <ng-template pTemplate="body" let-follow> |
26 | <tr> | 25 | <tr> |
27 | <td>{{ follow.id }}</td> | ||
28 | <td><a [href]="follow.follower.url" target="_blank" rel="noopener noreferrer">{{ follow.follower.name + '@' + follow.follower.host }}</a></td> | 26 | <td><a [href]="follow.follower.url" target="_blank" rel="noopener noreferrer">{{ follow.follower.name + '@' + follow.follower.host }}</a></td> |
29 | 27 | ||
30 | <td *ngIf="follow.state === 'accepted'" i18n>Accepted</td> | 28 | <td *ngIf="follow.state === 'accepted'" i18n>Accepted</td> |
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 5bc8fbc2d..5a252eda9 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 | |||
@@ -15,18 +15,16 @@ | |||
15 | 15 | ||
16 | <ng-template pTemplate="header"> | 16 | <ng-template pTemplate="header"> |
17 | <tr> | 17 | <tr> |
18 | <th i18n style="width: 60px">ID</th> | ||
19 | <th i18n>Host</th> | 18 | <th i18n>Host</th> |
20 | <th i18n>State</th> | 19 | <th i18n pSortableColumn="state">State <p-sortIcon field="state"></p-sortIcon></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> |
22 | <th i18n>Redundancy allowed</th> | 21 | <th i18n pSortableColumn="redundancyAllowed">Redundancy allowed <p-sortIcon field="redundancyAllowed"></p-sortIcon></th> |
23 | <th></th> | 22 | <th></th> |
24 | </tr> | 23 | </tr> |
25 | </ng-template> | 24 | </ng-template> |
26 | 25 | ||
27 | <ng-template pTemplate="body" let-follow> | 26 | <ng-template pTemplate="body" let-follow> |
28 | <tr> | 27 | <tr> |
29 | <td>{{ follow.id }}</td> | ||
30 | <td>{{ follow.following.host }}</td> | 28 | <td>{{ follow.following.host }}</td> |
31 | 29 | ||
32 | <td *ngIf="follow.state === 'accepted'" i18n>Accepted</td> | 30 | <td *ngIf="follow.state === 'accepted'" i18n>Accepted</td> |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index eaad84bee..a1538f3ca 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -49,8 +49,8 @@ const SORTABLE_COLUMNS = { | |||
49 | VIDEO_COMMENT_THREADS: [ 'createdAt' ], | 49 | VIDEO_COMMENT_THREADS: [ 'createdAt' ], |
50 | VIDEO_RATES: [ 'createdAt' ], | 50 | VIDEO_RATES: [ 'createdAt' ], |
51 | BLACKLISTS: [ 'id', 'name', 'duration', 'views', 'likes', 'dislikes', 'uuid', 'createdAt' ], | 51 | BLACKLISTS: [ 'id', 'name', 'duration', 'views', 'likes', 'dislikes', 'uuid', 'createdAt' ], |
52 | FOLLOWERS: [ 'createdAt' ], | 52 | FOLLOWERS: [ 'createdAt', 'state', 'score' ], |
53 | FOLLOWING: [ 'createdAt' ], | 53 | FOLLOWING: [ 'createdAt', 'redundancyAllowed', 'state' ], |
54 | 54 | ||
55 | VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes', 'trending' ], | 55 | VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes', 'trending' ], |
56 | 56 | ||
diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts index c3c4d61ab..c65b975d2 100644 --- a/server/models/activitypub/actor-follow.ts +++ b/server/models/activitypub/actor-follow.ts | |||
@@ -23,7 +23,7 @@ import { logger } from '../../helpers/logger' | |||
23 | import { getServerActor } from '../../helpers/utils' | 23 | import { getServerActor } from '../../helpers/utils' |
24 | import { ACTOR_FOLLOW_SCORE, FOLLOW_STATES, SERVER_ACTOR_NAME } from '../../initializers/constants' | 24 | import { ACTOR_FOLLOW_SCORE, FOLLOW_STATES, SERVER_ACTOR_NAME } from '../../initializers/constants' |
25 | import { ServerModel } from '../server/server' | 25 | import { ServerModel } from '../server/server' |
26 | import { createSafeIn, getSort } from '../utils' | 26 | import { createSafeIn, getSort, getFollowsSort } from '../utils' |
27 | import { ActorModel, unusedActorAttributesForAPI } from './actor' | 27 | import { ActorModel, unusedActorAttributesForAPI } from './actor' |
28 | import { VideoChannelModel } from '../video/video-channel' | 28 | import { VideoChannelModel } from '../video/video-channel' |
29 | import { AccountModel } from '../account/account' | 29 | import { AccountModel } from '../account/account' |
@@ -324,7 +324,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> { | |||
324 | distinct: true, | 324 | distinct: true, |
325 | offset: start, | 325 | offset: start, |
326 | limit: count, | 326 | limit: count, |
327 | order: getSort(sort), | 327 | order: getFollowsSort(sort), |
328 | where: followWhere, | 328 | where: followWhere, |
329 | include: [ | 329 | include: [ |
330 | { | 330 | { |
@@ -391,7 +391,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> { | |||
391 | distinct: true, | 391 | distinct: true, |
392 | offset: start, | 392 | offset: start, |
393 | limit: count, | 393 | limit: count, |
394 | order: getSort(sort), | 394 | order: getFollowsSort(sort), |
395 | where: followWhere, | 395 | where: followWhere, |
396 | include: [ | 396 | include: [ |
397 | { | 397 | { |
diff --git a/server/models/utils.ts b/server/models/utils.ts index ccdbcd1cf..b53a52a05 100644 --- a/server/models/utils.ts +++ b/server/models/utils.ts | |||
@@ -58,6 +58,19 @@ function getBlacklistSort (model: any, value: string, lastSort: OrderItem = [ 'i | |||
58 | return [ firstSort, lastSort ] | 58 | return [ firstSort, lastSort ] |
59 | } | 59 | } |
60 | 60 | ||
61 | function getFollowsSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] { | ||
62 | const { direction, field } = buildDirectionAndField(value) | ||
63 | |||
64 | if (field === 'redundancyAllowed') { | ||
65 | return [ | ||
66 | [ 'ActorFollowing', 'Server', 'redundancyAllowed', direction ], | ||
67 | lastSort | ||
68 | ] | ||
69 | } | ||
70 | |||
71 | return getSort(value, lastSort) | ||
72 | } | ||
73 | |||
61 | function isOutdated (model: { createdAt: Date, updatedAt: Date }, refreshInterval: number) { | 74 | function isOutdated (model: { createdAt: Date, updatedAt: Date }, refreshInterval: number) { |
62 | const now = Date.now() | 75 | const now = Date.now() |
63 | const createdAtTime = model.createdAt.getTime() | 76 | const createdAtTime = model.createdAt.getTime() |
@@ -163,6 +176,7 @@ export { | |||
163 | buildWhereIdOrUUID, | 176 | buildWhereIdOrUUID, |
164 | isOutdated, | 177 | isOutdated, |
165 | parseAggregateResult, | 178 | parseAggregateResult, |
179 | getFollowsSort, | ||
166 | createSafeIn | 180 | createSafeIn |
167 | } | 181 | } |
168 | 182 | ||