add unrank & star user on scoreboard ui

This commit is contained in:
panda committed 2022-12-17 01:14:52 +00:00
1 parent dc0e397d77
commit b8fd94df50
5 files changed
+42 -5

No files matched your search

+2 -1
View File
@@ -368,7 +368,8 @@ export interface Tdoc<docType = document['TYPE_CONTEST'] | document['TYPE_TRAINI
unlocked?: boolean;
access?: number;
autoHide?: boolean;
unrankUsers?: number[];
unrankUser?: number[];
uninvite?: boolean;
/**
* In hours
+4
View File
@@ -11,6 +11,10 @@ const ranked: ranked = async (cursor, equ) => {
for (const doc of docs) {
count++;
if (!last || !equ(last, doc)) r = count;
if (doc.unrank) {
results.push([0, doc]);
continue;
}
last = doc;
results.push([r, doc]);
}
+2 -2
View File
@@ -127,7 +127,7 @@ const acm = buildContestRule({
async scoreboardRow(isExport, _, tdoc, pdict, udoc, rank, tsdoc, meta) {
const tsddict = tsdoc.detail || {};
const row: ScoreboardRow = [
{ type: 'rank', value: rank.toString() },
{ type: 'rank', value: rank ? rank.toString() : '*' },
{ type: 'user', value: udoc.uname, raw: tsdoc.uid },
];
if (isExport) {
@@ -263,7 +263,7 @@ const oi = buildContestRule({
async scoreboardRow(isExport, _, tdoc, pdict, udoc, rank, tsdoc, meta) {
const tsddict = tsdoc.detail || {};
const row: ScoreboardNode[] = [
{ type: 'rank', value: rank.toString() },
{ type: 'rank', value: rank ? rank.toString() : '*' },
{ type: 'user', value: udoc.uname, raw: tsdoc.uid },
];
if (isExport) {
@@ -127,6 +127,26 @@
}) }}
</div>
</div>
<div class="row">
{{ form.form_text({
columns:9,
label:'UnRank User',
name:'unrankUser',
help_text:_('User who will not show rank in scoreboard'),
value:tdoc.unrankUser|default(''),
row:false
}) }}
<div style="display: none" class="authorize-settings authorize--invite">
{{ form.form_checkbox({
columns:3,
label:'Allow join by unrank',
name:'uninvite',
placeholder:_('Allow user join by unrank user without invite code'),
value:tdoc.uninvite|default(true),
row:false
}) }}
</div>
</div>
</div>
<div style="padding-top: 0" class="section__header">
<h2 class="section__title">{{ _('Contest Settings') }}</h2>
@@ -164,7 +184,7 @@
label:'Lock (minutes)',
name:'lock',
placeholder:_('(leave blank if none)'),
value:(((tdoc.endAt - tdoc.lockAt)/60000)|int)|default(''),
value:(((tdoc.endAt - tdoc.lockAt)/60000)|int) if tdoc.lockAt else '',
help_text:_('Lock scoreboard on last N minutes'),
disabled:true,
row:false
@@ -22,12 +22,20 @@
{% if model.contest.isDone(tdoc) and tdoc.lockAt and handler.user.own(tdoc) and not tdoc.unlocked %}
<form method="POST">
<input type="hidden" name="operation" value="unlock">
<button type="submit" class="button" href="{{ url(type + '_scoreboard_download', tid=tdoc.docId, ext='csv') }}">
<button type="submit" class="button">
<span class="icon icon-feeling-lucky"></span> {{ _('Unlock scoreboard') }}
</button>
</form>
{% endif %}
<div class="section__tools">
<select class="select" name="list">
<option value="all">{{ _('All Users') }}</option>
<option value="star">{{ _('Stared Users') }}</option>
<option value="unrank">{{ _('Unrank Users') }}</option>
</select>
</div>
</div>
<h1 style="text-align:center" class="section__title">{{ tdoc.title }}</h1>
{% if model.contest.isLocked(tdoc) %}
<div class="section__body no-padding">
<blockquote class="note">
@@ -71,6 +79,10 @@
<td class="col--{{ rows[0][loop.index0]['type'] }}"{% if column.style %} style="{{ column.style }}"{% endif %}>
{%- if column.type == 'user' -%}
{%- set canView = canViewAll or handler.user._id == column.raw -%}
<button class="star user--{{ colomn.raw }}">
<span class="starred--hide"><span class="icon icon-star--outline" data-tooltip="{{ _('Star') }}"></span></span>
<span class="starred--show"><span class="icon icon-star" data-tooltip="{{ _('Unstar') }}"></span></span>
</button>
{{ user.render_inline(udict[column.raw], badge=false) }}
{%- elif column.type == 'record' and column.raw -%}
<a href="{{ url('record_detail', rid=column.raw) if canView else '' }}" data-tooltip="{{ column.hover }}">