core: add paginator keys

This commit is contained in:
undefined committed 2024-01-16 03:01:35 +08:00
1 parent 5d2ac74b04
commit 911676b050
7 files changed
+21 -23

No files matched your search

+6
View File
@@ -9,6 +9,7 @@ import Body from 'koa-body';
import Compress from 'koa-compress';
import proxy from 'koa-proxies';
import cache from 'koa-static-cache';
import type { FindCursor } from 'mongodb';
import WebSocket from 'ws';
import { Counter, isClass, parseMemoryMB } from '@hydrooj/utils/lib/utils';
import { Context, Service } from '../context';
@@ -18,6 +19,7 @@ import {
PrivilegeError, UserFacingError,
} from '../error';
import { DomainDoc } from '../interface';
import paginate from '../lib/paginate';
import serializer from '../lib/serializer';
import { Types } from '../lib/validator';
import { Logger } from '../logger';
@@ -150,6 +152,10 @@ export class HandlerCommon {
await opcount.inc(op, id, periodSecs, maxOperations);
}
paginate<T>(cursor: FindCursor<T>, page: number, key: string) {
return paginate(cursor, page, this.ctx.setting.get(`pagination.${key}`));
}
renderTitle(str: string) {
const name = this.domain?.ui?.name || system.get('server.name');
if (this.UiContext.extraTitleContent) return `${this.translate(str)} - ${this.UiContext.extraTitleContent} - ${name}`;