mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core&ui: contest_files
This commit is contained in:
1 parent
86d77625f6
commit
996ff2a9dd
16 files changed
+154
-32
No files matched your search
@@ -6,6 +6,7 @@ contest_detail_problem_submit: Submit Contest Problem
|
|||||||
contest_detail_problem: Problem Detail
|
contest_detail_problem: Problem Detail
|
||||||
contest_detail: Contest Detail
|
contest_detail: Contest Detail
|
||||||
contest_edit: Contest Edit
|
contest_edit: Contest Edit
|
||||||
|
contest_files: Contest Files
|
||||||
contest_main: Contest
|
contest_main: Contest
|
||||||
contest_scoreboard: Scoreboard
|
contest_scoreboard: Scoreboard
|
||||||
discussion_create: Create Discussion
|
discussion_create: Create Discussion
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ contest_detail_problem_submit: 递交比赛题目
|
|||||||
contest_detail_problem: 题目详情
|
contest_detail_problem: 题目详情
|
||||||
contest_detail: 比赛详情
|
contest_detail: 比赛详情
|
||||||
contest_edit: 编辑比赛
|
contest_edit: 编辑比赛
|
||||||
|
contest_files: 比赛文件
|
||||||
contest_main: 比赛
|
contest_main: 比赛
|
||||||
contest_scoreboard: 比赛成绩表
|
contest_scoreboard: 比赛成绩表
|
||||||
Contest: 比赛
|
Contest: 比赛
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "3.14.6",
|
"version": "3.14.7",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import AdmZip from 'adm-zip';
|
import AdmZip from 'adm-zip';
|
||||||
|
import { statSync } from 'fs-extra';
|
||||||
|
import { pick } from 'lodash';
|
||||||
import moment from 'moment-timezone';
|
import moment from 'moment-timezone';
|
||||||
import { ObjectID } from 'mongodb';
|
import { ObjectID } from 'mongodb';
|
||||||
import { Time } from '@hydrooj/utils/lib/utils';
|
import { sortFiles, Time } from '@hydrooj/utils/lib/utils';
|
||||||
import {
|
import {
|
||||||
ContestNotFoundError, ContestNotLiveError, ForbiddenError, InvalidTokenError,
|
ContestNotFoundError, ContestNotLiveError, ForbiddenError, InvalidTokenError,
|
||||||
PermissionError, ValidationError,
|
PermissionError, ValidationError,
|
||||||
@@ -11,13 +13,15 @@ import paginate from '../lib/paginate';
|
|||||||
import { PERM, PRIV } from '../model/builtin';
|
import { PERM, PRIV } from '../model/builtin';
|
||||||
import * as contest from '../model/contest';
|
import * as contest from '../model/contest';
|
||||||
import message from '../model/message';
|
import message from '../model/message';
|
||||||
|
import * as oplog from '../model/oplog';
|
||||||
import problem from '../model/problem';
|
import problem from '../model/problem';
|
||||||
import record from '../model/record';
|
import record from '../model/record';
|
||||||
|
import storage from '../model/storage';
|
||||||
import * as system from '../model/system';
|
import * as system from '../model/system';
|
||||||
import TaskModel from '../model/task';
|
import TaskModel from '../model/task';
|
||||||
import user from '../model/user';
|
import user from '../model/user';
|
||||||
import {
|
import {
|
||||||
Handler, param, Route, Types,
|
Handler, param, post, Route, Types,
|
||||||
} from '../service/server';
|
} from '../service/server';
|
||||||
import { registerResolver, registerValue } from './api';
|
import { registerResolver, registerValue } from './api';
|
||||||
|
|
||||||
@@ -363,6 +367,93 @@ export class ContestCodeHandler extends Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class ContestFilesHandler extends ContestDetailHandler {
|
||||||
|
@param('tid', Types.ObjectID)
|
||||||
|
@param('pjax', Types.Boolean)
|
||||||
|
// @ts-ignore
|
||||||
|
async get(domainId: string, tid: ObjectID, pjax = false) {
|
||||||
|
const tdoc = await contest.get(domainId, tid);
|
||||||
|
if (!this.user.own(tdoc)) this.checkPerm(PERM.PERM_EDIT_CONTEST);
|
||||||
|
const body = {
|
||||||
|
tdoc,
|
||||||
|
owner_udoc: await user.getById(domainId, tdoc.owner),
|
||||||
|
files: sortFiles(tdoc.files || []),
|
||||||
|
urlForFile: (filename: string) => this.url('contest_file_download', { tid, filename }),
|
||||||
|
};
|
||||||
|
if (pjax) {
|
||||||
|
this.response.body = {
|
||||||
|
fragments: (await Promise.all([
|
||||||
|
this.renderHTML('partials/files.html', body),
|
||||||
|
])).map((i) => ({ html: i })),
|
||||||
|
};
|
||||||
|
this.response.template = '';
|
||||||
|
} else {
|
||||||
|
this.response.template = 'contest_files.html';
|
||||||
|
this.response.body = body;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@param('tid', Types.ObjectID)
|
||||||
|
async post(domainId: string, tid: ObjectID) {
|
||||||
|
const tdoc = await contest.get(domainId, tid);
|
||||||
|
if (!this.user.own(tdoc)) this.checkPerm(PERM.PERM_EDIT_CONTEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
@param('tid', Types.ObjectID)
|
||||||
|
@post('filename', Types.Name, true)
|
||||||
|
async postUploadFile(domainId: string, tid: ObjectID, filename: string) {
|
||||||
|
const tdoc = await contest.get(domainId, tid);
|
||||||
|
if ((tdoc.files?.length || 0) >= system.get('limit.contest_files')) {
|
||||||
|
throw new ForbiddenError('File limit exceeded.');
|
||||||
|
}
|
||||||
|
const file = this.request.files?.file;
|
||||||
|
if (!file) throw new ValidationError('file');
|
||||||
|
const f = statSync(file.filepath);
|
||||||
|
const size = Math.sum((tdoc.files || []).map((i) => i.size)) + f.size;
|
||||||
|
if (size >= system.get('limit.contest_files_size')) {
|
||||||
|
throw new ForbiddenError('File size limit exceeded.');
|
||||||
|
}
|
||||||
|
if (!filename) filename = file.originalFilename || String.random(16);
|
||||||
|
if (filename.includes('/') || filename.includes('..')) throw new ValidationError('filename', null, 'Bad filename');
|
||||||
|
await storage.put(`contest/${domainId}/${tid}/${filename}`, file.filepath, this.user._id);
|
||||||
|
const meta = await storage.getMeta(`contest/${domainId}/${tid}/${filename}`);
|
||||||
|
const payload = { name: filename, ...pick(meta, ['size', 'lastModified', 'etag']) };
|
||||||
|
if (!meta) throw new Error('Upload failed');
|
||||||
|
await contest.edit(domainId, tid, { files: [...(tdoc.files || []), payload] });
|
||||||
|
this.back();
|
||||||
|
}
|
||||||
|
|
||||||
|
@param('tid', Types.ObjectID)
|
||||||
|
@post('files', Types.Array)
|
||||||
|
async postDeleteFiles(domainId: string, tid: ObjectID, files: string[]) {
|
||||||
|
const tdoc = await contest.get(domainId, tid);
|
||||||
|
await Promise.all([
|
||||||
|
storage.del(files.map((t) => `contest/${domainId}/${tid}/${t}`), this.user._id),
|
||||||
|
contest.edit(domainId, tid, { files: tdoc.files.filter((i) => !files.includes(i.name)) }),
|
||||||
|
]);
|
||||||
|
this.back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ContestFileDownloadHandler extends ContestDetailHandler {
|
||||||
|
@param('tid', Types.ObjectID)
|
||||||
|
@param('filename', Types.Name)
|
||||||
|
@param('noDisposition', Types.Boolean)
|
||||||
|
// @ts-ignore
|
||||||
|
async get(domainId: string, tid: ObjectID, filename: string, noDisposition = false) {
|
||||||
|
this.response.addHeader('Cache-Control', 'public');
|
||||||
|
const target = `contest/${domainId}/${tid}/${filename}`;
|
||||||
|
const file = await storage.getMeta(target);
|
||||||
|
await oplog.log(this, 'download.file.contest', {
|
||||||
|
target,
|
||||||
|
size: file?.size || 0,
|
||||||
|
});
|
||||||
|
this.response.redirect = await storage.signDownloadLink(
|
||||||
|
target, noDisposition ? undefined : filename, false, 'user',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function apply() {
|
export async function apply() {
|
||||||
Route('contest_create', '/contest/create', ContestEditHandler);
|
Route('contest_create', '/contest/create', ContestEditHandler);
|
||||||
Route('contest_main', '/contest', ContestListHandler, PERM.PERM_VIEW_CONTEST);
|
Route('contest_main', '/contest', ContestListHandler, PERM.PERM_VIEW_CONTEST);
|
||||||
@@ -372,6 +463,8 @@ export async function apply() {
|
|||||||
Route('contest_scoreboard', '/contest/:tid/scoreboard', ContestScoreboardHandler, PERM.PERM_VIEW_CONTEST);
|
Route('contest_scoreboard', '/contest/:tid/scoreboard', ContestScoreboardHandler, PERM.PERM_VIEW_CONTEST);
|
||||||
Route('contest_scoreboard_download', '/contest/:tid/export/:ext', ContestScoreboardDownloadHandler, PERM.PERM_VIEW_CONTEST);
|
Route('contest_scoreboard_download', '/contest/:tid/export/:ext', ContestScoreboardDownloadHandler, PERM.PERM_VIEW_CONTEST);
|
||||||
Route('contest_code', '/contest/:tid/code', ContestCodeHandler, PERM.PERM_VIEW_CONTEST);
|
Route('contest_code', '/contest/:tid/code', ContestCodeHandler, PERM.PERM_VIEW_CONTEST);
|
||||||
|
Route('contest_files', '/contest/:tid/file', ContestFilesHandler, PERM.PERM_VIEW_CONTEST);
|
||||||
|
Route('contest_file_download', '/contest/:tid/file/:filename', ContestFileDownloadHandler, PERM.PERM_VIEW_CONTEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
global.Hydro.handler.contest = apply;
|
global.Hydro.handler.contest = apply;
|
||||||
@@ -29,17 +29,20 @@ export class FilesHandler extends Handler {
|
|||||||
@param('pjax', Types.Boolean)
|
@param('pjax', Types.Boolean)
|
||||||
async get(domainId: string, pjax = false) {
|
async get(domainId: string, pjax = false) {
|
||||||
if (!this.user._files?.length) this.checkPriv(PRIV.PRIV_CREATE_FILE);
|
if (!this.user._files?.length) this.checkPriv(PRIV.PRIV_CREATE_FILE);
|
||||||
const files = sortFiles(this.user._files);
|
const body = {
|
||||||
|
files: sortFiles(this.user._files),
|
||||||
|
urlForFile: (filename: string) => this.url('fs_download', { uid: this.user._id, filename }),
|
||||||
|
};
|
||||||
if (pjax) {
|
if (pjax) {
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
fragments: (await Promise.all([
|
fragments: (await Promise.all([
|
||||||
this.renderHTML('partials/home_files.html', { files }),
|
this.renderHTML('partials/files.html', body),
|
||||||
])).map((i) => ({ html: i })),
|
])).map((i) => ({ html: i })),
|
||||||
};
|
};
|
||||||
this.response.template = '';
|
this.response.template = '';
|
||||||
} else {
|
} else {
|
||||||
this.response.template = 'home_files.html';
|
this.response.template = 'home_files.html';
|
||||||
this.response.body = { files };
|
this.response.body = body;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,13 +71,6 @@ export class FilesHandler extends Handler {
|
|||||||
this.back();
|
this.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
@post('from', Types.String)
|
|
||||||
@post('to', Types.String)
|
|
||||||
async postRename(domainId: string, from: string, to: string) {
|
|
||||||
await storage.rename(`user/${this.user._id}/${from}`, `user/${this.user._id}/${to}`, this.user._id);
|
|
||||||
this.back();
|
|
||||||
}
|
|
||||||
|
|
||||||
@post('files', Types.Array)
|
@post('files', Types.Array)
|
||||||
async postDeleteFiles(domainId: string, files: string[]) {
|
async postDeleteFiles(domainId: string, files: string[]) {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
|
|||||||
@@ -338,6 +338,7 @@ export interface Tdoc<docType = document['TYPE_CONTEST'] | document['TYPE_TRAINI
|
|||||||
rated?: boolean;
|
rated?: boolean;
|
||||||
_code?: string;
|
_code?: string;
|
||||||
assign?: string[];
|
assign?: string[];
|
||||||
|
files?: FileInfo[];
|
||||||
|
|
||||||
// For contest
|
// For contest
|
||||||
lockAt?: Date;
|
lockAt?: Date;
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ AccountSetting(
|
|||||||
Setting('setting_info', 'bio', null, 'markdown', 'Bio'),
|
Setting('setting_info', 'bio', null, 'markdown', 'Bio'),
|
||||||
Setting('setting_info', 'school', '', 'text', 'School'),
|
Setting('setting_info', 'school', '', 'text', 'School'),
|
||||||
Setting('setting_info', 'studentId', '', 'text', 'Student ID'),
|
Setting('setting_info', 'studentId', '', 'text', 'Student ID'),
|
||||||
|
Setting('setting_info', 'phone', null, 'text', 'Phone', null, FLAG_DISABLED),
|
||||||
Setting('setting_customize', 'backgroundImage',
|
Setting('setting_customize', 'backgroundImage',
|
||||||
'/components/profile/backgrounds/1.jpg', 'text', 'Profile Background Image',
|
'/components/profile/backgrounds/1.jpg', 'text', 'Profile Background Image',
|
||||||
'Choose the background image in your profile page.'),
|
'Choose the background image in your profile page.'),
|
||||||
@@ -212,6 +213,8 @@ SystemSetting(
|
|||||||
Setting('setting_limits', 'limit.problem_files_max_size', 256 * 1024 * 1024, 'number', 'limit.problem_files_max_size', 'Max files size per problem'),
|
Setting('setting_limits', 'limit.problem_files_max_size', 256 * 1024 * 1024, 'number', 'limit.problem_files_max_size', 'Max files size per problem'),
|
||||||
Setting('setting_limits', 'limit.user_files', 100, 'number', 'limit.user_files', 'Max files for user'),
|
Setting('setting_limits', 'limit.user_files', 100, 'number', 'limit.user_files', 'Max files for user'),
|
||||||
Setting('setting_limits', 'limit.user_files_size', 128 * 1024 * 1024, 'number', 'limit.user_files_size', 'Max total file size for user'),
|
Setting('setting_limits', 'limit.user_files_size', 128 * 1024 * 1024, 'number', 'limit.user_files_size', 'Max total file size for user'),
|
||||||
|
Setting('setting_limits', 'limit.contest_files', 100, 'number', 'limit.contest_files', 'Max files for contest'),
|
||||||
|
Setting('setting_limits', 'limit.contest_files_size', 128 * 1024 * 1024, 'number', 'limit.contest_files_size', 'Max total file size for contest'),
|
||||||
Setting('setting_limits', 'limit.submission', 60, 'number', 'limit.submission', 'Max submission count per minute'),
|
Setting('setting_limits', 'limit.submission', 60, 'number', 'limit.submission', 'Max submission count per minute'),
|
||||||
Setting('setting_limits', 'limit.submission_user', 15, 'number', 'limit.submission_user', 'Max submission count per user per minute'),
|
Setting('setting_limits', 'limit.submission_user', 15, 'number', 'limit.submission_user', 'Max submission count per user per minute'),
|
||||||
Setting('setting_limits', 'limit.pretest', 60, 'number', 'limit.pretest', 'Max pretest count per minute'),
|
Setting('setting_limits', 'limit.pretest', 60, 'number', 'limit.pretest', 'Max pretest count per minute'),
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ about: 关于
|
|||||||
About: 关于
|
About: 关于
|
||||||
AC Message: 通过消息
|
AC Message: 通过消息
|
||||||
Accept: 通过
|
Accept: 通过
|
||||||
Accepted Problem: 通过的题目
|
Accepted Problems: 通过的题目
|
||||||
Accepted Ratio: 通过率
|
Accepted Ratio: 通过率
|
||||||
Accepted: 已通过
|
Accepted: 已通过
|
||||||
Access Control: 访问控制
|
Access Control: 访问控制
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.38.6",
|
"version": "4.38.7",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
|
|||||||
+7
-10
@@ -14,7 +14,7 @@ function onBeforeUnload(e) {
|
|||||||
|
|
||||||
function ensureAndGetSelectedFiles() {
|
function ensureAndGetSelectedFiles() {
|
||||||
const files = _.map(
|
const files = _.map(
|
||||||
$('.home-files tbody [data-checkbox-group="user_files"]:checked'),
|
$('.files tbody [data-checkbox-group="files"]:checked'),
|
||||||
(ch) => $(ch).closest('tr').attr('data-filename'),
|
(ch) => $(ch).closest('tr').attr('data-filename'),
|
||||||
);
|
);
|
||||||
if (files.length === 0) {
|
if (files.length === 0) {
|
||||||
@@ -152,12 +152,9 @@ function handleDrop(ev) {
|
|||||||
handleClickUpload(files);
|
handleClickUpload(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
const page = new NamedPage('home_files', () => {
|
const page = new NamedPage(['home_files', 'contest_files'], () => {
|
||||||
const clip = new Clipboard('.home-files .col--name', {
|
const clip = new Clipboard('.files .col--name', {
|
||||||
text: (trigger) => {
|
text: (trigger) => new URL(trigger.children[0].href, window.location.href).toString(),
|
||||||
const filename = trigger.closest('[data-filename]').getAttribute('data-filename');
|
|
||||||
return new URL(`/file/${UserContext._id}/${filename}`, window.location.href).toString();
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
clip.on('success', () => {
|
clip.on('success', () => {
|
||||||
Notification.success(i18n('Download link copied to clipboard!'), 1000);
|
Notification.success(i18n('Download link copied to clipboard!'), 1000);
|
||||||
@@ -165,11 +162,11 @@ const page = new NamedPage('home_files', () => {
|
|||||||
clip.on('error', () => {
|
clip.on('error', () => {
|
||||||
Notification.error(i18n('Copy failed :('));
|
Notification.error(i18n('Copy failed :('));
|
||||||
});
|
});
|
||||||
$(document).on('click', '.home-files .col--name', (ev) => ev.preventDefault());
|
$(document).on('click', '.files .col--name', (ev) => ev.preventDefault());
|
||||||
$(document).on('click', '[name="upload_file"]', () => handleClickUpload());
|
$(document).on('click', '[name="upload_file"]', () => handleClickUpload());
|
||||||
$(document).on('click', '[name="remove_selected"]', () => handleClickRemoveSelected());
|
$(document).on('click', '[name="remove_selected"]', () => handleClickRemoveSelected());
|
||||||
$(document).on('dragover', '.home-files', (ev) => handleDragOver(ev));
|
$(document).on('dragover', '.files', (ev) => handleDragOver(ev));
|
||||||
$(document).on('drop', '.home-files', (ev) => handleDrop(ev));
|
$(document).on('drop', '.files', (ev) => handleDrop(ev));
|
||||||
});
|
});
|
||||||
|
|
||||||
export default page;
|
export default page;
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
{% extends "layout/basic.html" %}
|
||||||
|
{% import "components/contest.html" as contest with context %}
|
||||||
|
{% import "components/record.html" as record with context %}
|
||||||
|
{% import "components/problem.html" as problem with context %}
|
||||||
|
{% block content %}
|
||||||
|
{{ set(UiContext, 'tdoc', tdoc) }}
|
||||||
|
<div class="row">
|
||||||
|
<div class="medium-9 columns">
|
||||||
|
<div class="section">
|
||||||
|
<div class="section__header">
|
||||||
|
<h1 class="section__title">{{ _('Files') }}</h1>
|
||||||
|
<div class="section__tools">
|
||||||
|
<button class="primary rounded button" name="upload_file">{{ _('Upload File') }}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{ noscript_note.render() }}
|
||||||
|
{% include "partials/files.html" %}
|
||||||
|
<div class="section__body">
|
||||||
|
<button class="rounded button" name="remove_selected">{{ _('Remove Selected') }}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="medium-3 columns">
|
||||||
|
{% include "partials/contest_sidebar.html" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{ noscript_note.render() }}
|
{{ noscript_note.render() }}
|
||||||
{% include "partials/home_files.html" %}
|
{% include "partials/files.html" %}
|
||||||
<div class="section__body">
|
<div class="section__body">
|
||||||
<button class="rounded button" name="remove_selected">{{ _('Remove Selected') }}</button>
|
<button class="rounded button" name="remove_selected">{{ _('Remove Selected') }}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -72,6 +72,9 @@
|
|||||||
<li class="menu__item"><a class="menu__link" href="{{ url('contest_edit', tid=tdoc.docId) }}">
|
<li class="menu__item"><a class="menu__link" href="{{ url('contest_edit', tid=tdoc.docId) }}">
|
||||||
<span class="icon icon-edit"></span> {{ _('Edit Contest') }}
|
<span class="icon icon-edit"></span> {{ _('Edit Contest') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
|
<li class="menu__item"><a class="menu__link" href="{{ url('contest_files', tid=tdoc.docId) }}">
|
||||||
|
<span class="icon icon-file"></span> {{ _('Files') }}
|
||||||
|
</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if handler.user.own(tdoc) or handler.user.hasPriv(PRIV.PRIV_READ_RECORD_CODE) or handler.user.hasPerm(perm.PERM_READ_RECORD_CODE) %}
|
{% if handler.user.own(tdoc) or handler.user.hasPriv(PRIV.PRIV_READ_RECORD_CODE) or handler.user.hasPerm(perm.PERM_READ_RECORD_CODE) %}
|
||||||
{% if model.contest.canShowRecord.call(handler, tdoc, true) %}
|
{% if model.contest.canShowRecord.call(handler, tdoc, true) %}
|
||||||
|
|||||||
+4
-4
@@ -1,5 +1,5 @@
|
|||||||
{% import "components/nothing.html" as nothing with context %}
|
{% import "components/nothing.html" as nothing with context %}
|
||||||
<div class="section__body no-padding home-files" data-fragment-id="home-files">
|
<div class="section__body no-padding files" data-fragment-id="files">
|
||||||
{% if files.length %}
|
{% if files.length %}
|
||||||
<table class="data-table">
|
<table class="data-table">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th class="col--checkbox">
|
<th class="col--checkbox">
|
||||||
<label class="compact checkbox">
|
<label class="compact checkbox">
|
||||||
<input type="checkbox" name="select_all" data-checkbox-toggle="user_files">
|
<input type="checkbox" name="select_all" data-checkbox-toggle="files">
|
||||||
</label>
|
</label>
|
||||||
</th>
|
</th>
|
||||||
<th class="col--name">{{ _('Filename') }}</th>
|
<th class="col--name">{{ _('Filename') }}</th>
|
||||||
@@ -23,11 +23,11 @@
|
|||||||
<tr data-filename="{{ file.name }}" data-size="{{ file.size }}">
|
<tr data-filename="{{ file.name }}" data-size="{{ file.size }}">
|
||||||
<td class="col--checkbox">
|
<td class="col--checkbox">
|
||||||
<label class="compact checkbox">
|
<label class="compact checkbox">
|
||||||
<input type="checkbox" data-checkbox-group="user_files" data-checkbox-range>
|
<input type="checkbox" data-checkbox-group="files" data-checkbox-range>
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
<td class="col--name">
|
<td class="col--name">
|
||||||
<a href="{{ url('fs_download', {uid: handler.user._id, filename: file.name}) }}">{{ file.name }}</a>
|
<a href="{{ urlForFile(file.name) }}">{{ file.name }}</a>
|
||||||
</td>
|
</td>
|
||||||
<td class="col--size">{{ size(file.size) }}</td>
|
<td class="col--size">{{ size(file.size) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -250,7 +250,7 @@ export function sortFiles(files: { _id: string }[] | string[]) {
|
|||||||
if (!files?.length) return [];
|
if (!files?.length) return [];
|
||||||
const isString = typeof files[0] === 'string';
|
const isString = typeof files[0] === 'string';
|
||||||
const result = files
|
const result = files
|
||||||
.map((i) => (isString ? { name: i, weights: i.match(fSortR) } : { ...i, weights: i._id.match(fSortR) }))
|
.map((i) => (isString ? { name: i, weights: i.match(fSortR) } : { ...i, weights: (i._id || i.name).match(fSortR) }))
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
let pos = 0;
|
let pos = 0;
|
||||||
const weightsA = a.weights;
|
const weightsA = a.weights;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/utils",
|
"name": "@hydrooj/utils",
|
||||||
"version": "1.3.0",
|
"version": "1.3.1",
|
||||||
"description": "hydrooj utils",
|
"description": "hydrooj utils",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||||
|
|||||||
Reference in new issue
Block a user