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
+18 -4

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.29.37", "version": "2.29.38",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "dist/loader.js", "main": "dist/loader.js",
"typings": "dist/loader.d.ts", "typings": "dist/loader.d.ts",
+13
View File
@@ -562,6 +562,18 @@ export class ProblemCreateHandler extends Handler {
export class ProblemPrefixListHandler extends Handler { export class ProblemPrefixListHandler extends Handler {
@param('prefix', Types.Name) @param('prefix', Types.Name)
async get(domainId: string, prefix: string) { 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); const pdocs = await problem.getPrefixList(domainId, prefix);
if (!Number.isNaN(+prefix)) { if (!Number.isNaN(+prefix)) {
const pdoc = await problem.get(domainId, +prefix, ['domainId', 'docId', 'pid', 'title']); const pdoc = await problem.get(domainId, +prefix, ['domainId', 'docId', 'pid', 'title']);
@@ -576,6 +588,7 @@ export class ProblemPrefixListHandler extends Handler {
} }
} }
this.response.body = pdocs; 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", "name": "@hydrooj/ui-default",
"version": "4.13.2", "version": "4.13.3",
"author": "undefined <i@undefined.moe>", "author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"main": "hydro.js", "main": "hydro.js",
@@ -214,6 +214,7 @@ const page = new NamedPage(['problem_main', 'problem_category'], () => {
$('[name="hide_selected_problems"]').on('click', () => handleOperation('hide')); $('[name="hide_selected_problems"]').on('click', () => handleOperation('hide'));
$('[name="unhide_selected_problems"]').on('click', () => handleOperation('unhide')); $('[name="unhide_selected_problems"]').on('click', () => handleOperation('unhide'));
$('[name="download_selected_problems"]').on('click', handleDownload); $('[name="download_selected_problems"]').on('click', handleDownload);
$('#hideTags').on('click', () => $('.problem__tags').hide());
$('#search').on('click', (ev) => { $('#search').on('click', (ev) => {
ev.preventDefault(); ev.preventDefault();
updateSelection(); updateSelection();
@@ -33,7 +33,7 @@
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %} {% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
<th class="col--status record-status--border edit-mode-hide">{{ _('Status') }}</th> <th class="col--status record-status--border edit-mode-hide">{{ _('Status') }}</th>
{% endif %} {% endif %}
<th class="col--name">{{ _('Problem') }}</th> <th class="col--name">{{ _('Problem') }}<span style="float:right" id="hideTags">{{ _('Hide tags') }}</span></th>
<th class="col--tried">{{ _('Tried') }}</th> <th class="col--tried">{{ _('Tried') }}</th>
<th class="col--ac">{{ _('AC') }}</th> <th class="col--ac">{{ _('AC') }}</th>
<th class="col--difficulty">{{ _('Difficulty') }}</th> <th class="col--difficulty">{{ _('Difficulty') }}</th>
@@ -13,7 +13,7 @@
<div class="section__body no-padding"> <div class="section__body no-padding">
<form method="get" id="searchForm" action="{{ url('problem_main') }}"> <form method="get" id="searchForm" action="{{ url('problem_main') }}">
<div class="search"> <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" %} {% include "partials/problem_stat.html" %}
<button type="submit"> <button type="submit">
<span class="icon icon-search"></span> <span class="icon icon-search"></span>