core: prefixList with domain

This commit is contained in:
undefined committed 2021-07-24 14:50:53 +08:00
1 parent c67d626abe
commit f6a7ae4620
6 files changed
+29 -15

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.29.37",
"version": "2.29.38",
"bin": "bin/hydrooj.js",
"main": "dist/loader.js",
"typings": "dist/loader.d.ts",
+13
View File
@@ -562,6 +562,18 @@ export class ProblemCreateHandler extends Handler {
export class ProblemPrefixListHandler extends Handler {
@param('prefix', Types.Name)
async get(domainId: string, prefix: string) {
let cors = false;
if (prefix.includes(':')) {
const [pdomain, s] = prefix.split(':');
const ddoc = await domain.get(pdomain);
this.response.body = [];
if (!ddoc || ddoc._id === domainId || !ddoc.share || !s.trim()) return;
ddoc.share = ddoc.share.replace(/,/g, ',').split(',').map((q) => q.trim()).join(',');
if (ddoc.share !== '*' && !`,${ddoc.share},`.includes(`,${domainId},`)) return;
domainId = pdomain;
prefix = s;
cors = true;
}
const pdocs = await problem.getPrefixList(domainId, prefix);
if (!Number.isNaN(+prefix)) {
const pdoc = await problem.get(domainId, +prefix, ['domainId', 'docId', 'pid', 'title']);
@@ -576,6 +588,7 @@ export class ProblemPrefixListHandler extends Handler {
}
}
this.response.body = pdocs;
if (cors) this.response.body.forEach((v) => { v.docId = `${domainId}:${v.docId}`; });
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/ui-default",
"version": "4.13.2",
"version": "4.13.3",
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0",
"main": "hydro.js",
@@ -214,6 +214,7 @@ const page = new NamedPage(['problem_main', 'problem_category'], () => {
$('[name="hide_selected_problems"]').on('click', () => handleOperation('hide'));
$('[name="unhide_selected_problems"]').on('click', () => handleOperation('unhide'));
$('[name="download_selected_problems"]').on('click', handleDownload);
$('#hideTags').on('click', () => $('.problem__tags').hide());
$('#search').on('click', (ev) => {
ev.preventDefault();
updateSelection();
@@ -22,18 +22,18 @@
</colgroup>
<thead>
<tr>
{% if handler.user.hasPerm(perm.PERM_EDIT_PROBLEM) %}
<th class="col--checkbox display-mode-hide">
<label class="compact checkbox">
<input type="checkbox" name="select_all" data-checkbox-toggle="problem">
</label>
</th>
<th class="col--pid display-mode-hide">{{ _('ID') }}</th>
{% endif %}
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
<th class="col--status record-status--border edit-mode-hide">{{ _('Status') }}</th>
{% endif %}
<th class="col--name">{{ _('Problem') }}</th>
{% if handler.user.hasPerm(perm.PERM_EDIT_PROBLEM) %}
<th class="col--checkbox display-mode-hide">
<label class="compact checkbox">
<input type="checkbox" name="select_all" data-checkbox-toggle="problem">
</label>
</th>
<th class="col--pid display-mode-hide">{{ _('ID') }}</th>
{% endif %}
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
<th class="col--status record-status--border edit-mode-hide">{{ _('Status') }}</th>
{% endif %}
<th class="col--name">{{ _('Problem') }}<span style="float:right" id="hideTags">{{ _('Hide tags') }}</span></th>
<th class="col--tried">{{ _('Tried') }}</th>
<th class="col--ac">{{ _('AC') }}</th>
<th class="col--difficulty">{{ _('Difficulty') }}</th>
@@ -13,7 +13,7 @@
<div class="section__body no-padding">
<form method="get" id="searchForm" action="{{ url('problem_main') }}">
<div class="search">
<input name="q" type="text" value="{{ category }}" placeholder="1001">
<input name="q" type="text" value="{{ category }}" placeholder="{{ _('Search') }}">
{% include "partials/problem_stat.html" %}
<button type="submit">
<span class="icon icon-search"></span>