Add more filters to admin follows table

pull/2301/head
Chocobozzz 2019-11-29 11:16:43 +01:00
parent 97ecddae10
commit cb5ce4cb13
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
5 changed files with 23 additions and 13 deletions

View File

@ -13,10 +13,9 @@
<ng-template pTemplate="header"> <ng-template pTemplate="header">
<tr> <tr>
<th i18n style="width: 60px">ID</th>
<th i18n>Follower handle</th> <th i18n>Follower handle</th>
<th i18n>State</th> <th i18n pSortableColumn="state">State <p-sortIcon field="state"></p-sortIcon></th>
<th i18n>Score</th> <th i18n pSortableColumn="score">Score <p-sortIcon field="score"></p-sortIcon></th>
<th i18n pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th> <th i18n pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th>
<th></th> <th></th>
</tr> </tr>
@ -24,7 +23,6 @@
<ng-template pTemplate="body" let-follow> <ng-template pTemplate="body" let-follow>
<tr> <tr>
<td>{{ follow.id }}</td>
<td><a [href]="follow.follower.url" target="_blank" rel="noopener noreferrer">{{ follow.follower.name + '@' + follow.follower.host }}</a></td> <td><a [href]="follow.follower.url" target="_blank" rel="noopener noreferrer">{{ follow.follower.name + '@' + follow.follower.host }}</a></td>
<td *ngIf="follow.state === 'accepted'" i18n>Accepted</td> <td *ngIf="follow.state === 'accepted'" i18n>Accepted</td>

View File

@ -15,18 +15,16 @@
<ng-template pTemplate="header"> <ng-template pTemplate="header">
<tr> <tr>
<th i18n style="width: 60px">ID</th>
<th i18n>Host</th> <th i18n>Host</th>
<th i18n>State</th> <th i18n pSortableColumn="state">State <p-sortIcon field="state"></p-sortIcon></th>
<th i18n pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th> <th i18n pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th>
<th i18n>Redundancy allowed</th> <th i18n pSortableColumn="redundancyAllowed">Redundancy allowed <p-sortIcon field="redundancyAllowed"></p-sortIcon></th>
<th></th> <th></th>
</tr> </tr>
</ng-template> </ng-template>
<ng-template pTemplate="body" let-follow> <ng-template pTemplate="body" let-follow>
<tr> <tr>
<td>{{ follow.id }}</td>
<td>{{ follow.following.host }}</td> <td>{{ follow.following.host }}</td>
<td *ngIf="follow.state === 'accepted'" i18n>Accepted</td> <td *ngIf="follow.state === 'accepted'" i18n>Accepted</td>

View File

@ -49,8 +49,8 @@ const SORTABLE_COLUMNS = {
VIDEO_COMMENT_THREADS: [ 'createdAt' ], VIDEO_COMMENT_THREADS: [ 'createdAt' ],
VIDEO_RATES: [ 'createdAt' ], VIDEO_RATES: [ 'createdAt' ],
BLACKLISTS: [ 'id', 'name', 'duration', 'views', 'likes', 'dislikes', 'uuid', 'createdAt' ], BLACKLISTS: [ 'id', 'name', 'duration', 'views', 'likes', 'dislikes', 'uuid', 'createdAt' ],
FOLLOWERS: [ 'createdAt' ], FOLLOWERS: [ 'createdAt', 'state', 'score' ],
FOLLOWING: [ 'createdAt' ], FOLLOWING: [ 'createdAt', 'redundancyAllowed', 'state' ],
VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes', 'trending' ], VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes', 'trending' ],

View File

@ -23,7 +23,7 @@ import { logger } from '../../helpers/logger'
import { getServerActor } from '../../helpers/utils' import { getServerActor } from '../../helpers/utils'
import { ACTOR_FOLLOW_SCORE, FOLLOW_STATES, SERVER_ACTOR_NAME } from '../../initializers/constants' import { ACTOR_FOLLOW_SCORE, FOLLOW_STATES, SERVER_ACTOR_NAME } from '../../initializers/constants'
import { ServerModel } from '../server/server' import { ServerModel } from '../server/server'
import { createSafeIn, getSort } from '../utils' import { createSafeIn, getSort, getFollowsSort } from '../utils'
import { ActorModel, unusedActorAttributesForAPI } from './actor' import { ActorModel, unusedActorAttributesForAPI } from './actor'
import { VideoChannelModel } from '../video/video-channel' import { VideoChannelModel } from '../video/video-channel'
import { AccountModel } from '../account/account' import { AccountModel } from '../account/account'
@ -324,7 +324,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
distinct: true, distinct: true,
offset: start, offset: start,
limit: count, limit: count,
order: getSort(sort), order: getFollowsSort(sort),
where: followWhere, where: followWhere,
include: [ include: [
{ {
@ -391,7 +391,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
distinct: true, distinct: true,
offset: start, offset: start,
limit: count, limit: count,
order: getSort(sort), order: getFollowsSort(sort),
where: followWhere, where: followWhere,
include: [ include: [
{ {

View File

@ -58,6 +58,19 @@ function getBlacklistSort (model: any, value: string, lastSort: OrderItem = [ 'i
return [ firstSort, lastSort ] return [ firstSort, lastSort ]
} }
function getFollowsSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] {
const { direction, field } = buildDirectionAndField(value)
if (field === 'redundancyAllowed') {
return [
[ 'ActorFollowing', 'Server', 'redundancyAllowed', direction ],
lastSort
]
}
return getSort(value, lastSort)
}
function isOutdated (model: { createdAt: Date, updatedAt: Date }, refreshInterval: number) { function isOutdated (model: { createdAt: Date, updatedAt: Date }, refreshInterval: number) {
const now = Date.now() const now = Date.now()
const createdAtTime = model.createdAt.getTime() const createdAtTime = model.createdAt.getTime()
@ -163,6 +176,7 @@ export {
buildWhereIdOrUUID, buildWhereIdOrUUID,
isOutdated, isOutdated,
parseAggregateResult, parseAggregateResult,
getFollowsSort,
createSafeIn createSafeIn
} }