ui: fix upload

This commit is contained in:
wuxianucw committed 2021-05-19 08:59:06 +08:00
1 parent 18b4f3e33b
commit 16a6787ae7
3 files changed
+19 -9

No files matched your search

+10
View File
@@ -52,6 +52,16 @@ AC Message: 通过消息
Accepted Ratio: 通过率 Accepted Ratio: 通过率
Accepted: 已通过 Accepted: 已通过
Access Control: 访问控制 Access Control: 访问控制
Processing...: 处理中...
Confirm to delete the selected files?: 确认删除所选文件吗?
Selected files have been deleted.: 所选文件已被删除。
You don't have permission to upload file.: 您没有权限上传文件。
file too large: 文件过大
Loading file...: 正在加载文件内容...
Loading editor...: 正在加载编辑器...
Saving file...: 正在保存文件...
File saved.: 文件已成功保存。
Please select at least one file to perform this operation.: 请选择至少一个文件来执行此操作。
Account Settings: 账户设置 Account Settings: 账户设置
Action: 动作 Action: 动作
Active Sessions: 活动会话 Active Sessions: 活动会话
@@ -88,12 +88,12 @@ const page = new NamedPage('problem_files', () => {
Notification.info(i18n('Uploading files...')); Notification.info(i18n('Uploading files...'));
window.addEventListener('beforeunload', onBeforeUnload); window.addEventListener('beforeunload', onBeforeUnload);
const dialog = new Dialog({ const dialog = new Dialog({
$body: `\ $body: `
<div class="file-label" style="text-align: center;margin: 5px 0;color: gray;font-size: small;"></div> <div class="file-label" style="text-align: center; margin-bottom: 5px; color: gray; font-size: small;"></div>
<div class="bp3-progress-bar bp3-intent-primary bp3-no-stripes"> <div class="bp3-progress-bar bp3-intent-primary bp3-no-stripes">
<div class="file-progress bp3-progress-meter" style="width: 0"></div> <div class="file-progress bp3-progress-meter" style="width: 0"></div>
</div> </div>
<div class="upload-label" style="text-align: center;margin-bottom: 8px;color: gray;"></div> <div class="upload-label" style="text-align: center; margin: 5px 0; color: gray; font-size: small;"></div>
<div class="bp3-progress-bar bp3-intent-primary bp3-no-stripes"> <div class="bp3-progress-bar bp3-intent-primary bp3-no-stripes">
<div class="upload-progress bp3-progress-meter" style="width: 0"></div> <div class="upload-progress bp3-progress-meter" style="width: 0"></div>
</div>`, </div>`,
@@ -185,11 +185,11 @@ const page = new NamedPage('problem_files', () => {
* @param {JQuery.DropEvent<HTMLElement, undefined, HTMLElement, HTMLElement>} ev * @param {JQuery.DropEvent<HTMLElement, undefined, HTMLElement, HTMLElement>} ev
*/ */
function handleDrop(type, ev) { function handleDrop(type, ev) {
if (!$('[name="remove_selected_testdata"]').length) { ev.preventDefault();
if (!$('[name="upload_testdata"]').length) {
Notification.error(i18n("You don't have permission to upload file.")); Notification.error(i18n("You don't have permission to upload file."));
return; return;
} }
ev.preventDefault();
ev = ev.originalEvent; ev = ev.originalEvent;
const files = []; const files = [];
if (ev.dataTransfer.items) { if (ev.dataTransfer.items) {
@@ -261,7 +261,7 @@ const page = new NamedPage('problem_files', () => {
await pjax.request({ push: false }); await pjax.request({ push: false });
} }
if ($('[name="remove_selected_testdata"]').length) { if ($('[name="upload_testdata"]').length) {
$('.problem-files-testdata .col--name').on('click', (ev) => handleEdit('testdata', ev)); $('.problem-files-testdata .col--name').on('click', (ev) => handleEdit('testdata', ev));
$('.problem-files-additional_file .col--name').on('click', (ev) => handleEdit('additional_file', ev)); $('.problem-files-additional_file .col--name').on('click', (ev) => handleEdit('additional_file', ev));
$('[name="upload_testdata"]').on('click', () => handleClickUpload('testdata')); $('[name="upload_testdata"]').on('click', () => handleClickUpload('testdata'));
@@ -186,9 +186,9 @@ async function handleOperation(operation) {
if (operation === 'delete') { if (operation === 'delete') {
const action = await new ConfirmDialog({ const action = await new ConfirmDialog({
$body: tpl` $body: tpl`
<div class="typo"> <div class="typo">
<p>${i18n('Confirm to delete the selected problems?')}</p> <p>${i18n('Confirm to delete the selected problems?')}</p>
</div>`, </div>`,
}).open(); }).open();
if (action !== 'yes') return; if (action !== 'yes') return;
} }