This commit is contained in:
Wicklow 2023-11-30 12:35:50 -07:00 committed by GitHub
commit 0cb6b8792a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 2 deletions

View File

@ -4,9 +4,9 @@
</h1>
<p-table
[value]="users" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="pagination.start"
[value]="users" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="start"
[rowsPerPageOptions]="rowsPerPageOptions" [sortField]="sort.field" [sortOrder]="sort.order" dataKey="id" [resizableColumns]="true"
[(selection)]="selectedRows" [lazy]="true" (onLazyLoad)="loadLazy($event)" [lazyLoadOnInit]="false" [selectionPageOnly]="true"
[(selection)]="selectedRows" [lazy]="true" (onLazyLoad)="onLazyLoadHandler($event)" [lazyLoadOnInit]="false" [selectionPageOnly]="true"
[showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()" [expandedRowKeys]="expandedRows"
>
<ng-template pTemplate="caption">

View File

@ -9,6 +9,7 @@ import { AccountMutedStatus, BlocklistService, UserBanModalComponent, UserModera
import { UserAdminService } from '@app/shared/shared-users'
import { User, UserRole, UserRoleType } from '@peertube/peertube-models'
import { logger } from '@root-helpers/logger'
import { TableLazyLoadEvent } from 'primeng/table'
type UserForList = User & {
rawVideoQuota: number
@ -88,7 +89,18 @@ export class UserListComponent extends RestTable <User> implements OnInit {
this.saveSelectedColumns()
}
start = 0
ngOnInit () {
this.route.queryParams.subscribe(params => {
const paramPage = +params['page']
const paramCount = +params['count']
if (!isNaN(paramPage) && !isNaN(paramCount)) {
this.rowsPerPage = paramCount
this.start = paramCount * (paramPage - 1)
}
})
this.serverService.getConfig()
.subscribe(config => this.requiresEmailVerification = config.signup.requiresEmailVerification)
@ -321,4 +333,21 @@ export class UserListComponent extends RestTable <User> implements OnInit {
}
})
}
onLazyLoadHandler (event: TableLazyLoadEvent) {
this.loadLazy(event)
const url = new URL(window.location.href)
const page = event.first / event.rows + 1
url.searchParams.set('page', page.toString())
url.searchParams.set('count', event.rows.toString())
window.history.pushState({}, document.title, url.href)
this.start = event.first
this.pagination.start = this.start
}
}