-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support contest problem recommender (#98)
- Loading branch information
Showing
10 changed files
with
2,153 additions
and
2,228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
releases: | ||
"@aoi-js/frontend": patch | ||
"@aoi-js/server": patch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
apps/frontend/src/components/contest/ContestProblemRecommender.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<template> | ||
<VDialog width="auto" max-width="640" min-width="640"> | ||
<template v-slot:activator="{ props }"> | ||
<VBtn | ||
color="info" | ||
prepend-icon="mdi-tag-arrow-right-outline" | ||
:text="t('action.recommend-problem')" | ||
v-bind="props" | ||
/> | ||
</template> | ||
|
||
<VCard :title="t('action.recommend-problem')"> | ||
<VCardText> | ||
<VTextField v-model="search" :label="t('term.search')" clearable /> | ||
<VCombobox v-model="tags" :label="t('term.tags')" multiple chips /> | ||
<VBtn | ||
block | ||
variant="flat" | ||
:text="t('action.recommend-problem')" | ||
@click="problems.execute()" | ||
/> | ||
</VCardText> | ||
<VDivider /> | ||
<VDataTable | ||
:headers="headers" | ||
:items="problems.state.value" | ||
:loading="problems.isLoading.value" | ||
item-value="_id" | ||
> | ||
<template v-slot:[`item.title`]="{ item }"> | ||
<div class="u-flex u-items-center u-gap-2"> | ||
<RouterLink :to="`/org/${orgId}/problem/${item._id}`" class="u-flex u-gap-2"> | ||
<div> | ||
<div> | ||
{{ item.title }} | ||
</div> | ||
<div class="u-text-xs text-secondary"> | ||
<code>{{ item.slug }}</code> | ||
</div> | ||
</div> | ||
</RouterLink> | ||
<ProblemStatus :org-id="orgId" :problem-id="item._id" :status="item.status" /> | ||
</div> | ||
</template> | ||
<template v-slot:[`item.accessLevel`]="{ item }"> | ||
<AccessLevelBadge variant="chip" :access-level="item.accessLevel" inline /> | ||
</template> | ||
<template v-slot:[`item.tags`]="{ item }"> | ||
<ProblemTagGroup :tags="item.tags" :url-prefix="`/org/${orgId}/problem/tag`" /> | ||
</template> | ||
<template v-slot:[`item.actions`]="{ item }"> | ||
<VBtn variant="tonal" @click="emit('update', item._id)" :text="t('action.select')" /> | ||
</template> | ||
</VDataTable> | ||
</VCard> | ||
</VDialog> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { useAsyncState } from '@vueuse/core' | ||
import { ref } from 'vue' | ||
import { useI18n } from 'vue-i18n' | ||
import ProblemStatus from '../problem/ProblemStatus.vue' | ||
import ProblemTagGroup from '../problem/ProblemTagGroup.vue' | ||
import type { IProblemDTO } from '../problem/types' | ||
import AccessLevelBadge from '../utils/AccessLevelBadge.vue' | ||
import { http } from '@/utils/http' | ||
const props = defineProps<{ | ||
orgId: string | ||
}>() | ||
const emit = defineEmits<{ | ||
(ev: 'update', value: string): void | ||
}>() | ||
const { t } = useI18n() | ||
const search = ref('') | ||
const tags = ref<string[]>([]) | ||
const headers = [ | ||
{ title: t('term.name'), key: 'title', sortable: false }, | ||
{ title: t('term.tags'), key: 'tags', sortable: false }, | ||
{ title: t('term.access-level'), key: 'accessLevel', align: 'end', sortable: false }, | ||
{ title: t('term.actions'), key: 'actions', align: 'end', sortable: false } | ||
] as const | ||
const problems = useAsyncState( | ||
async () => | ||
http | ||
.post('problem/recommend', { | ||
json: { | ||
orgId: props.orgId, | ||
search: search.value || undefined, | ||
tags: tags.value.length ? tags.value : undefined, | ||
sample: 10 | ||
} | ||
}) | ||
.json<IProblemDTO[]>(), | ||
[], | ||
{ immediate: false, resetOnExecute: false } | ||
) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.