Skip to content

Commit

Permalink
feat: submissions modal
Browse files Browse the repository at this point in the history
Signed-off-by: Dup4 <lyuzhi.pan@gmail.com>
  • Loading branch information
Dup4 committed Nov 4, 2023
1 parent d07eb21 commit 97a9092
Show file tree
Hide file tree
Showing 5 changed files with 307 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/apps/board/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ declare module 'vue' {
StandingsAnnotate: typeof import('./components/board/StandingsAnnotate.vue')['default']
StarIcon: typeof import('./components/icon/StarIcon.vue')['default']
Statistics: typeof import('./components/board/Statistics.vue')['default']
SubmissionsModal: typeof import('./components/board/SubmissionsModal.vue')['default']
SubmissionsTable: typeof import('./components/board/SubmissionsTable.vue')['default']
SubmissionsTableModal: typeof import('./components/board/SubmissionsTableModal.vue')['default']
TablePagination: typeof import('./components/table/TablePagination.vue')['default']
Expand Down
18 changes: 11 additions & 7 deletions packages/apps/board/src/components/board/Board.vue
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,18 @@ const widthClass = "sm:w-[1260px] xl:w-screen";
</div>
</div>
</div>
</div>
<OptionsModal
v-if="!isHiddenOptionsModal"
v-model:is-hidden="isHiddenOptionsModal"
v-model:rank-options="rankOptions"
:rank="rank"
/>
<SubmissionsModal
:rank="rank"
/>
<OptionsModal
v-if="!isHiddenOptionsModal"
v-model:is-hidden="isHiddenOptionsModal"
v-model:rank-options="rankOptions"
:rank="rank"
/>
</div>
</div>
</template>
Expand Down
131 changes: 131 additions & 0 deletions packages/apps/board/src/components/board/SubmissionsModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<script setup lang="ts">
import type { Problem, Rank, Team } from "@xcpcio/core";
import { Submission } from "@xcpcio/core";
import { SubmissionStatusToSimpleString } from "@xcpcio/types";
const props = defineProps<{
rank: Rank,
}>();
interface Item {
submission: Submission,
team: Team,
problem: Problem,
displayName: string,
}
const rank = computed(() => props.rank);
const submissions = computed(() => {
const ss = rank.value.getSubmissions().sort(Submission.compare).reverse();
const res: Item[] = [];
let cnt = 0;
const need = 16;
for (let i = 0; i < ss.length && cnt < need; i++) {
const s = ss[i];
const teamId = s.teamId;
const problemId = s.problemId;
const team = rank.value.teamsMap.get(teamId);
if (!team) {
continue;
}
const problem = rank.value.contest.problemsMap.get(problemId);
if (!problem) {
continue;
}
let displayName = team.name;
if (team.organization) {
displayName = `${team.organization} - ${displayName}`;
}
res.push({
submission: s,
team,
problem,
displayName,
});
++cnt;
}
return res.reverse();
});
</script>

<template>
<div
absolute fixed z-99
bottom-4 left-4
opacity-90
>
<div
flex flex-col
>
<div>
<template
v-for="s in submissions"
:key="s.id"
>
<div
w-104
h-6
bg-slate-800 text-gray-200
font-mono
flex flex-row
pl-2
>
<div
w-8
>
{{ s.team.rank }}
</div>

<div
pl-2
w-80
truncate
>
{{ s.displayName }}
</div>

<div
w-5
>
{{ s.team.solvedProblemNum }}
</div>

<div
w-8
border-b-4
flex justify-center
:style="{
'border-color': s.problem.balloonColor?.background_color.toString(),
}"
>
{{ s.problem.label }}
</div>
<div
w-10
flex justify-center
:class="[s.submission.status]"
opacity-100
>
{{ SubmissionStatusToSimpleString[s.submission.status] }}
</div>
</div>
</template>
</div>
</div>
</div>
</template>
<style scoped lang="less">
@import "../../styles/submission-status-background.css";
</style>
123 changes: 123 additions & 0 deletions packages/apps/board/src/styles/submission-status-background.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
.PENDING {
background-color: var(--theme-status-pending);
}

.WAITING {
background-color: var(--theme-status-waiting);
}

.PREPARING {
background-color: var(--theme-status-preparing);
}

.COMPILING {
background-color: var(--theme-status-compiling);
}

.RUNNING {
background-color: var(--theme-status-running);
}

.JUDGING {
background-color: var(--theme-status-running);
}

.FROZEN {
background-color: var(--theme-status-pending);
}


.ACCEPTED {
background-color: var(--theme-status-accepted);
}

.CORRECT {
background-color: var(--theme-status-accepted);
}

.PARTIALLY_CORRECT {
background-color: var(--theme-status-partially-correct);
}


.REJECTED {
background-color: var(--theme-status-wrong-answer);
}

.WRONG_ANSWER {
background-color: var(--theme-status-wrong-answer);
}


.COMPILATION_ERROR {
background-color: var(--theme-status-compilation-error);
}

.PRESENTATION_ERROR {
background-color: var(--theme-status-compilation-error);
}


.RUNTIME_ERROR {
background-color: var(--theme-status-runtime-error);
}

.TIME_LIMIT_EXCEEDED {
background-color: var(--theme-status-time-limit-exceeded);
}

.MEMORY_LIMIT_EXCEEDED {
background-color: var(--theme-status-memory-limit-exceeded);
}

.OUTPUT_LIMIT_EXCEEDED {
background-color: var(--theme-status-output-limit-exceeded);
}

.IDLENESS_LIMIT_EXCEEDED {
background-color: var(--theme-status-output-limit-exceeded);
}

.HACKED {
background-color: var(--theme-status-wrong-answer);
}

.JUDGEMENT_FAILED {
background-color: var(--theme-status-judgement-failed);
}

.CONFIGURATION_ERROR {
background-color: var(--theme-status-configuration-error);
}

.FILE_ERROR {
background-color: var(--theme-status-file-error);
}

.SYSTEM_ERROR {
background-color: var(--theme-status-system-error);
}

.CANCELED {
background-color: var(--theme-status-canceled);
}

.SKIPPED {
background-color: var(--theme-status-skipped);
}

.SECURITY_VIOLATED {
background-color: var(--theme-status-judgement-failed);
}

.DENIAL_OF_JUDGEMENT {
background-color: var(--theme-status-judgement-failed);
}

.UNKNOWN {
background-color: var(--theme-status-unknown);
}

.UNDEFINED {
background-color: var(--theme-status-undefined);
}
41 changes: 41 additions & 0 deletions packages/libs/types/src/submission-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,44 @@ export const SubmissionStatusToString: { [key in SubmissionStatus]: string } = {
[SubmissionStatus.UNKNOWN]: "Unknown",
[SubmissionStatus.UNDEFINED]: "Undefined",
};

export const SubmissionStatusToSimpleString: { [key in SubmissionStatus]: string } = {
[SubmissionStatus.PENDING]: "PD",
[SubmissionStatus.WAITING]: "PD",
[SubmissionStatus.PREPARING]: "PD",
[SubmissionStatus.COMPILING]: "PD",
[SubmissionStatus.RUNNING]: "PD",
[SubmissionStatus.JUDGING]: "PD",
[SubmissionStatus.FROZEN]: "PD",

[SubmissionStatus.ACCEPTED]: "AC",
[SubmissionStatus.CORRECT]: "AC",
[SubmissionStatus.PARTIALLY_CORRECT]: "RJ",

[SubmissionStatus.REJECTED]: "RJ",
[SubmissionStatus.WRONG_ANSWER]: "WA",

[SubmissionStatus.COMPILATION_ERROR]: "CE",
[SubmissionStatus.PRESENTATION_ERROR]: "PE",

[SubmissionStatus.RUNTIME_ERROR]: "RE",
[SubmissionStatus.TIME_LIMIT_EXCEEDED]: "TL",
[SubmissionStatus.MEMORY_LIMIT_EXCEEDED]: "ML",
[SubmissionStatus.OUTPUT_LIMIT_EXCEEDED]: "OL",
[SubmissionStatus.IDLENESS_LIMIT_EXCEEDED]: "IL",

[SubmissionStatus.HACKED]: "RJ",

[SubmissionStatus.JUDGEMENT_FAILED]: "RJ",
[SubmissionStatus.CONFIGURATION_ERROR]: "RJ",
[SubmissionStatus.FILE_ERROR]: "RJ",
[SubmissionStatus.SYSTEM_ERROR]: "RJ",
[SubmissionStatus.CANCELED]: "RJ",
[SubmissionStatus.SKIPPED]: "RJ",

[SubmissionStatus.SECURITY_VIOLATED]: "RJ",
[SubmissionStatus.DENIAL_OF_JUDGEMENT]: "RJ",

[SubmissionStatus.UNKNOWN]: "RJ",
[SubmissionStatus.UNDEFINED]: "RJ",
};

0 comments on commit 97a9092

Please sign in to comment.