diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index e0256fa2a..130cbc9a8 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "2.26.13", + "version": "2.26.14", "bin": "bin/hydrooj.js", "main": "dist/loader.js", "typings": "dist/loader.d.ts", diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index 7c60e8a75..73892d4be 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -388,11 +388,12 @@ export class ProblemFilesHandler extends ProblemDetailHandler { this.response.body.additional_file = getAdditionalFile ? sortFiles(this.pdoc.additional_file || []) : []; if (pjax) { const { testdata, additional_file } = this.response.body; + const owner_udoc = await user.getById(domainId, this.pdoc.owner); this.response.body = { fragments: (await Promise.all([ this.renderHTML('partials/problem_files-testdata.html', { testdata, pdoc: this.pdoc }), this.renderHTML('partials/problem_files-additional_file.html', { additional_file, pdoc: this.pdoc }), - this.renderHTML('partials/problem-sidebar-information.html', { pdoc: this.pdoc }), + this.renderHTML('partials/problem-sidebar-information.html', { pdoc: this.pdoc, owner_udoc }), ])).map((i) => ({ html: i })), }; this.response.template = ''; diff --git a/packages/ui-default/pages/problem_files.page.js b/packages/ui-default/pages/problem_files.page.js index c27f2b592..0ace60d94 100644 --- a/packages/ui-default/pages/problem_files.page.js +++ b/packages/ui-default/pages/problem_files.page.js @@ -84,20 +84,24 @@ const page = new NamedPage('problem_files', () => { await new Promise((resolve) => { input.onchange = resolve; }); files = input.files; } + if (!files.length) { + Notification.warn(i18n('No file selected.')); + return; + } + const dialog = new Dialog({ + $body: ` +
+ + + `, + }); try { Notification.info(i18n('Uploading files...')); window.addEventListener('beforeunload', onBeforeUnload); - const dialog = new Dialog({ - $body: ` - - - - `, - }); dialog.open(); const $uploadLabel = dialog.$dom.find('.dialog__body .upload-label'); const $uploadProgress = dialog.$dom.find('.dialog__body .upload-progress'); @@ -132,13 +136,14 @@ const page = new NamedPage('problem_files', () => { }, }); } - dialog.close(); window.removeEventListener('beforeunload', onBeforeUnload); Notification.success(i18n('File uploaded successfully.')); await pjax.request({ push: false }); } catch (e) { console.error(e); Notification.error(i18n('File upload failed: {0}', e.toString())); + } finally { + dialog.close(); } } diff --git a/packages/ui-default/templates/problem_files.html b/packages/ui-default/templates/problem_files.html index 33dde88da..e82922806 100644 --- a/packages/ui-default/templates/problem_files.html +++ b/packages/ui-default/templates/problem_files.html @@ -15,14 +15,12 @@ {{ noscript_note.render() }} {% include "partials/problem_files-testdata.html" %} {% if handler.user.own(pdoc) or handler.user.hasPerm(perm.PERM_READ_PROBLEM_DATA) or handler.user.hasPriv(PRIV.PRIV_READ_PROBLEM_DATA) %} - {% if testdata.length %} -