scoreboard_ui
undefined 2 years ago
parent a0ef60bfeb
commit 4fe734a6f3

@ -6,7 +6,7 @@ ignorePatterns:
- packages/ui-default - packages/ui-default
overrides: overrides:
- files: - files:
- '**/public/**/*.{ts,tsx,page.js}' - '**/{public,frontend}/**/*.{ts,tsx,page.js}'
rules: rules:
'@typescript-eslint/indent': '@typescript-eslint/indent':
- warn - warn

@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "4.7.8", "version": "4.7.9",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "src/plugin-api", "main": "src/plugin-api",
"module": "src/plugin-api", "module": "src/plugin-api",

@ -99,27 +99,23 @@ class TrainingMainHandler extends Handler {
class TrainingDetailHandler extends Handler { class TrainingDetailHandler extends Handler {
@param('tid', Types.ObjectID) @param('tid', Types.ObjectID)
@param('uid', Types.PositiveInt, true) @param('uid', Types.PositiveInt, true)
async get(domainId: string, tid: ObjectID, uid: number) { async get(domainId: string, tid: ObjectID, uid = this.user._id) {
const tdoc = await training.get(domainId, tid); const tdoc = await training.get(domainId, tid);
await this.ctx.parallel('training/get', tdoc, this); await this.ctx.parallel('training/get', tdoc, this);
let targetUser = this.user._id;
let enrollUsers: number[] = []; let enrollUsers: number[] = [];
let shouldCompare = false; let shouldCompare = false;
const pids = training.getPids(tdoc.dag); const pids = training.getPids(tdoc.dag);
if (this.user.hasPriv(PRIV.PRIV_USER_PROFILE)) { if (this.user.hasPriv(PRIV.PRIV_USER_PROFILE)) {
enrollUsers = (await training.getMultiStatus(domainId, { docId: tid, uid: { $gt: 1 } }) enrollUsers = (await training.getMultiStatus(domainId, { docId: tid, uid: { $gt: 1 } })
.project({ uid: 1 }).limit(500).toArray()).map((x) => +x.uid); .project({ uid: 1 }).limit(500).toArray()).map((x) => +x.uid);
if (uid) { shouldCompare = uid !== this.user._id;
targetUser = uid; } else uid = this.user._id;
shouldCompare = targetUser !== this.user._id;
}
}
const canViewHidden = this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN) || this.user._id; const canViewHidden = this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN) || this.user._id;
const [udoc, udict, pdict, psdict, selfPsdict] = await Promise.all([ const [udoc, udict, pdict, psdict, selfPsdict] = await Promise.all([
user.getById(domainId, tdoc.owner), user.getById(domainId, tdoc.owner),
user.getListForRender(domainId, enrollUsers), user.getListForRender(domainId, enrollUsers),
problem.getList(domainId, pids, canViewHidden, true), problem.getList(domainId, pids, canViewHidden, true),
problem.getListStatus(domainId, targetUser, pids), problem.getListStatus(domainId, uid, pids),
shouldCompare ? problem.getListStatus(domainId, this.user._id, pids) : {}, shouldCompare ? problem.getListStatus(domainId, this.user._id, pids) : {},
]); ]);
const donePids = new Set<number>(); const donePids = new Set<number>();

@ -77,7 +77,8 @@ export async function buildUI() {
const lazyModules: string[] = []; const lazyModules: string[] = [];
const newFiles = ['entry.js']; const newFiles = ['entry.js'];
for (const addon of global.addons) { for (const addon of global.addons) {
const publicPath = resolve(addon, 'public'); let publicPath = resolve(addon, 'frontend');
if (!fs.existsSync(publicPath)) publicPath = resolve(addon, 'public');
if (!fs.existsSync(publicPath)) continue; if (!fs.existsSync(publicPath)) continue;
const targets = fs.readdirSync(publicPath); const targets = fs.readdirSync(publicPath);
for (const target of targets) { for (const target of targets) {

Loading…
Cancel
Save