Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions packages/ui-default/pages/problem_config.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,15 @@ const page = new NamedPage('problem_config', () => {

async function handleClickDownloadAll() {
const files = reduxStore.getState().testdata.map((i) => i.name);
const { links, pdoc } = await request.post('./files', { operation: 'get_links', files, type: 'testdata' });
const targets: { filename: string, url: string }[] = [];
for (const filename of Object.keys(links)) targets.push({ filename, url: links[filename] });
await download(`${pdoc.docId} ${pdoc.title}.zip`, targets);
try {
const { links, pdoc } = await request.post('./files', { operation: 'get_links', files, type: 'testdata' });
const targets: { filename: string, url: string }[] = [];
for (const filename of Object.keys(links)) targets.push({ filename, url: links[filename] });
await download(`${pdoc.docId} ${pdoc.title}.zip`, targets);
} catch (error) {
const err = error as any;
Notification.error(err.params ? [err.message, ...err.params].join(' ') : err.message);
}
}

async function uploadConfig(config: object) {
Expand Down
13 changes: 9 additions & 4 deletions packages/ui-default/pages/problem_files.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ const page = new NamedPage('problem_files', () => {
const type = $(ev.currentTarget).closest('[data-type]').attr('data-type');
const files = ensureAndGetSelectedFiles(type);
if (files === null) return;
const { links, pdoc } = await request.post('', { operation: 'get_links', files, type });
const targets = [];
for (const filename of Object.keys(links)) targets.push({ filename, url: links[filename] });
await download(`${pdoc.docId} ${pdoc.title} ${type}.zip`, targets);
try {
const { links, pdoc } = await request.post('', { operation: 'get_links', files, type });
const targets = [];
for (const filename of Object.keys(links)) targets.push({ filename, url: links[filename] });
await download(`${pdoc.docId} ${pdoc.title} ${type}.zip`, targets);
} catch (error) {
const err = error as any;
Notification.error(err.params ? [err.message, ...err.params].join(' ') : err.message);
}
}

async function handleGenerateTestdata(ev) {
Expand Down
Loading