From 3032463faf3b0eab6fd8f6654fa250729b9c0f3a Mon Sep 17 00:00:00 2001 From: Menci Date: Thu, 8 Nov 2018 00:37:12 +0800 Subject: [PATCH 01/19] Change the style of showing memory usage --- libs/submissions_process.js | 5 +++-- utility.js | 4 ++-- views/submissions_item.ejs | 8 +++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/libs/submissions_process.js b/libs/submissions_process.js index 44d4503..faa5714 100644 --- a/libs/submissions_process.js +++ b/libs/submissions_process.js @@ -18,7 +18,8 @@ const getRoughResult = (x, displayConfig) => { return { result: x.status, time: displayConfig.showUsage ? x.total_time : null, - memory: displayConfig.showUsage ? x.max_memory : null, + memory: displayConfig.showUsage ? syzoj.utils.formatSize((x.max_memory * 1024) || 0, 2) : null, + precise_memory: displayConfig.showUsage ? x.max_memory : null, score: displayConfig.showScore ? x.score : null }; } @@ -72,4 +73,4 @@ const processOverallResult = (source, config) => { }; } -module.exports = { getRoughResult, getSubmissionInfo, processOverallResult }; \ No newline at end of file +module.exports = { getRoughResult, getSubmissionInfo, processOverallResult }; diff --git a/utility.js b/utility.js index 6304b22..6b70d11 100644 --- a/utility.js +++ b/utility.js @@ -121,8 +121,8 @@ module.exports = { } return sgn + util.format('%s:%s:%s', toStringWithPad(x / 3600), toStringWithPad(x / 60 % 60), toStringWithPad(x % 60)); }, - formatSize(x) { - let res = filesize(x, { fixed: 1 }).calculate(); + formatSize(x, precision) { + let res = filesize(x, { fixed: precision || 1 }).calculate(); if (res.result === parseInt(res.result)) res.fixed = res.result.toString(); if (res.suffix.startsWith('Byte')) res.suffix = 'B'; else res.suffix = res.suffix.replace('iB', ''); diff --git a/views/submissions_item.ejs b/views/submissions_item.ejs index 14637eb..bff0679 100644 --- a/views/submissions_item.ejs +++ b/views/submissions_item.ejs @@ -69,7 +69,13 @@ Vue.component('submission-item', { {{ Math.floor(data.result.score || 0) }} <% } %> {{ (data.result.time || 0).toString() + ' ms' }} - {{ (data.result.memory || 0).toString() + ' KiB' }} + + <% if (active === 'submissions') { %> + {{ data.result.memory }} + <% } else { %> + {{ (data.result.precise_memory || 0).toString() + ' K'}} + <% } %> + From c90077da585fdf8baee1a201d2b46cdfd4f1ba77 Mon Sep 17 00:00:00 2001 From: Menci Date: Thu, 8 Nov 2018 15:30:48 +0800 Subject: [PATCH 02/19] UI improvement on submission / submissions page --- modules/submission.js | 7 +++++-- static/style.css | 19 ++++++++++++------- views/footer.ejs | 2 +- views/header.ejs | 2 +- views/status_label.ejs | 8 ++++++-- views/submission.ejs | 36 ++++++++++++++++++++++++++++++++---- views/submissions.ejs | 25 ++++++++++++++++++++----- views/submissions_item.ejs | 10 +++++----- 8 files changed, 82 insertions(+), 27 deletions(-) diff --git a/modules/submission.js b/modules/submission.js index 9fb21f5..27146c8 100644 --- a/modules/submission.js +++ b/modules/submission.js @@ -71,9 +71,9 @@ app.get('/submissions', async (req, res) => { if (req.query.problem_id) { let problem_id = parseInt(req.query.problem_id); let problem = await Problem.fromID(problem_id); - if(!problem) + if (!problem) throw new ErrorMessage("无此题目。"); - if(await problem.isAllowedUseBy(res.locals.user)) { + if (await problem.isAllowedUseBy(res.locals.user)) { where.problem_id = { $and: [ { $eq: where.problem_id = problem_id } @@ -91,6 +91,8 @@ app.get('/submissions', async (req, res) => { if (req.query.problem_id) where.problem_id = parseInt(req.query.problem_id) || -1; } + let isFiltered = !!(where.problem_id || where.user_id || where.score || where.language || where.status); + let paginate = syzoj.utils.paginate(await JudgeState.count(where), req.query.page, syzoj.config.page.judge_state); let judge_state = await JudgeState.query(paginate, where, [['id', 'desc']], true); @@ -112,6 +114,7 @@ app.get('/submissions', async (req, res) => { pushType: 'rough', form: req.query, displayConfig: displayConfig, + isFiltered: isFiltered }); } catch (e) { syzoj.log(e); diff --git a/static/style.css b/static/style.css index 5f076c6..b0d3ce9 100644 --- a/static/style.css +++ b/static/style.css @@ -21,15 +21,15 @@ h4, h5, body { - font-family: + font-family: Lato, - -apple-system, - 'PingFang SC',/* Apple */ - 'Source Han Sans SC', + -apple-system, + 'PingFang SC',/* Apple */ + 'Source Han Sans SC', 'Noto Sans CJK SC', /* Google */ - 'Microsoft Yahei', - 'Lantinghei SC', - 'Hiragino Sans GB', + 'Microsoft Yahei', + 'Lantinghei SC', + 'Hiragino Sans GB', 'Microsoft Sans Serif', /* M$ */ 'WenQuanYi Micro Hei', /* *nix */ sans-serif; @@ -300,3 +300,8 @@ code { font-size: 1em; vertical-align: initial; } + +.ui.selection.dropdown .menu>.item { + padding-left: 0.8rem !important; + padding-right: 0 !important; +} diff --git a/views/footer.ejs b/views/footer.ejs index d069db5..0791557 100644 --- a/views/footer.ejs +++ b/views/footer.ejs @@ -1,5 +1,5 @@ -