mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
bug fix
This commit is contained in:
1 parent
2b6a510c1e
commit
f2bcc3bc93
23 files changed
+241
-119
No files matched your search
@@ -24,6 +24,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: development.js
|
name: development.js
|
||||||
path: .build/development.js
|
path: .build/development.js
|
||||||
|
- uses: actions/upload-artifact@v1
|
||||||
|
with:
|
||||||
|
name: full.js
|
||||||
|
path: .build/full.js
|
||||||
- uses: actions/upload-artifact@v1
|
- uses: actions/upload-artifact@v1
|
||||||
with:
|
with:
|
||||||
name: module
|
name: module
|
||||||
|
|||||||
+7
-11
@@ -25,18 +25,15 @@ async function build(type) {
|
|||||||
ignoreFailure(fs.mkdirSync, root('.build'));
|
ignoreFailure(fs.mkdirSync, root('.build'));
|
||||||
ignoreFailure(fs.mkdirSync, root('.build/module'));
|
ignoreFailure(fs.mkdirSync, root('.build/module'));
|
||||||
const langs = fs.readdirSync(root('locales'));
|
const langs = fs.readdirSync(root('locales'));
|
||||||
const lang = {};
|
const locale = {};
|
||||||
for (const i of langs) {
|
for (const i of langs) {
|
||||||
const content = fs.readFileSync(root(`locales/${i}`)).toString();
|
const content = fs.readFileSync(root(`locales/${i}`)).toString();
|
||||||
lang[i.split('.')[0]] = yaml.safeLoad(content);
|
locale[i.split('.')[0]] = yaml.safeLoad(content);
|
||||||
}
|
}
|
||||||
const exclude = [
|
|
||||||
'bsod.html',
|
|
||||||
];
|
|
||||||
const builtin = {
|
const builtin = {
|
||||||
id: 'builtin',
|
id: 'builtin',
|
||||||
locale: lang,
|
locale,
|
||||||
template: template('templates', exclude),
|
template: template('templates'),
|
||||||
file: {},
|
file: {},
|
||||||
};
|
};
|
||||||
const files = getFiles('.uibuild');
|
const files = getFiles('.uibuild');
|
||||||
@@ -72,10 +69,9 @@ async function build(type) {
|
|||||||
console.error(`Module pack failed: ${m}`);
|
console.error(`Module pack failed: ${m}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await fsp.writeFile(root('.build/module.json'), JSON.stringify(j));
|
const f = fs.readFileSync(root('.build/development.js')).toString();
|
||||||
console.log('Build::Full');
|
const file = `global._hydroModule=${JSON.stringify(j)};${f}`;
|
||||||
await require('./webpack')(type, '-full');
|
fs.writeFileSync(root('.build/full.js'), file);
|
||||||
await fsp.unlink(root('.build/module.json'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = build;
|
module.exports = build;
|
||||||
|
|||||||
+2
-2
@@ -15,7 +15,7 @@ function getFiles(folder) {
|
|||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
const build = (dirOrObject, exclude = []) => {
|
const build = (dirOrObject) => {
|
||||||
let templates = {};
|
let templates = {};
|
||||||
if (typeof dirOrObject === 'string') {
|
if (typeof dirOrObject === 'string') {
|
||||||
const files = getFiles(dirOrObject);
|
const files = getFiles(dirOrObject);
|
||||||
@@ -25,7 +25,7 @@ const build = (dirOrObject, exclude = []) => {
|
|||||||
}
|
}
|
||||||
} else templates = dirOrObject;
|
} else templates = dirOrObject;
|
||||||
for (const i in templates) {
|
for (const i in templates) {
|
||||||
if (!exclude.includes(i) && i.endsWith('.html')) {
|
if (i.endsWith('.html') && !templates[i].includes('No Compression')) {
|
||||||
templates[i] = templates[i]
|
templates[i] = templates[i]
|
||||||
.trim()
|
.trim()
|
||||||
.replace(/ *\n */gmi, ' ')
|
.replace(/ *\n */gmi, ' ')
|
||||||
|
|||||||
+2
-2
@@ -4,7 +4,7 @@ const webpack = require('webpack');
|
|||||||
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
|
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
|
||||||
const { root } = require('./utils');
|
const { root } = require('./utils');
|
||||||
|
|
||||||
const build = async (type, tag = '') => {
|
const build = async (type) => {
|
||||||
function hackNodeModuleFormidable() {
|
function hackNodeModuleFormidable() {
|
||||||
const tasks = ['incoming_form', 'file', 'json_parser', 'querystring_parser'];
|
const tasks = ['incoming_form', 'file', 'json_parser', 'querystring_parser'];
|
||||||
for (const task of tasks) {
|
for (const task of tasks) {
|
||||||
@@ -25,7 +25,7 @@ const build = async (type, tag = '') => {
|
|||||||
development: root('hydro/development.js'),
|
development: root('hydro/development.js'),
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
filename: `[name]${tag}.js`,
|
filename: '[name].js',
|
||||||
path: root('.build'),
|
path: root('.build'),
|
||||||
},
|
},
|
||||||
target: 'node',
|
target: 'node',
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"id": "homework",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "Homework support"
|
|
||||||
}
|
|
||||||
+46
-11
@@ -10,6 +10,7 @@ const misc = require('../lib/misc');
|
|||||||
const md5 = require('../lib/md5');
|
const md5 = require('../lib/md5');
|
||||||
const contest = require('../model/contest');
|
const contest = require('../model/contest');
|
||||||
const message = require('../model/message');
|
const message = require('../model/message');
|
||||||
|
const document = require('../model/document');
|
||||||
const system = require('../model/system');
|
const system = require('../model/system');
|
||||||
const user = require('../model/user');
|
const user = require('../model/user');
|
||||||
const setting = require('../model/setting');
|
const setting = require('../model/setting');
|
||||||
@@ -18,12 +19,26 @@ const token = require('../model/token');
|
|||||||
const training = require('../model/training');
|
const training = require('../model/training');
|
||||||
const {
|
const {
|
||||||
PERM_VIEW_TRAINING, PERM_VIEW_CONTEST, PERM_VIEW_DISCUSSION,
|
PERM_VIEW_TRAINING, PERM_VIEW_CONTEST, PERM_VIEW_DISCUSSION,
|
||||||
PERM_LOGGEDIN,
|
PERM_LOGGEDIN, PERM_VIEW_HOMEWORK,
|
||||||
} = require('../permission');
|
} = require('../permission');
|
||||||
|
|
||||||
const { geoip, useragent } = global.Hydro.lib;
|
const { geoip, useragent } = global.Hydro.lib;
|
||||||
|
|
||||||
class HomeHandler extends Handler {
|
class HomeHandler extends Handler {
|
||||||
|
async homework(domainId) {
|
||||||
|
if (this.user.hasPerm(PERM_VIEW_HOMEWORK)) {
|
||||||
|
const tdocs = await contest.getMulti(domainId, {}, document.TYPE_HOMEWORK)
|
||||||
|
.limit(await system.get('HOMEWORK_ON_MAIN'))
|
||||||
|
.toArray();
|
||||||
|
const tsdict = await contest.getListStatus(
|
||||||
|
domainId, this.user._id,
|
||||||
|
tdocs.map((tdoc) => tdoc.docId), document.TYPE_HOMEWORK,
|
||||||
|
);
|
||||||
|
return [tdocs, tsdict];
|
||||||
|
}
|
||||||
|
return [[], {}];
|
||||||
|
}
|
||||||
|
|
||||||
async contest(domainId) {
|
async contest(domainId) {
|
||||||
if (this.user.hasPerm(PERM_VIEW_CONTEST)) {
|
if (this.user.hasPerm(PERM_VIEW_CONTEST)) {
|
||||||
const tdocs = await contest.getMulti(domainId)
|
const tdocs = await contest.getMulti(domainId)
|
||||||
@@ -63,13 +78,17 @@ class HomeHandler extends Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async get({ domainId }) {
|
async get({ domainId }) {
|
||||||
const [[tdocs, tsdict], [trdocs, trsdict], [ddocs, vndict]] = await Promise.all([
|
const [
|
||||||
this.contest(domainId), this.training(domainId), this.discussion(domainId),
|
[htdocs, htsdict], [tdocs, tsdict],
|
||||||
|
[trdocs, trsdict], [ddocs, vndict],
|
||||||
|
] = await Promise.all([
|
||||||
|
this.homework(domainId), this.contest(domainId),
|
||||||
|
this.training(domainId), this.discussion(domainId),
|
||||||
]);
|
]);
|
||||||
const udict = await user.getList(domainId, ddocs.map((ddoc) => ddoc.owner));
|
const udict = await user.getList(domainId, ddocs.map((ddoc) => ddoc.owner));
|
||||||
this.response.template = 'main.html';
|
this.response.template = 'main.html';
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
tdocs, tsdict, trdocs, trsdict, ddocs, vndict, udict,
|
htdocs, htsdict, tdocs, tsdict, trdocs, trsdict, ddocs, vndict, udict,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,21 +209,37 @@ class HomeMessagesHandler extends Handler {
|
|||||||
|
|
||||||
async get() {
|
async get() {
|
||||||
// TODO(iceboy): projection, pagination.
|
// TODO(iceboy): projection, pagination.
|
||||||
const mdocs = await message.getMulti(this.user._id).sort('_id', -1).limit(50).toArray();
|
const messages = await message.getByUser(this.user._id);
|
||||||
const udict = await user.getList([
|
const udict = await user.getList([
|
||||||
...mdocs.map((mdoc) => mdoc.from),
|
...messages.map((mdoc) => mdoc.from),
|
||||||
...mdocs.map((mdoc) => mdoc.to),
|
...messages.map((mdoc) => mdoc.to),
|
||||||
]);
|
]);
|
||||||
// TODO(twd2): improve here:
|
// TODO(twd2): improve here:
|
||||||
for (const mdoc of mdocs) {
|
const parsed = {};
|
||||||
this.udoc(udict, mdoc.from);
|
for (const m of messages) {
|
||||||
this.udoc(udict, mdoc.to);
|
if (m.from === this.user._id) {
|
||||||
|
if (!parsed[m.to]) {
|
||||||
|
parsed[m.to] = {
|
||||||
|
udoc: { ...udict[m.to], gravatar: misc.gravatar(udict[m.to].gravatar) },
|
||||||
|
messages: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
parsed[m.to].messages.push(m);
|
||||||
|
} else {
|
||||||
|
if (!parsed[m.from]) {
|
||||||
|
parsed[m.from] = {
|
||||||
|
udoc: { ...udict[m.from], gravatar: misc.gravatar(udict[m.from].gravatar) },
|
||||||
|
messages: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
parsed[m.from].messages.push(m);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const path = [
|
const path = [
|
||||||
['Hydro', '/'],
|
['Hydro', '/'],
|
||||||
['home_messages', null],
|
['home_messages', null],
|
||||||
];
|
];
|
||||||
this.response.body = { messages: mdocs, udict, path };
|
this.response.body = { messages, udict, path };
|
||||||
this.response.template = 'home_messages.html';
|
this.response.template = 'home_messages.html';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ class HomeworkMainHandler extends HomeworkHandler {
|
|||||||
const tdocs = await contest.getMulti(domainId, {}, document.TYPE_HOMEWORK).toArray();
|
const tdocs = await contest.getMulti(domainId, {}, document.TYPE_HOMEWORK).toArray();
|
||||||
const calendar = [];
|
const calendar = [];
|
||||||
for (const tdoc of tdocs) {
|
for (const tdoc of tdocs) {
|
||||||
console.log(tdoc);
|
const cal = { ...tdoc, url: `/homework/${tdoc.docId}` };
|
||||||
const cal = { ...tdoc };
|
|
||||||
if (contest.isHomeworkExtended(tdoc) || contest.isDone(tdoc)) {
|
if (contest.isHomeworkExtended(tdoc) || contest.isDone(tdoc)) {
|
||||||
cal.endAt = tdoc.endAt;
|
cal.endAt = tdoc.endAt;
|
||||||
cal.penaltySince = tdoc.penaltySince;
|
cal.penaltySince = tdoc.penaltySince;
|
||||||
@@ -37,7 +36,11 @@ class HomeworkMainHandler extends HomeworkHandler {
|
|||||||
}
|
}
|
||||||
calendar.push(cal);
|
calendar.push(cal);
|
||||||
}
|
}
|
||||||
this.response.body = { tdocs, calendar };
|
const path = [
|
||||||
|
['Hydro', '/'],
|
||||||
|
['homework_main', null],
|
||||||
|
];
|
||||||
|
this.response.body = { tdocs, calendar, path };
|
||||||
this.response.template = 'homework_main.html';
|
this.response.template = 'homework_main.html';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,6 +79,7 @@ class HomeworkDetailHandler extends HomeworkHandler {
|
|||||||
uids.push(tdoc.owner);
|
uids.push(tdoc.owner);
|
||||||
const udict = await user.getList(domainId, uids);
|
const udict = await user.getList(domainId, uids);
|
||||||
const path = [
|
const path = [
|
||||||
|
['Hydro', '/'],
|
||||||
['homework_main', '/homework'],
|
['homework_main', '/homework'],
|
||||||
[tdoc.title, null, true],
|
[tdoc.title, null, true],
|
||||||
];
|
];
|
||||||
@@ -113,6 +117,7 @@ class HomeworkDetailProblemHandler extends HomeworkHandler {
|
|||||||
}
|
}
|
||||||
if (!this.tdoc.pids.includes(pid)) throw new ProblemNotFoundError(domainId, pid, tid);
|
if (!this.tdoc.pids.includes(pid)) throw new ProblemNotFoundError(domainId, pid, tid);
|
||||||
const path = [
|
const path = [
|
||||||
|
['Hydro', '/'],
|
||||||
['homework_main', '/homework'],
|
['homework_main', '/homework'],
|
||||||
[this.tdoc.title, `/homework/${tid}`, true],
|
[this.tdoc.title, `/homework/${tid}`, true],
|
||||||
[this.pdoc.title, null, true],
|
[this.pdoc.title, null, true],
|
||||||
@@ -136,6 +141,7 @@ class HomeworkDetailProblemSubmitHandler extends HomeworkDetailProblemHandler {
|
|||||||
.sort('_id', -1).limit(10).toArray()
|
.sort('_id', -1).limit(10).toArray()
|
||||||
: [];
|
: [];
|
||||||
const path = [
|
const path = [
|
||||||
|
['Hydro', '/'],
|
||||||
['homework_main', '/homework'],
|
['homework_main', '/homework'],
|
||||||
[this.tdoc.title, `/homework/${tid}`, true],
|
[this.tdoc.title, `/homework/${tid}`, true],
|
||||||
[this.pdoc.title, `/homework/${tid}/p/${pid}`, true],
|
[this.pdoc.title, `/homework/${tid}/p/${pid}`, true],
|
||||||
@@ -162,6 +168,7 @@ class HomeworkDetailProblemSubmitHandler extends HomeworkDetailProblemHandler {
|
|||||||
rid, pid, false, 0, document.TYPE_HOMEWORK);
|
rid, pid, false, 0, document.TYPE_HOMEWORK);
|
||||||
this.response.body = { tid, rid };
|
this.response.body = { tid, rid };
|
||||||
if (this.canShowRecord(this.tdoc)) this.response.redirect = `/record/${rid}`;
|
if (this.canShowRecord(this.tdoc)) this.response.redirect = `/record/${rid}`;
|
||||||
|
else this.response.redirect = `/homework/${tid}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,6 +177,8 @@ class HomeworkCreateHandler extends HomeworkHandler {
|
|||||||
const beginAt = new Date().delta({ day: 1 });
|
const beginAt = new Date().delta({ day: 1 });
|
||||||
const penaltySince = beginAt.delta({ day: 7 });
|
const penaltySince = beginAt.delta({ day: 7 });
|
||||||
const path = [
|
const path = [
|
||||||
|
['Hydro', '/'],
|
||||||
|
['homework_main', '/homework'],
|
||||||
['homework_create', null],
|
['homework_create', null],
|
||||||
];
|
];
|
||||||
this.response.template = 'homework_edit.html';
|
this.response.template = 'homework_edit.html';
|
||||||
@@ -221,6 +230,7 @@ class HomeworkEditHandler extends HomeworkHandler {
|
|||||||
(tdoc.endAt.getTime() - tdoc.penaltySince.getTime()) / 36000 / 24,
|
(tdoc.endAt.getTime() - tdoc.penaltySince.getTime()) / 36000 / 24,
|
||||||
) / 100;
|
) / 100;
|
||||||
const path = [
|
const path = [
|
||||||
|
['Hydro', '/'],
|
||||||
['homework_main', '/homework'],
|
['homework_main', '/homework'],
|
||||||
[tdoc.title, `/homework/${tid}`, true],
|
[tdoc.title, `/homework/${tid}`, true],
|
||||||
['homework_edit', null],
|
['homework_edit', null],
|
||||||
@@ -353,6 +363,7 @@ async function apply() {
|
|||||||
{ type: 'total_time', value: _('Total Time (Seconds)') },
|
{ type: 'total_time', value: _('Total Time (Seconds)') },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
columns.push({ type: 'total_time_str', value: _('Total Time') });
|
||||||
for (const index in tdoc.pids) {
|
for (const index in tdoc.pids) {
|
||||||
const pid = tdoc.pids[index];
|
const pid = tdoc.pids[index];
|
||||||
if (isExport) {
|
if (isExport) {
|
||||||
@@ -383,14 +394,13 @@ async function apply() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const rows = [columns];
|
const rows = [columns];
|
||||||
for (const rank in rankedTsdocs) {
|
for (const [rank, tsdoc] of rankedTsdocs) {
|
||||||
const tsdoc = rankedTsdocs[rank];
|
|
||||||
const tsddict = {};
|
const tsddict = {};
|
||||||
for (const item of tsdoc.journal || []) {
|
for (const item of tsdoc.journal || []) {
|
||||||
tsddict[item.pid] = item;
|
tsddict[item.pid] = item;
|
||||||
}
|
}
|
||||||
const row = [
|
const row = [
|
||||||
{ type: 'string', value: rank + 1 },
|
{ type: 'string', value: rank },
|
||||||
{
|
{
|
||||||
type: 'user',
|
type: 'user',
|
||||||
value: udict[tsdoc.uid].uname,
|
value: udict[tsdoc.uid].uname,
|
||||||
@@ -411,7 +421,7 @@ async function apply() {
|
|||||||
const colScore = (tsddict[pid] || {}).penaltyScore || '-';
|
const colScore = (tsddict[pid] || {}).penaltyScore || '-';
|
||||||
const colOriginalScore = (tsddict[pid] || {}).score || '-';
|
const colOriginalScore = (tsddict[pid] || {}).score || '-';
|
||||||
const colTime = (tsddict[pid] || {}).time || '-';
|
const colTime = (tsddict[pid] || {}).time || '-';
|
||||||
const colTimeStr = colTime !== '-' ? misc.formatSeconds(colTime) : '-';
|
const colTimeStr = colTime !== '-' ? misc.formatSeconds(colTime || 0) : '-';
|
||||||
if (isExport) {
|
if (isExport) {
|
||||||
row.push(
|
row.push(
|
||||||
{ type: 'string', value: colScore },
|
{ type: 'string', value: colScore },
|
||||||
@@ -431,7 +441,7 @@ async function apply() {
|
|||||||
}
|
}
|
||||||
return rows;
|
return rows;
|
||||||
},
|
},
|
||||||
rank: (tdocs) => ranked(tdocs, (a, b) => a.score === b.score),
|
rank: (tsdocs) => ranked(tsdocs, (a, b) => a.score === b.score),
|
||||||
};
|
};
|
||||||
Route('/homework', HomeworkMainHandler, PERM_VIEW_HOMEWORK);
|
Route('/homework', HomeworkMainHandler, PERM_VIEW_HOMEWORK);
|
||||||
Route('/homework/create', HomeworkCreateHandler, PERM_CREATE_HOMEWORK);
|
Route('/homework/create', HomeworkCreateHandler, PERM_CREATE_HOMEWORK);
|
||||||
|
|||||||
+37
-20
@@ -1,7 +1,5 @@
|
|||||||
const {
|
const { PERM_READ_RECORD_CODE, PERM_REJUDGE, PERM_VIEW_PROBLEM_HIDDEN } = require('../permission');
|
||||||
PERM_READ_RECORD_CODE, PERM_VIEW_CONTEST_HIDDEN_SCOREBOARD,
|
const { PermissionError } = require('../error');
|
||||||
PERM_REJUDGE, PERM_VIEW_PROBLEM_HIDDEN,
|
|
||||||
} = require('../permission');
|
|
||||||
const problem = require('../model/problem');
|
const problem = require('../model/problem');
|
||||||
const record = require('../model/record');
|
const record = require('../model/record');
|
||||||
const contest = require('../model/contest');
|
const contest = require('../model/contest');
|
||||||
@@ -20,7 +18,12 @@ class RecordListHandler extends RecordHandler {
|
|||||||
}) {
|
}) {
|
||||||
this.response.template = 'record_main.html';
|
this.response.template = 'record_main.html';
|
||||||
const q = { tid };
|
const q = { tid };
|
||||||
if (uname_or_uid) q.$or = [{ unameLower: uname_or_uid.toLowerCase() }, { _id: parseInt(uname_or_uid) }];
|
if (uname_or_uid) {
|
||||||
|
q.$or = [
|
||||||
|
{ unameLower: uname_or_uid.toLowerCase() },
|
||||||
|
{ _id: parseInt(uname_or_uid) },
|
||||||
|
];
|
||||||
|
}
|
||||||
const rdocs = await record.getMany(domainId, q, { _id: -1 }, page, await system.get('RECORD_PER_PAGE'));
|
const rdocs = await record.getMany(domainId, q, { _id: -1 }, page, await system.get('RECORD_PER_PAGE'));
|
||||||
const [udict, pdict] = await Promise.all([
|
const [udict, pdict] = await Promise.all([
|
||||||
user.getList(domainId, rdocs.map((rdoc) => rdoc.uid)),
|
user.getList(domainId, rdocs.map((rdoc) => rdoc.uid)),
|
||||||
@@ -73,16 +76,30 @@ class RecordRejudgeHandler extends Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RecordConnectionHandler extends ConnectionHandler {
|
const RecordConnectionHandler = contest.ContestHandlerMixin(ConnectionHandler);
|
||||||
async prepare({ domainId }) {
|
|
||||||
|
class RecordMainConnectionHandler extends RecordConnectionHandler {
|
||||||
|
async prepare({ domainId, tid }) {
|
||||||
this.domainId = domainId;
|
this.domainId = domainId;
|
||||||
|
if (tid) {
|
||||||
|
const tdoc = await contest.get(domainId, tid, -1);
|
||||||
|
if (this.canShowRecord(tdoc)) this.tid = tid;
|
||||||
|
else {
|
||||||
|
this.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
bus.subscribe(['record_change'], this.onRecordChange);
|
bus.subscribe(['record_change'], this.onRecordChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
async message(msg) {
|
async message(msg) {
|
||||||
for (const rid of msg.rids) {
|
const rdocs = await record.getMany(
|
||||||
const rdoc = await record.get(this.domainId, rid); // eslint-disable-line no-await-in-loop
|
this.domainId,
|
||||||
await this.onRecordChange({ value: rdoc }); // eslint-disable-line no-await-in-loop
|
{ _id: { $in: msg.rids } },
|
||||||
|
{ _id: -1 }, 1, 100,
|
||||||
|
);
|
||||||
|
for (const rdoc of rdocs) {
|
||||||
|
this.onRecordChange({ value: rdoc });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +124,7 @@ class RecordDetailConnectionHandler extends contest.ContestHandlerMixin(Connecti
|
|||||||
async prepare({ domainId, rid }) {
|
async prepare({ domainId, rid }) {
|
||||||
const rdoc = await record.get(domainId, rid);
|
const rdoc = await record.get(domainId, rid);
|
||||||
if (rdoc.tid) {
|
if (rdoc.tid) {
|
||||||
const tdoc = await contest.get(domainId, rdoc.tid);
|
const tdoc = await contest.get(domainId, rdoc.tid, -1);
|
||||||
if (!this.canShowRecord(tdoc)) {
|
if (!this.canShowRecord(tdoc)) {
|
||||||
this.close();
|
this.close();
|
||||||
return;
|
return;
|
||||||
@@ -133,21 +150,21 @@ class RecordDetailConnectionHandler extends contest.ContestHandlerMixin(Connecti
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function apply() {
|
async function apply() {
|
||||||
Route('/r', module.exports.RecordListHandler);
|
Route('/r', RecordListHandler);
|
||||||
Route('/r/:rid', module.exports.RecordDetailHandler);
|
Route('/r/:rid', RecordDetailHandler);
|
||||||
Route('/r/:rid/rejudge', module.exports.RecordRejudgeHandler);
|
Route('/r/:rid/rejudge', RecordRejudgeHandler);
|
||||||
Route('/record', module.exports.RecordListHandler);
|
Route('/record', RecordListHandler);
|
||||||
Route('/record/:rid', module.exports.RecordDetailHandler);
|
Route('/record/:rid', RecordDetailHandler);
|
||||||
Route('/record/:rid/rejudge', module.exports.RecordRejudgeHandler);
|
Route('/record/:rid/rejudge', RecordRejudgeHandler);
|
||||||
Connection('/record-conn', module.exports.RecordConnectionHandler);
|
Connection('/record-conn', RecordMainConnectionHandler);
|
||||||
Connection('/record-detail-conn', module.exports.RecordDetailConnectionHandler);
|
Connection('/record-detail-conn', RecordDetailConnectionHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
global.Hydro.handler.record = module.exports = {
|
global.Hydro.handler.record = module.exports = {
|
||||||
RecordListHandler,
|
RecordListHandler,
|
||||||
RecordDetailHandler,
|
RecordDetailHandler,
|
||||||
RecordRejudgeHandler,
|
RecordRejudgeHandler,
|
||||||
RecordConnectionHandler,
|
RecordMainConnectionHandler,
|
||||||
RecordDetailConnectionHandler,
|
RecordDetailConnectionHandler,
|
||||||
apply,
|
apply,
|
||||||
};
|
};
|
||||||
+11
-2
@@ -49,9 +49,18 @@ function size(s, base = 1) {
|
|||||||
return '{0} {1}'.format(Math.round(s * unit), unitNames[unitNames.length - 1]);
|
return '{0} {1}'.format(Math.round(s * unit), unitNames[unitNames.length - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatSeconds(seconds) {
|
function _digit2(number) {
|
||||||
|
if (number < 10) return `0${number}`;
|
||||||
|
return number.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatSeconds(seconds = 0) {
|
||||||
seconds = parseInt(seconds);
|
seconds = parseInt(seconds);
|
||||||
return '{:02}:{:02}:{:02}'.format(Math.floor(seconds / 3600), Math.floor((seconds % 3600) / 60), seconds % 60);
|
return '{0}:{1}:{2}'.format(
|
||||||
|
_digit2(Math.floor(seconds / 3600)),
|
||||||
|
_digit2(Math.floor((seconds % 3600) / 60)),
|
||||||
|
_digit2(seconds % 60),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
global.Hydro.lib.misc = module.exports = {
|
global.Hydro.lib.misc = module.exports = {
|
||||||
|
|||||||
+3
-8
@@ -20,20 +20,15 @@ let pending = [];
|
|||||||
const active = [];
|
const active = [];
|
||||||
const fail = [];
|
const fail = [];
|
||||||
|
|
||||||
try {
|
if (global._hydroModule) {
|
||||||
// Let webpack pack builtin module together.
|
for (const filename in global._hydroModule) {
|
||||||
// eslint-disable-next-line import/no-unresolved
|
|
||||||
const f = require('../.build/module.json');
|
|
||||||
for (const filename in f) {
|
|
||||||
const m = {
|
const m = {
|
||||||
...yaml.safeLoad(zlib.gunzipSync(Buffer.from(f[filename], 'base64'))),
|
...yaml.safeLoad(zlib.gunzipSync(Buffer.from(global._hydroModule[filename], 'base64'))),
|
||||||
filename,
|
filename,
|
||||||
isBuiltin: true,
|
isBuiltin: true,
|
||||||
};
|
};
|
||||||
pending.push(m);
|
pending.push(m);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
|
||||||
// Ignore Missing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function preload() {
|
async function preload() {
|
||||||
|
|||||||
@@ -245,7 +245,11 @@ async function edit(domainId, tid, $set, type = document.TYPE_CONTEST) {
|
|||||||
* @returns {Tdoc}
|
* @returns {Tdoc}
|
||||||
*/
|
*/
|
||||||
async function get(domainId, tid, type = document.TYPE_CONTEST) {
|
async function get(domainId, tid, type = document.TYPE_CONTEST) {
|
||||||
const tdoc = await document.get(domainId, type, tid);
|
let tdoc;
|
||||||
|
if (type === -1) {
|
||||||
|
tdoc = await document.get(domainId, document.TYPE_CONTEST, tid);
|
||||||
|
if (!tdoc) tdoc = await document.get(domainId, document.TYPE_HOMEWORK, tid);
|
||||||
|
} else tdoc = await document.get(domainId, type, tid);
|
||||||
if (!tdoc) throw new ContestNotFoundError(tid);
|
if (!tdoc) throw new ContestNotFoundError(tid);
|
||||||
return tdoc;
|
return tdoc;
|
||||||
}
|
}
|
||||||
@@ -265,10 +269,11 @@ function getStatus(domainId, tid, uid, type = document.TYPE_CONTEST) {
|
|||||||
return document.getStatus(domainId, type, tid, uid);
|
return document.getStatus(domainId, type, tid, uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getListStatus(domainId, uid, tids) {
|
async function getListStatus(domainId, uid, tids, type = document.TYPE_CONTEST) {
|
||||||
const r = {};
|
const r = {};
|
||||||
|
console.log(tids);
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
for (const tid of tids) r[tid] = await getStatus(domainId, tid, uid);
|
for (const tid of tids) r[tid] = await getStatus(domainId, tid, uid, type);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,7 +332,7 @@ const ContestHandlerMixin = (c) => class extends c {
|
|||||||
async getScoreboard(domainId, tid, isExport = false, docType = document.TYPE_CONTEST) {
|
async getScoreboard(domainId, tid, isExport = false, docType = document.TYPE_CONTEST) {
|
||||||
const tdoc = await get(domainId, tid, docType);
|
const tdoc = await get(domainId, tid, docType);
|
||||||
if (!this.canShowScoreboard(tdoc)) throw new ContestScoreboardHiddenError(tid);
|
if (!this.canShowScoreboard(tdoc)) throw new ContestScoreboardHiddenError(tid);
|
||||||
const tsdocs = await getMultiStatus(domainId, tid, docType)
|
const tsdocs = await getMultiStatus(domainId, { docId: tid }, docType)
|
||||||
.sort(RULES[tdoc.rule].statusSort).toArray();
|
.sort(RULES[tdoc.rule].statusSort).toArray();
|
||||||
const uids = [];
|
const uids = [];
|
||||||
for (const tsdoc of tsdocs) uids.push(tsdoc.uid);
|
for (const tsdoc of tsdocs) uids.push(tsdoc.uid);
|
||||||
|
|||||||
+7
-23
@@ -5,29 +5,8 @@ const db = require('../service/db.js');
|
|||||||
const coll = db.collection('message');
|
const coll = db.collection('message');
|
||||||
|
|
||||||
async function send(from, to, content) {
|
async function send(from, to, content) {
|
||||||
await coll.updateOne({
|
await coll.insertOne({
|
||||||
from: Math.min(from, to),
|
from, to, content, unread: true,
|
||||||
to: Math.max(from, to),
|
|
||||||
}, {
|
|
||||||
$push: {
|
|
||||||
reply: {
|
|
||||||
_id: new ObjectID(),
|
|
||||||
from,
|
|
||||||
content,
|
|
||||||
unread: true,
|
|
||||||
at: new Date(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
$setOnInsert: {
|
|
||||||
from: Math.min(from, to),
|
|
||||||
to: Math.max(from, to),
|
|
||||||
fromUnread: from > to,
|
|
||||||
toUnread: from < to,
|
|
||||||
},
|
|
||||||
}, { upsert: true });
|
|
||||||
return await coll.findOne({ // eslint-disable-line no-return-await
|
|
||||||
from: Math.min(from, to),
|
|
||||||
to: Math.max(from, to),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,6 +16,10 @@ async function get(_id) {
|
|||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getByUser(uid) {
|
||||||
|
return coll.find({ $or: [{ from: uid }, { to: uid }] }).toArray();
|
||||||
|
}
|
||||||
|
|
||||||
function getMany(query, sort, page, limit) {
|
function getMany(query, sort, page, limit) {
|
||||||
return coll.find(query).sort(sort)
|
return coll.find(query).sort(sort)
|
||||||
.skip((page - 1) * limit).limit(limit)
|
.skip((page - 1) * limit).limit(limit)
|
||||||
@@ -65,6 +48,7 @@ function ensureIndexes() {
|
|||||||
global.Hydro.model.message = module.exports = {
|
global.Hydro.model.message = module.exports = {
|
||||||
count,
|
count,
|
||||||
get,
|
get,
|
||||||
|
getByUser,
|
||||||
del,
|
del,
|
||||||
getMany,
|
getMany,
|
||||||
getMulti,
|
getMulti,
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ const db = require('../service/db');
|
|||||||
const coll = db.collection('task');
|
const coll = db.collection('task');
|
||||||
|
|
||||||
async function add(task) {
|
async function add(task) {
|
||||||
console.log(task);
|
|
||||||
const res = await coll.insertOne(task);
|
const res = await coll.insertOne(task);
|
||||||
return res.insertedId;
|
return res.insertedId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ async function run(username, password) {
|
|||||||
TRAINING_PER_PAGE: 10,
|
TRAINING_PER_PAGE: 10,
|
||||||
DISCUSSION_PER_PAGE: 50,
|
DISCUSSION_PER_PAGE: 50,
|
||||||
REPLY_PER_PAGE: 50,
|
REPLY_PER_PAGE: 50,
|
||||||
|
HOMEWORK_ON_MAIN: 5,
|
||||||
CONTESTS_ON_MAIN: 5,
|
CONTESTS_ON_MAIN: 5,
|
||||||
TRAININGS_ON_MAIN: 5,
|
TRAININGS_ON_MAIN: 5,
|
||||||
DISCUSSIONS_ON_MAIN: 20,
|
DISCUSSIONS_ON_MAIN: 20,
|
||||||
|
|||||||
File renamed without changes.
@@ -43,7 +43,7 @@ const tasks = {
|
|||||||
doc_type: 'docType',
|
doc_type: 'docType',
|
||||||
num_submit: 'nSubmit',
|
num_submit: 'nSubmit',
|
||||||
num_accept: 'nAccept',
|
num_accept: 'nAccept',
|
||||||
difficulty_admin: 'difficulty',
|
difficulty: 'difficulty',
|
||||||
pname: 'pid',
|
pname: 'pid',
|
||||||
title: 'title',
|
title: 'title',
|
||||||
content: 'content',
|
content: 'content',
|
||||||
@@ -64,6 +64,17 @@ const tasks = {
|
|||||||
update_at: 'updateAt',
|
update_at: 'updateAt',
|
||||||
begin_at: 'beginAt',
|
begin_at: 'beginAt',
|
||||||
end_at: 'endAt',
|
end_at: 'endAt',
|
||||||
|
penalty_since: 'penaltySince',
|
||||||
|
penalty_rules: {
|
||||||
|
field: 'penaltyRules',
|
||||||
|
processer: (rule) => {
|
||||||
|
const n = {};
|
||||||
|
for (const key in rule) {
|
||||||
|
n[key / 3600] = rule;
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
},
|
||||||
|
},
|
||||||
rule: {
|
rule: {
|
||||||
field: 'rule',
|
field: 'rule',
|
||||||
processer: (rule) => {
|
processer: (rule) => {
|
||||||
@@ -176,7 +187,7 @@ const tasks = {
|
|||||||
score: c.score,
|
score: c.score,
|
||||||
time: c.time_ms || c.time,
|
time: c.time_ms || c.time,
|
||||||
memory: c.memory_kb || c.memory,
|
memory: c.memory_kb || c.memory,
|
||||||
judge_text: (c.judge_text || '') + (c.message || ''),
|
judgeText: (c.judge_text || '') + (c.message || ''),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
@@ -194,7 +205,7 @@ const tasks = {
|
|||||||
judger: doc.judge_uid,
|
judger: doc.judge_uid,
|
||||||
judgeAt: doc.judge_at,
|
judgeAt: doc.judge_at,
|
||||||
judgeTexts: doc.judge_texts,
|
judgeTexts: doc.judge_texts,
|
||||||
compileTexts: doc.compile_texts,
|
compilerTexts: doc.compiler_texts,
|
||||||
rejudged: doc.rejudged,
|
rejudged: doc.rejudged,
|
||||||
testCases,
|
testCases,
|
||||||
};
|
};
|
||||||
@@ -242,25 +253,42 @@ async function task(name, src, report) {
|
|||||||
const count = await cursor[name](src).count();
|
const count = await cursor[name](src).count();
|
||||||
await report({ progress: 1, message: `${name}: ${count}` });
|
await report({ progress: 1, message: `${name}: ${count}` });
|
||||||
const total = Math.floor(count / 50);
|
const total = Math.floor(count / 50);
|
||||||
|
let lastProgress = -1;
|
||||||
for (let i = 0; i <= total; i++) {
|
for (let i = 0; i <= total; i++) {
|
||||||
const docs = await cursor[name](src).skip(i * 50).limit(50).toArray();
|
const docs = await cursor[name](src).skip(i * 50).limit(50).toArray();
|
||||||
const res = [];
|
const res = [];
|
||||||
for (const doc of docs) {
|
for (const doc of docs) {
|
||||||
const d = await tasks[name](doc);
|
const d = await tasks[name](doc);
|
||||||
if (d) {
|
if (d) {
|
||||||
if (d.docId && d.docType) {
|
const docWithoutId = {};
|
||||||
res.push(dst.collection(name).updateOne({
|
const docWithoutDid = {};
|
||||||
docId: d.docId, docType: d.docType,
|
for (const key in d) {
|
||||||
}, { $set: d }, { upsert: true }));
|
if (key !== '_id') {
|
||||||
|
if (key !== 'domainId' && key !== 'docId' && key !== 'docType' && key !== 'uid') {
|
||||||
|
docWithoutDid[key] = d[key];
|
||||||
|
}
|
||||||
|
docWithoutId[key] = d[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (d.domainId && d.docId && d.docType) {
|
||||||
|
const query = { domainId: d.domainId, docId: d.docId, docType: d.docType };
|
||||||
|
if (d.uid) query.uid = d.uid;
|
||||||
|
res.push(dst.collection(name).updateOne(
|
||||||
|
query, { $set: docWithoutDid }, { upsert: true },
|
||||||
|
));
|
||||||
} else if (d._id) {
|
} else if (d._id) {
|
||||||
res.push(dst.collection(name).updateOne({
|
res.push(dst.collection(name).updateOne({
|
||||||
_id: d._id,
|
_id: d._id,
|
||||||
}, { $set: d }, { upsert: true }));
|
}, { $set: docWithoutId }, { upsert: true }));
|
||||||
} else res.push(dst.collection(name).insertOne(d));
|
} else res.push(dst.collection(name).insertOne(d));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await Promise.all(res);
|
await Promise.all(res);
|
||||||
await report({ progress: Math.round(100 * ((i + 1) / (total + 1))) });
|
const progress = Math.round(100 * ((i + 1) / (total + 1)));
|
||||||
|
if (progress > lastProgress) {
|
||||||
|
await report({ progress });
|
||||||
|
lastProgress = progress;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await fixPid(report);
|
await fixPid(report);
|
||||||
}
|
}
|
||||||
@@ -286,7 +314,6 @@ async function migrateVijos({
|
|||||||
{ upsert: true },
|
{ upsert: true },
|
||||||
);
|
);
|
||||||
await report({ progress: 1, message: 'Collection:system done.' });
|
await report({ progress: 1, message: 'Collection:system done.' });
|
||||||
await dst.collection('user').deleteMany({ _id: { $nin: [0, 1] } });
|
|
||||||
if (!await dst.collection('system').findOne({ _id: 'migrateVijosFs' })) {
|
if (!await dst.collection('system').findOne({ _id: 'migrateVijosFs' })) {
|
||||||
const f = ['fs.files', 'fs.chunks'];
|
const f = ['fs.files', 'fs.chunks'];
|
||||||
for (const i of f) {
|
for (const i of f) {
|
||||||
@@ -295,8 +322,10 @@ async function migrateVijos({
|
|||||||
}
|
}
|
||||||
await dst.collection('system').insertOne({ _id: 'migrateVijosFs', value: true });
|
await dst.collection('system').insertOne({ _id: 'migrateVijosFs', value: true });
|
||||||
}
|
}
|
||||||
|
await dst.collection('user').deleteMany({ _id: { $nin: [0, 1] } });
|
||||||
const d = ['user', 'document', 'document.status', 'record', 'file'];
|
const d = ['user', 'document', 'document.status', 'record', 'file'];
|
||||||
for (const i of d) await task(i, src, report);
|
for (const i of d) await task(i, src, report);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
global.Hydro.script.migrateVijos = module.exports = { run: migrateVijos };
|
global.Hydro.script.migrateVijos = module.exports = { run: migrateVijos };
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
{# No Compression #}
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
|||||||
@@ -56,6 +56,50 @@
|
|||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if htdocs.length %}
|
||||||
|
<div class="section page--homework_main">
|
||||||
|
<div class="section__header">
|
||||||
|
<h1 class="section__title">{{ _('Homework') }}</h1>
|
||||||
|
</div>
|
||||||
|
<ol class="section__list homework__list">
|
||||||
|
{% for tdoc in htdocs %}
|
||||||
|
<li class="section__list__item homework__item">
|
||||||
|
<div class="media">
|
||||||
|
<div class="media__left medium">
|
||||||
|
<div class="homework__date numbox">
|
||||||
|
<div class="numbox__num large">{{ datetimeSpan(tdoc['penaltySince'], false, '%d')|safe }}</div>
|
||||||
|
<div class="numbox__text">{{ datetimeSpan(tdoc['penaltySince'], false, '%Y-%m')|safe }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="media__body medium">
|
||||||
|
<h1 class="homework__title"><a href="/homework/{{ tdoc.docId }}" data-emoji-enabled>{{ tdoc['title'] }}</a></h1>
|
||||||
|
<ul class="supplementary list">
|
||||||
|
<li>
|
||||||
|
{{ _('Status') }}: <span class="homework-status--text {{ model.contest.getStatus(tdoc) }}">{{ _(model.contest.statusText(tdoc)) }}</span>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
{{ _('Open Since') }}: {{ datetimeSpan(tdoc['beginAt'])|safe }}
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
{% if model.contest.isHomeworkExtended(tdoc) or model.contest.isDone(tdoc) %}
|
||||||
|
{{ _('Hard Deadline') }}: {{ datetimeSpan(tdoc['endAt'])|safe }}
|
||||||
|
{% else %}
|
||||||
|
{{ _('Deadline') }}: {{ datetimeSpan(tdoc['penaltySince'])|safe }}
|
||||||
|
{% endif %}
|
||||||
|
</li>
|
||||||
|
{% if htsdict[tdoc['docId']]['attend'] == 1 %}
|
||||||
|
<li class="homework__info-attended">
|
||||||
|
<span class="icon icon-check"></span> {{ _('Claimed') }}
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% if trdocs.length %}
|
{% if trdocs.length %}
|
||||||
<div class="section page--training_main">
|
<div class="section page--training_main">
|
||||||
<div class="section__header">
|
<div class="section__header">
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
{# No Compression #}
|
||||||
<div class="dialog dialog--signin" style="display:none">
|
<div class="dialog dialog--signin" style="display:none">
|
||||||
<div class="dialog__content">
|
<div class="dialog__content">
|
||||||
<div class="dialog--signin__bg">
|
<div class="dialog--signin__bg">
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ export default class MessagePadDialogueContentContainer extends React.PureCompon
|
|||||||
isSelf={reply.from === UserContext._id}
|
isSelf={reply.from === UserContext._id}
|
||||||
faceUrl={
|
faceUrl={
|
||||||
reply.from === this.props.item.from
|
reply.from === this.props.item.from
|
||||||
? this.props.item.from_udoc.gravatar_url
|
? this.props.item.from_udoc.gravatar
|
||||||
: this.props.item.to_udoc.gravatar_url
|
: this.props.item.to_udoc.gravatar
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<div>{reply.content}</div>
|
<div>{reply.content}</div>
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ export default class MessagePadDialogueListContainer extends React.PureComponent
|
|||||||
}
|
}
|
||||||
faceUrl={
|
faceUrl={
|
||||||
dialogue.from === UserContext._id
|
dialogue.from === UserContext._id
|
||||||
? dialogue.to_udoc.gravatar_url
|
? dialogue.to_udoc.gravatar
|
||||||
: dialogue.from_udoc.gravatar_url
|
: dialogue.from_udoc.gravatar
|
||||||
}
|
}
|
||||||
active={dialogue._id === this.props.activeId}
|
active={dialogue._id === this.props.activeId}
|
||||||
onClick={() => this.props.handleClick(dialogue._id)}
|
onClick={() => this.props.handleClick(dialogue._id)}
|
||||||
|
|||||||
@@ -35,10 +35,7 @@ const page = new NamedPage('home_messages', () => {
|
|||||||
|
|
||||||
reduxStore = store;
|
reduxStore = store;
|
||||||
|
|
||||||
const sock = new SockJs('/home/messages-conn');
|
const sock = new SockJs(`/home/messages-conn?token=${UiContext.csrfToken}`);
|
||||||
sock.onopen = () => {
|
|
||||||
sock.send(document.cookie);
|
|
||||||
};
|
|
||||||
sock.onmessage = (message) => {
|
sock.onmessage = (message) => {
|
||||||
const msg = JSON.parse(message.data);
|
const msg = JSON.parse(message.data);
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ const page = new NamedPage('homework_main', () => {
|
|||||||
// Homework Calendar
|
// Homework Calendar
|
||||||
if (Context.docs) {
|
if (Context.docs) {
|
||||||
const events = Context.docs.map((doc) => ({
|
const events = Context.docs.map((doc) => ({
|
||||||
beginAt: doc.beginAt * 1000,
|
beginAt: doc.beginAt,
|
||||||
endAt: doc.endAt * 1000,
|
endAt: doc.endAt,
|
||||||
title: doc.title,
|
title: doc.title,
|
||||||
maskFrom: doc.penaltySince ? doc.penaltySince * 1000 : null,
|
maskFrom: doc.penaltySince ? doc.penaltySince : null,
|
||||||
maskTitle: i18n('Time Extension'),
|
maskTitle: i18n('Time Extension'),
|
||||||
colorIndex: parseMongoId(doc.id).timestamp % 12,
|
colorIndex: parseMongoId(doc._id).timestamp % 12,
|
||||||
link: doc.url,
|
link: doc.url,
|
||||||
}));
|
}));
|
||||||
const calendar = new Calendar(events);
|
const calendar = new Calendar(events);
|
||||||
|
|||||||
Reference in new issue
Block a user