mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: support generate testdata (#695)
Co-authored-by: panda <panda_dtdyy@outlook.com>
This commit is contained in:
1 parent
b83b2e792e
commit
55b4e1aaf0
27 files changed
+454
-68
No files matched your search
@@ -2,7 +2,8 @@ import $ from 'jquery';
|
||||
import { map } from 'lodash';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import { ActionDialog, ConfirmDialog } from 'vj/components/dialog/index';
|
||||
import FileSelectAutoComplete from 'vj/components/autocomplete/FileSelectAutoComplete';
|
||||
import { ActionDialog, ConfirmDialog, InfoDialog } from 'vj/components/dialog/index';
|
||||
import createHint from 'vj/components/hint';
|
||||
import Notification from 'vj/components/notification';
|
||||
import { previewFile } from 'vj/components/preview/preview.page';
|
||||
@@ -318,6 +319,48 @@ const page = new NamedPage('problem_files', () => {
|
||||
handleClickUpload(type, files);
|
||||
}
|
||||
|
||||
async function handleGenerateTestdata(ev) {
|
||||
ev.preventDefault();
|
||||
const gen = $('[name=gen]').val();
|
||||
const std = $('[name=std]').val();
|
||||
if (!gen) {
|
||||
Notification.error(i18n('Please input the generator.'));
|
||||
return;
|
||||
}
|
||||
if (!std) {
|
||||
Notification.error(i18n('Please input the standard program.'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await request.post('', {
|
||||
operation: 'generate_testdata',
|
||||
gen,
|
||||
std,
|
||||
});
|
||||
if (res.error) Notification.error(res.error);
|
||||
else {
|
||||
Notification.success(i18n('Generating...'));
|
||||
await new InfoDialog({
|
||||
$body: tpl`
|
||||
<div class="typo">
|
||||
<iframe src="${res.url}"
|
||||
scrolling="yes" border="0" frameborder="no" framespacing="0" width="100%" style="height: 70vh;"></iframe>
|
||||
</div>`,
|
||||
width: `${window.innerWidth - 200}px`,
|
||||
height: `${window.innerHeight - 100}px`,
|
||||
}).open();
|
||||
}
|
||||
} catch (error) {
|
||||
Notification.error([error.message, ...error.params].join(' '));
|
||||
}
|
||||
}
|
||||
|
||||
if (UiContext.pdoc) {
|
||||
FileSelectAutoComplete.getOrConstruct($('[name=gen]'), { data: UiContext.pdoc.data });
|
||||
FileSelectAutoComplete.getOrConstruct($('[name=std]'), { data: UiContext.pdoc.data });
|
||||
$('[name="generate_testdata"]').on('click', handleGenerateTestdata);
|
||||
}
|
||||
|
||||
if ($('[name="upload_testdata"]').length) {
|
||||
$(document).on('click', '[name="upload_testdata"]', () => handleClickUpload('testdata'));
|
||||
$(document).on('click', '[name="upload_file"]', () => handleClickUpload('additional_file'));
|
||||
|
||||
Reference in new issue
Block a user