Include complete API and frontend sources for unified deployment
This commit is contained in:
1 parent
627b0ae60e
commit
d8fcae32b0
93 files changed
+53270
-3
No files matched your search
@@ -0,0 +1,13 @@
|
||||
# editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
@@ -0,0 +1,20 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
env: {
|
||||
browser: true,
|
||||
node: true
|
||||
},
|
||||
parserOptions: {
|
||||
parser: '@babel/eslint-parser',
|
||||
requireConfigFile: false
|
||||
},
|
||||
extends: [
|
||||
'@nuxtjs',
|
||||
'plugin:nuxt/recommended',
|
||||
'prettier'
|
||||
],
|
||||
plugins: [
|
||||
],
|
||||
// add your custom rules here
|
||||
rules: {}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
# Created by .ignore support plugin (hsz.mobi)
|
||||
### Node template
|
||||
# Logs
|
||||
/logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# Nuxt generate
|
||||
dist
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless
|
||||
|
||||
# IDE / Editor
|
||||
.idea
|
||||
|
||||
# Service worker
|
||||
sw.*
|
||||
|
||||
# macOS
|
||||
.DS_Store
|
||||
|
||||
# Vim swap files
|
||||
*.swp
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"semi": false,
|
||||
"arrowParens": "avoid",
|
||||
"singleQuote": true,
|
||||
"trailingComma": "es5",
|
||||
"bracketSpacing": true,
|
||||
"endOfLine": "lf",
|
||||
"printWidth": 120,
|
||||
"useTabs": true,
|
||||
"tabWidth": 2
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
# CyberGarden
|
||||
|
||||
Nuxt 2 / Vue 2. API на Express + MySQL находится в соседнем проекте `hackathon-grading-system`.
|
||||
|
||||
```bash
|
||||
npm ci
|
||||
API_BASE_URL=http://localhost:3080 NODE_OPTIONS=--openssl-legacy-provider npm run dev
|
||||
# Статическая сборка за обратным прокси /api/
|
||||
API_BASE_URL=/api NODE_OPTIONS=--openssl-legacy-provider npm run generate
|
||||
```
|
||||
|
||||
Сборка воспроизводится на Node 18. `API_BASE_URL` задаётся при сборке.
|
||||
|
||||
## Страницы
|
||||
|
||||
- `/login` — логотип, логин, пароль и вход.
|
||||
- `/` — назначенные эксперту кейсы и команды, оценки 0–5.
|
||||
- `/admin` — список и создание кейсов.
|
||||
- `/admin/cases/:id` — изменение кейса, создание и изменение команд, два критерия организатора, список назначенных экспертов.
|
||||
- `/admin/users` — добавление экспертов, просмотр данных входа, назначение одного или нескольких кейсов.
|
||||
- `/admin/marks` — рейтинг, пропущенные и нулевые оценки. API использует функции из серверных `scripts/calc-positions.js` и `scripts/no-marks.js`.
|
||||
|
||||
Палитра и общие стили — `assets/css/app.css`. Каркас — `components/AppShell.vue`. Формы редактирования используют нативный `dialog`. Эксперт отправляет только свои критерии; отмена и ошибка сохранения сохраняют исходные данные.
|
||||
|
||||
## Проверки
|
||||
|
||||
```bash
|
||||
npx eslint pages components layouts nuxt.config.js --ext .js,.vue
|
||||
npx stylelint assets/css/app.css
|
||||
```
|
||||
|
||||
На странице «Эксперты» доступны редактирование ФИО, логина и пароля, удаление с подтверждением, восстановление на вкладке «Удалённые». Оценки при удалении сохраняются. Пустое поле нового пароля оставляет прежний пароль.
|
||||
|
||||
Кнопка «QR-коды PDF» скачивает один PDF со всеми активными экспертами, независимо от поиска: A4, 12 карточек на страницу (3 × 4), QR-код и ФИО. В диалоге задаётся адрес приложения, доступный экспертам с телефона. Ссылка открывает форму входа с заполненными логином и паролем.
|
||||
|
||||
Иконки кейсов загружаются в формах создания и изменения: PNG до 256 КБ и 1024 × 1024 пикселей, с предварительным просмотром и удалением. В «Результатах» вкладка «Все оценки» показывает все критерии для каждой пары команда — эксперт, с фильтром по кейсу. Критерии технических экспертов помечены «(тех.)».
|
||||
|
||||
У экспертов бокового меню нет. Меню администратора скрывается кнопкой «Меню»; выбор сохраняется на компьютере. На мобильных экранах меню открывается поверх страницы и закрывается после перехода. Dev-сервер слушает `0.0.0.0`; в Docker используется порт 3081 на всех интерфейсах, API — относительный `/api/`.
|
||||
|
||||
Для QR-кодов адрес по умолчанию — `https://cg.vkhost.ru/`, независимо от адреса, через который открыт кабинет администратора.
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,52 @@
|
||||
<template>
|
||||
<svg
|
||||
:width="size"
|
||||
:height="size"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.65"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path v-for="(path, index) in paths" :key="index" :d="path" />
|
||||
</svg>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const icons = {
|
||||
leaf: ['M12 21V11', 'M12 16C4 16 3 11 3 7c6 0 9 2 9 7', 'M12 11c0-6 3-8 9-8 0 6-3 9-9 9'],
|
||||
grid: ['M3 3h7v7H3z', 'M14 3h7v7h-7z', 'M3 14h7v7H3z', 'M14 14h7v7h-7z'],
|
||||
users: [
|
||||
'M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2',
|
||||
'M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8',
|
||||
'M17 4a4 4 0 0 1 0 8',
|
||||
'M22 21v-2a4 4 0 0 0-3-3.87',
|
||||
],
|
||||
chart: ['M4 20h16', 'M7 16v-5', 'M12 16V4', 'M17 16V8'],
|
||||
arrow: ['M5 12h14', 'm13 6 6 6-6 6'],
|
||||
back: ['M19 12H5', 'm11 6-6 6 6 6'],
|
||||
check: ['m5 12 4 4L19 6'],
|
||||
search: ['M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16', 'm17 17 4 4'],
|
||||
logout: ['M9 21H4V3h5', 'M10 12h11', 'm17 8 4 4-4 4'],
|
||||
close: ['m6 6 12 12', 'M6 18 18 6'],
|
||||
plus: ['M12 5v14', 'M5 12h14'],
|
||||
lock: ['M5 11h14v10H5z', 'M8 11V7a4 4 0 0 1 8 0v4'],
|
||||
info: ['M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20', 'M12 11v6', 'M12 7h.01'],
|
||||
clock: ['M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20', 'M12 6v6l4 2'],
|
||||
file: ['M14 2H4v20h16V8z', 'M14 2v6h6', 'M8 13h8', 'M8 17h5'],
|
||||
eye: ['M2 12s3-7 10-7 10 7 10 7-3 7-10 7S2 12 2 12', 'M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6'],
|
||||
copy: ['M8 8h13v13H8z', 'M16 4V2H2v14h2'],
|
||||
award: ['M12 15a6 6 0 1 0 0-12 6 6 0 0 0 0 12', 'm8 14-1 8 5-3 5 3-1-8'],
|
||||
menu: ['M4 6h16', 'M4 12h16', 'M4 18h16'],
|
||||
}
|
||||
export default {
|
||||
props: { name: { type: String, default: 'grid' }, size: { type: [Number, String], default: 20 } },
|
||||
computed: {
|
||||
paths() {
|
||||
return icons[this.name] || icons.grid
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,105 @@
|
||||
<template>
|
||||
<div class="app-shell simple-shell" :class="{ 'menu-open': isAdmin && menuOpen }">
|
||||
<a class="skip-link" href="#main-content" @click.prevent="focusMain">Перейти к содержимому</a>
|
||||
<button
|
||||
v-if="isAdmin && menuOpen"
|
||||
class="menu-backdrop"
|
||||
type="button"
|
||||
aria-label="Закрыть меню"
|
||||
@click="toggleMenu"
|
||||
/>
|
||||
<aside v-if="isAdmin && menuOpen" id="admin-sidebar" class="sidebar">
|
||||
<div class="sidebar-heading">
|
||||
<NuxtLink to="/admin" class="brand" aria-label="CyberGarden — главная"
|
||||
><img src="/logo2026.png" alt="" width="32" height="30" /><strong>CyberGarden</strong></NuxtLink
|
||||
>
|
||||
</div>
|
||||
<nav class="main-nav" aria-label="Основная навигация">
|
||||
<NuxtLink
|
||||
v-for="item in navigation"
|
||||
:key="item.to"
|
||||
:to="item.to"
|
||||
:exact="item.to !== '/admin'"
|
||||
class="nav-item"
|
||||
:class="{ 'current-nav': item.to === '/admin' && $route.path.startsWith('/admin/cases') }"
|
||||
@click.native="closeOnMobile"
|
||||
><AppIcon :name="item.icon" :size="18" /><span>{{ item.label }}</span></NuxtLink
|
||||
>
|
||||
</nav>
|
||||
</aside>
|
||||
<div class="workspace">
|
||||
<header class="workspace-header">
|
||||
<button
|
||||
v-if="isAdmin"
|
||||
class="button menu-toggle"
|
||||
type="button"
|
||||
:aria-expanded="String(menuOpen)"
|
||||
aria-controls="admin-sidebar"
|
||||
:aria-label="menuOpen ? 'Скрыть меню' : 'Показать меню'"
|
||||
@click="toggleMenu"
|
||||
>
|
||||
<AppIcon name="menu" :size="18" /></button
|
||||
><NuxtLink v-else to="/" class="compact-brand" aria-label="CyberGarden — кейсы"
|
||||
><img src="/logo2026.png" width="36" height="34" alt="" /><strong>CyberGarden</strong></NuxtLink
|
||||
>
|
||||
<div class="header-profile">
|
||||
<span>{{ fullName }}</span
|
||||
><button class="icon-button" type="button" aria-label="Выйти" @click="exit">
|
||||
<AppIcon name="logout" :size="18" />
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
<main id="main-content" class="main-content" tabindex="-1"><Nuxt /></main>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return { menuOpen: false }
|
||||
},
|
||||
computed: {
|
||||
isAdmin() {
|
||||
return this.$route.path.startsWith('/admin') || this.$auth.user?.login === 'admin'
|
||||
},
|
||||
fullName() {
|
||||
const user = this.$auth.user || {}
|
||||
return (
|
||||
[
|
||||
user.firstName || localStorage.getItem('user.firstName'),
|
||||
user.lastName || localStorage.getItem('user.lastName'),
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ') || (this.isAdmin ? 'Администратор' : 'Эксперт')
|
||||
)
|
||||
},
|
||||
navigation() {
|
||||
return [
|
||||
{ to: '/admin', icon: 'file', label: 'Кейсы' },
|
||||
{ to: '/admin/users', icon: 'users', label: 'Эксперты' },
|
||||
{ to: '/admin/marks', icon: 'chart', label: 'Результаты' },
|
||||
]
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.menuOpen = window.innerWidth > 800 && localStorage.getItem('admin.menuOpen') !== 'false'
|
||||
},
|
||||
methods: {
|
||||
toggleMenu() {
|
||||
this.menuOpen = !this.menuOpen
|
||||
if (window.innerWidth > 800) localStorage.setItem('admin.menuOpen', String(this.menuOpen))
|
||||
},
|
||||
closeOnMobile() {
|
||||
if (window.innerWidth <= 800) this.menuOpen = false
|
||||
},
|
||||
focusMain() {
|
||||
const main = this.$el.querySelector('#main-content')
|
||||
main.focus()
|
||||
main.scrollIntoView({ block: 'start' })
|
||||
},
|
||||
async exit() {
|
||||
await this.$auth.logout()
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,6 @@
|
||||
<template>
|
||||
<span class="case-picture"><img v-if="src" :src="src" alt="" /><AppIcon v-else name="file" :size="22" /></span>
|
||||
</template>
|
||||
<script>
|
||||
export default { props: { src: { type: String, default: null } } }
|
||||
</script>
|
||||
@@ -0,0 +1,65 @@
|
||||
<template>
|
||||
<div class="icon-upload field">
|
||||
<label :for="inputId"><span>Иконка кейса (PNG)</span></label>
|
||||
<div class="icon-upload-controls">
|
||||
<CaseIcon :src="value" /><input
|
||||
:id="inputId"
|
||||
ref="file"
|
||||
type="file"
|
||||
accept="image/png,.png"
|
||||
:disabled="disabled"
|
||||
@change="select"
|
||||
/><button v-if="value || error" class="button button-sm" type="button" :disabled="disabled" @click="remove">
|
||||
Убрать
|
||||
</button>
|
||||
</div>
|
||||
<p class="muted">До 1 МБ, не более 1024 × 1024 пикселей.</p>
|
||||
<div v-if="error" class="form-error" role="alert">{{ error }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
props: { value: { type: String, default: null }, disabled: Boolean },
|
||||
data() {
|
||||
return { error: '', inputId: 'case-icon-file' }
|
||||
},
|
||||
methods: {
|
||||
select(event) {
|
||||
this.error = ''
|
||||
event.target.setCustomValidity('')
|
||||
const file = event.target.files[0]
|
||||
if (!file) return
|
||||
if (file.type !== 'image/png' || file.size > 1024 * 1024) {
|
||||
this.fail('Выберите PNG-файл размером до 1 МБ.')
|
||||
return
|
||||
}
|
||||
event.target.setCustomValidity('Дождитесь загрузки иконки.')
|
||||
const reader = new FileReader()
|
||||
reader.onerror = () => this.fail('Не удалось прочитать файл.')
|
||||
reader.onload = () => {
|
||||
const image = new Image()
|
||||
image.onload = () => {
|
||||
if (image.width > 1024 || image.height > 1024) this.fail('Размер иконки — не более 1024 × 1024 пикселей.')
|
||||
else {
|
||||
event.target.setCustomValidity('')
|
||||
this.$emit('input', reader.result)
|
||||
}
|
||||
}
|
||||
image.onerror = () => this.fail('Не удалось прочитать PNG-файл.')
|
||||
image.src = reader.result
|
||||
}
|
||||
reader.readAsDataURL(file)
|
||||
},
|
||||
fail(message) {
|
||||
this.error = message
|
||||
this.$refs.file.setCustomValidity(message)
|
||||
},
|
||||
remove() {
|
||||
this.$emit('input', null)
|
||||
this.error = ''
|
||||
this.$refs.file.value = ''
|
||||
this.$refs.file.setCustomValidity('')
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,40 @@
|
||||
<template>
|
||||
<dialog ref="dialog" class="score-dialog form-dialog" aria-labelledby="form-dialog-title" @cancel.prevent="close">
|
||||
<form @submit.prevent="$emit('save')">
|
||||
<div class="dialog-header">
|
||||
<h2 id="form-dialog-title">{{ title }}</h2>
|
||||
<button class="icon-button" type="button" aria-label="Закрыть" :disabled="busy" @click="close">
|
||||
<AppIcon name="close" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="dialog-body"><slot /></div>
|
||||
<div class="dialog-footer dialog-footer-actions">
|
||||
<button class="button" type="button" :disabled="busy" @click="close">Отмена</button
|
||||
><button class="button button-primary" :class="{ 'button-danger': danger }" type="submit" :disabled="busy">
|
||||
{{ busy ? 'Сохраняем…' : submitLabel }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</dialog>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
title: { type: String, required: true },
|
||||
busy: Boolean,
|
||||
danger: Boolean,
|
||||
submitLabel: { type: String, default: 'Сохранить' },
|
||||
},
|
||||
mounted() {
|
||||
this.$refs.dialog.showModal()
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$refs.dialog.close()
|
||||
},
|
||||
methods: {
|
||||
close() {
|
||||
if (!this.busy) this.$emit('close')
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,47 @@
|
||||
<template>
|
||||
<th scope="col" :aria-sort="active ? (direction === 'asc' ? 'ascending' : 'descending') : 'none'">
|
||||
<button class="sort-header" type="button" @click="$emit('sort')">
|
||||
<span><slot /></span>
|
||||
<span class="sort-indicator" :class="{ active }" aria-hidden="true">{{
|
||||
active ? (direction === 'asc' ? '↑' : '↓') : '↕'
|
||||
}}</span>
|
||||
</button>
|
||||
</th>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
active: { type: Boolean, default: false },
|
||||
direction: { type: String, default: 'asc' },
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.sort-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
.sort-header:hover,
|
||||
.sort-header:focus-visible {
|
||||
color: var(--primary, #28634c);
|
||||
}
|
||||
.sort-indicator {
|
||||
flex-shrink: 0;
|
||||
opacity: 0.45;
|
||||
}
|
||||
.sort-indicator.active {
|
||||
opacity: 1;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<AppShell />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default { name: 'Default', middleware: 'auth' }
|
||||
</script>
|
||||
@@ -0,0 +1,3 @@
|
||||
<template>
|
||||
<Nuxt />
|
||||
</template>
|
||||
@@ -0,0 +1,4 @@
|
||||
export default function ({ $auth, redirect }) {
|
||||
if (!$auth.loggedIn) return redirect('/login')
|
||||
if ($auth.user?.login === 'admin') return redirect('/admin')
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
export default {
|
||||
// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
|
||||
ssr: false,
|
||||
server: { host: '0.0.0.0' },
|
||||
|
||||
// Target: https://go.nuxtjs.dev/config-target
|
||||
target: 'static',
|
||||
|
||||
// Global page headers: https://go.nuxtjs.dev/config-head
|
||||
head: {
|
||||
title: 'Система оценки',
|
||||
meta: [
|
||||
{ charset: 'utf-8' },
|
||||
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
|
||||
{
|
||||
hid: 'description',
|
||||
name: 'description',
|
||||
content: 'Пространство оценки проектов и команд хакатона CyberGarden',
|
||||
},
|
||||
{ name: 'format-detection', content: 'telephone=no' },
|
||||
],
|
||||
link: [{ rel: 'icon', type: 'image/png', href: '/icon.png' }],
|
||||
},
|
||||
|
||||
// Global CSS: https://go.nuxtjs.dev/config-css
|
||||
css: ['~/assets/css/app.css'],
|
||||
|
||||
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
|
||||
plugins: [],
|
||||
|
||||
// Auto import components: https://go.nuxtjs.dev/config-components
|
||||
components: true,
|
||||
|
||||
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
|
||||
buildModules: [
|
||||
// https://go.nuxtjs.dev/eslint
|
||||
'@nuxtjs/eslint-module',
|
||||
// https://go.nuxtjs.dev/stylelint
|
||||
'@nuxtjs/stylelint-module',
|
||||
// https://go.nuxtjs.dev/tailwindcss
|
||||
'@nuxtjs/tailwindcss',
|
||||
// https://go.nuxtjs.dev/pwa
|
||||
'@nuxtjs/pwa',
|
||||
],
|
||||
|
||||
// Modules: https://go.nuxtjs.dev/config-modules
|
||||
modules: [
|
||||
// https://go.nuxtjs.dev/axios
|
||||
'@nuxtjs/axios',
|
||||
'@nuxtjs/auth-next',
|
||||
'nuxt-vue-material',
|
||||
],
|
||||
|
||||
// Axios module configuration: https://go.nuxtjs.dev/config-axios
|
||||
axios: {
|
||||
baseURL: process.env.API_BASE_URL || 'https://api.cybergarden.ru',
|
||||
},
|
||||
|
||||
vueMaterial: {},
|
||||
|
||||
router: {
|
||||
mode: 'hash',
|
||||
},
|
||||
|
||||
auth: {
|
||||
rewriteRedirect: false,
|
||||
resetOnError: true,
|
||||
redirect: {
|
||||
login: '/login',
|
||||
logout: '/login',
|
||||
home: false,
|
||||
},
|
||||
strategies: {
|
||||
local: {
|
||||
token: {
|
||||
property: 'token',
|
||||
maxAge: false,
|
||||
},
|
||||
user: {
|
||||
property: 'user',
|
||||
autoFetch: true,
|
||||
},
|
||||
endpoints: {
|
||||
login: { url: '/auth/login', method: 'post' },
|
||||
logout: { url: '/auth/logout', method: 'post' },
|
||||
user: { url: '/auth/user', method: 'get' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// PWA module configuration: https://go.nuxtjs.dev/pwa
|
||||
pwa: {
|
||||
manifest: {
|
||||
name: 'CyberGarden',
|
||||
start_url: '/',
|
||||
lang: 'ru',
|
||||
},
|
||||
},
|
||||
|
||||
// Build Configuration: https://go.nuxtjs.dev/config-build
|
||||
build: {},
|
||||
}
|
||||
+38323
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "hackathon-grading-system-front",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "nuxt",
|
||||
"build": "nuxt build",
|
||||
"start": "nuxt start",
|
||||
"generate": "nuxt generate",
|
||||
"lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
|
||||
"lint:style": "stylelint \"**/*.{vue,css}\" --ignore-path .gitignore",
|
||||
"lint": "npm run lint:js && npm run lint:style"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nuxtjs/auth-next": "5.0.0-1637745161.ea53f98",
|
||||
"@nuxtjs/axios": "^5.13.6",
|
||||
"@nuxtjs/pwa": "^3.3.5",
|
||||
"core-js": "^3.15.1",
|
||||
"nuxt": "^2.15.7",
|
||||
"nuxt-vue-material": "^1.2.0",
|
||||
"sass": "^1.44.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/eslint-parser": "^7.14.7",
|
||||
"@nuxt/types": "~2.15.0",
|
||||
"@nuxtjs/eslint-config": "^6.0.1",
|
||||
"@nuxtjs/eslint-module": "^3.0.2",
|
||||
"@nuxtjs/stylelint-module": "^4.0.0",
|
||||
"@nuxtjs/tailwindcss": "^4.2.0",
|
||||
"eslint": "^7.29.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-nuxt": "^2.0.0",
|
||||
"eslint-plugin-vue": "^7.12.1",
|
||||
"postcss": "^8.3.5",
|
||||
"prettier": "^2.3.2",
|
||||
"stylelint": "^13.13.1",
|
||||
"stylelint-config-prettier": "^8.0.2",
|
||||
"stylelint-config-standard": "^22.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,369 @@
|
||||
<template>
|
||||
<div>
|
||||
<NuxtLink to="/admin" class="back-link"><AppIcon name="back" :size="15" /> Кейсы</NuxtLink>
|
||||
<div class="page-heading">
|
||||
<div class="case-title">
|
||||
<CaseIcon :src="task.icon" />
|
||||
<h1>{{ task.name }}</h1>
|
||||
</div>
|
||||
<button class="button" type="button" @click="editCase">Изменить</button>
|
||||
</div>
|
||||
<p v-if="task.description" class="plain-description">{{ task.description }}</p>
|
||||
<div class="section-heading">
|
||||
<h2>Команды</h2>
|
||||
<button class="button button-primary" type="button" @click="editTeam()">
|
||||
<AppIcon name="plus" :size="16" /> Добавить команду
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="scoreError" class="form-error" role="alert">{{ scoreError }}</div>
|
||||
<div class="panel">
|
||||
<div class="table-scroll">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<SortHeader
|
||||
v-for="column in teamColumns"
|
||||
:key="column.key"
|
||||
:active="teamSortKey === column.key"
|
||||
:direction="teamSortDirection"
|
||||
@sort="sortTeamsBy(column.key)"
|
||||
>{{ column.name }}</SortHeader
|
||||
>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="team in sortedTeams" :key="team.id">
|
||||
<td>
|
||||
<strong>{{ team.name }}</strong>
|
||||
<p v-if="team.description" class="table-description">{{ team.description }}</p>
|
||||
<p
|
||||
v-if="team.TeamInCase && team.TeamInCase.technicalComment"
|
||||
class="table-description technical-comment-text"
|
||||
>
|
||||
Комментарий тех. эксперта: {{ team.TeamInCase.technicalComment }}
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
class="score-input"
|
||||
type="number"
|
||||
min="0"
|
||||
max="5"
|
||||
step="1"
|
||||
:value="implementation[team.id]"
|
||||
:aria-label="'Качество реализации — ' + team.name"
|
||||
:disabled="savingScores"
|
||||
@input="setScore(implementation, team.id, $event)"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
class="score-input"
|
||||
type="number"
|
||||
min="0"
|
||||
max="5"
|
||||
step="1"
|
||||
:value="work[team.id]"
|
||||
:aria-label="'Работа на хакатоне — ' + team.name"
|
||||
:disabled="savingScores"
|
||||
@input="setScore(work, team.id, $event)"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<button
|
||||
class="button button-sm"
|
||||
type="button"
|
||||
:aria-label="'Изменить команду ' + team.name"
|
||||
@click="editTeam(team)"
|
||||
>
|
||||
Изменить
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!task.teams.length">
|
||||
<td colspan="4" class="table-empty">Команд пока нет.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="task.teams.length" class="save-row">
|
||||
<span class="muted">{{
|
||||
task.users.length ? 'Оценки тех. экспертов · 0–5' : 'Сначала назначьте экспертов в разделе «Эксперты».'
|
||||
}}</span
|
||||
><button
|
||||
class="button button-primary"
|
||||
type="button"
|
||||
:disabled="savingScores || !task.users.length"
|
||||
@click="saveScores"
|
||||
>
|
||||
{{ savingScores ? 'Сохраняем…' : 'Сохранить оценки' }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="section-heading" style="margin-top: 32px">
|
||||
<h2>Эксперты</h2>
|
||||
<div ref="assignmentPicker" class="assignment-picker" @keydown.esc.prevent.stop="closeAssignments">
|
||||
<button
|
||||
ref="assignmentButton"
|
||||
type="button"
|
||||
class="button button-sm"
|
||||
:aria-expanded="String(assignmentOpen)"
|
||||
aria-controls="case-expert-picker"
|
||||
:disabled="savingAssignments"
|
||||
@click="toggleAssignments"
|
||||
>
|
||||
Назначить
|
||||
</button>
|
||||
<div v-if="assignmentOpen" id="case-expert-picker" class="assignment-dropdown">
|
||||
<input
|
||||
v-model="expertSearch"
|
||||
class="text-input"
|
||||
type="search"
|
||||
aria-label="Найти эксперта"
|
||||
placeholder="Найти эксперта"
|
||||
/>
|
||||
<p v-if="loadingAssignments" class="muted">Загрузка…</p>
|
||||
<div v-else class="assignment-options">
|
||||
<label v-for="user in filteredAssignmentUsers" :key="user.id" class="checkbox-row">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="isAssigned(user)"
|
||||
:disabled="savingAssignments"
|
||||
@change="setAssignment(user, $event)"
|
||||
/>
|
||||
<span
|
||||
>{{ [user.lastName, user.firstName, user.middleName].filter(Boolean).join(' ')
|
||||
}}{{ user.role === 'technical' ? ' · Технический эксперт' : '' }}</span
|
||||
>
|
||||
</label>
|
||||
<p v-if="!filteredAssignmentUsers.length" class="muted">Эксперты не найдены.</p>
|
||||
</div>
|
||||
<div v-if="assignmentError" class="form-error" role="alert">{{ assignmentError }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel">
|
||||
<div v-for="user in task.users" :key="user.id" class="simple-row">
|
||||
<span>{{ [user.lastName, user.firstName, user.middleName].filter(Boolean).join(' ') }}</span>
|
||||
<span v-if="user.role === 'technical'" class="badge">Технический эксперт</span>
|
||||
</div>
|
||||
<div v-if="!task.users.length" class="table-empty">Эксперты не назначены.</div>
|
||||
</div>
|
||||
<FormDialog
|
||||
v-if="editor"
|
||||
:title="editor === 'case' ? 'Изменить кейс' : teamId ? 'Изменить команду' : 'Новая команда'"
|
||||
:busy="saving"
|
||||
@close="editor = null"
|
||||
@save="save"
|
||||
><label class="field" for="entityName"
|
||||
><span>Название</span
|
||||
><input id="entityName" v-model.trim="name" class="text-input" maxlength="255" required /></label
|
||||
><label class="field" for="entityDescription"
|
||||
><span>Описание</span
|
||||
><textarea id="entityDescription" v-model.trim="description" class="text-input" maxlength="10000" rows="3" />
|
||||
</label>
|
||||
<CaseIconUpload v-if="editor === 'case'" v-model="icon" :disabled="saving" />
|
||||
<div v-if="error" class="form-error" role="alert">{{ error }}</div></FormDialog
|
||||
>
|
||||
<div v-if="message" class="toast" role="status">{{ message }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: 'CaseDetails',
|
||||
async asyncData({ $axios, params, error }) {
|
||||
const [{ cases }, { marks }] = await Promise.all([$axios.$get('/admin/cases'), $axios.$get('/admin')])
|
||||
const task = cases.find(c => c.id === params.id)
|
||||
if (!task) {
|
||||
error({ statusCode: 404, message: 'Кейс не найден' })
|
||||
return {}
|
||||
}
|
||||
return { task, implementation: marks.implementation, work: marks.work }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
task: { name: '', teams: [], users: [] },
|
||||
implementation: {},
|
||||
work: {},
|
||||
editor: null,
|
||||
teamId: null,
|
||||
name: '',
|
||||
description: '',
|
||||
icon: null,
|
||||
saving: false,
|
||||
error: '',
|
||||
savingScores: false,
|
||||
scoreError: '',
|
||||
message: '',
|
||||
timer: null,
|
||||
assignmentOpen: false,
|
||||
assignmentUsers: [],
|
||||
expertSearch: '',
|
||||
loadingAssignments: false,
|
||||
savingAssignments: false,
|
||||
assignmentError: '',
|
||||
teamSortKey: 'name',
|
||||
teamSortDirection: 'asc',
|
||||
teamColumns: [
|
||||
{ key: 'name', name: 'Команда' },
|
||||
{ key: 'implementation', name: 'Качество реализации (тех.)' },
|
||||
{ key: 'work', name: 'Работа на хакатоне (тех.)' },
|
||||
],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
sortedTeams() {
|
||||
const direction = this.teamSortDirection === 'asc' ? 1 : -1
|
||||
return [...this.task.teams].sort((a, b) => {
|
||||
const nameOrder = a.name.localeCompare(b.name, 'ru', { numeric: true, sensitivity: 'base' })
|
||||
if (this.teamSortKey === 'name') return direction * nameOrder
|
||||
const left = this[this.teamSortKey][a.id]
|
||||
const right = this[this.teamSortKey][b.id]
|
||||
const leftMissing = left === null || left === undefined || left === ''
|
||||
const rightMissing = right === null || right === undefined || right === ''
|
||||
if (leftMissing || rightMissing) return leftMissing === rightMissing ? nameOrder : leftMissing ? 1 : -1
|
||||
return direction * (Number(left) - Number(right)) || nameOrder
|
||||
})
|
||||
},
|
||||
filteredAssignmentUsers() {
|
||||
const search = this.expertSearch.trim().toLowerCase()
|
||||
return this.assignmentUsers.filter(user =>
|
||||
[user.lastName, user.firstName, user.middleName].filter(Boolean).join(' ').toLowerCase().includes(search)
|
||||
)
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
document.addEventListener('click', this.assignmentOutsideClick)
|
||||
},
|
||||
beforeDestroy() {
|
||||
clearTimeout(this.timer)
|
||||
document.removeEventListener('click', this.assignmentOutsideClick)
|
||||
},
|
||||
methods: {
|
||||
sortTeamsBy(key) {
|
||||
this.teamSortDirection = this.teamSortKey === key && this.teamSortDirection === 'asc' ? 'desc' : 'asc'
|
||||
this.teamSortKey = key
|
||||
},
|
||||
isAssigned(user) {
|
||||
return user.cases.some(task => task.id === this.task.id)
|
||||
},
|
||||
closeAssignments() {
|
||||
if (this.savingAssignments) return
|
||||
this.assignmentOpen = false
|
||||
this.$refs.assignmentButton?.focus()
|
||||
},
|
||||
assignmentOutsideClick(event) {
|
||||
if (!this.savingAssignments && !this.$refs.assignmentPicker?.contains(event.target)) this.assignmentOpen = false
|
||||
},
|
||||
async toggleAssignments() {
|
||||
this.assignmentOpen = !this.assignmentOpen
|
||||
if (!this.assignmentOpen) return
|
||||
this.expertSearch = ''
|
||||
this.assignmentError = ''
|
||||
this.loadingAssignments = true
|
||||
try {
|
||||
const { users } = await this.$axios.$get('/admin/users')
|
||||
this.assignmentUsers = users.filter(user => !user.deletedAt)
|
||||
} catch (e) {
|
||||
this.assignmentUsers = []
|
||||
this.assignmentError = 'Не удалось загрузить экспертов.'
|
||||
} finally {
|
||||
this.loadingAssignments = false
|
||||
}
|
||||
},
|
||||
async setAssignment(user, event) {
|
||||
if (this.savingAssignments) return
|
||||
const checked = event.target.checked
|
||||
const caseIds = user.cases.filter(task => task.id !== this.task.id).map(task => task.id)
|
||||
if (checked) caseIds.push(this.task.id)
|
||||
this.savingAssignments = true
|
||||
this.assignmentError = ''
|
||||
try {
|
||||
await this.$axios.$put('/admin/users/' + user.id + '/cases', { caseIds })
|
||||
user.cases = user.cases.filter(task => task.id !== this.task.id)
|
||||
this.task.users = this.task.users.filter(expert => expert.id !== user.id)
|
||||
if (checked) {
|
||||
user.cases.push({ id: this.task.id, name: this.task.name })
|
||||
const { id, firstName, lastName, middleName, login, role } = user
|
||||
this.task.users.push({ id, firstName, lastName, middleName, login, role })
|
||||
}
|
||||
} catch (e) {
|
||||
event.target.checked = this.isAssigned(user)
|
||||
this.assignmentError = e.response?.data?.message || 'Не удалось сохранить назначение. Попробуйте ещё раз.'
|
||||
} finally {
|
||||
this.savingAssignments = false
|
||||
}
|
||||
},
|
||||
async reload() {
|
||||
const { cases } = await this.$axios.$get('/admin/cases')
|
||||
this.task = cases.find(c => c.id === this.$route.params.id)
|
||||
},
|
||||
editCase() {
|
||||
this.editor = 'case'
|
||||
this.name = this.task.name
|
||||
this.description = this.task.description
|
||||
this.icon = this.task.icon || null
|
||||
this.error = ''
|
||||
},
|
||||
editTeam(team) {
|
||||
this.editor = 'team'
|
||||
this.teamId = team?.id || null
|
||||
this.name = team?.name || ''
|
||||
this.description = team?.description || ''
|
||||
this.error = ''
|
||||
},
|
||||
async save() {
|
||||
if (this.saving || !this.name) return
|
||||
this.saving = true
|
||||
this.error = ''
|
||||
try {
|
||||
const body = { name: this.name, description: this.description || '' }
|
||||
const base = '/admin/cases/' + this.task.id
|
||||
if (this.editor === 'case') await this.$axios.$put(base, { ...body, icon: this.icon })
|
||||
else if (this.teamId) await this.$axios.$put(base + '/teams/' + this.teamId, body)
|
||||
else await this.$axios.$post(base + '/teams', body)
|
||||
await this.reload()
|
||||
this.editor = null
|
||||
} catch (e) {
|
||||
this.error = 'Не удалось сохранить изменения.'
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
},
|
||||
setScore(target, id, event) {
|
||||
const value =
|
||||
event.target.value === '' ? '' : Math.min(5, Math.max(0, Math.round(Number(event.target.value) || 0)))
|
||||
this.$set(target, id, value)
|
||||
event.target.value = value
|
||||
},
|
||||
async saveScores() {
|
||||
if (this.savingScores) return
|
||||
this.scoreError = ''
|
||||
const values = this.task.teams.map(team => ({
|
||||
id: team.id,
|
||||
implementation: this.implementation[team.id],
|
||||
work: this.work[team.id],
|
||||
}))
|
||||
const filled = value => value !== '' && value !== undefined && value !== null
|
||||
if (values.some(m => filled(m.implementation) !== filled(m.work))) {
|
||||
this.scoreError = 'Заполните оба критерия для команды.'
|
||||
return
|
||||
}
|
||||
this.savingScores = true
|
||||
try {
|
||||
await this.$axios.$post('/admin', { marks: values.filter(m => filled(m.implementation) && filled(m.work)) })
|
||||
this.message = 'Оценки сохранены'
|
||||
clearTimeout(this.timer)
|
||||
this.timer = setTimeout(() => {
|
||||
this.message = ''
|
||||
}, 3500)
|
||||
} catch (e) {
|
||||
this.scoreError = 'Не удалось сохранить оценки.'
|
||||
} finally {
|
||||
this.savingScores = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,73 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="page-heading">
|
||||
<h1>Кейсы</h1>
|
||||
<button class="button button-primary" type="button" @click="editing = true">
|
||||
<AppIcon name="plus" :size="16" /> Добавить кейс
|
||||
</button>
|
||||
</div>
|
||||
<div class="panel">
|
||||
<NuxtLink v-for="task in cases" :key="task.id" :to="'/admin/cases/' + task.id" class="simple-row"
|
||||
><div class="case-row-label">
|
||||
<CaseIcon :src="task.icon" />
|
||||
<div>
|
||||
<strong>{{ task.name }}</strong>
|
||||
<p>{{ task.teams.length }} команд · {{ task.users.length }} экспертов</p>
|
||||
</div>
|
||||
</div>
|
||||
<AppIcon name="arrow" :size="18"
|
||||
/></NuxtLink>
|
||||
<div v-if="!cases.length" class="table-empty">Кейсов пока нет.</div>
|
||||
</div>
|
||||
<FormDialog
|
||||
v-if="editing"
|
||||
title="Новый кейс"
|
||||
:busy="saving"
|
||||
submit-label="Добавить"
|
||||
@close="
|
||||
editing = false
|
||||
error = ''
|
||||
"
|
||||
@save="save"
|
||||
><label class="field" for="caseName"
|
||||
><span>Название</span
|
||||
><input id="caseName" v-model.trim="name" class="text-input" maxlength="255" required /></label
|
||||
><label class="field" for="caseDescription"
|
||||
><span>Описание</span
|
||||
><textarea id="caseDescription" v-model.trim="description" class="text-input" maxlength="10000" rows="3" />
|
||||
</label>
|
||||
<CaseIconUpload v-model="icon" :disabled="saving" />
|
||||
<div v-if="error" class="form-error" role="alert">{{ error }}</div></FormDialog
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: 'AdminCases',
|
||||
async asyncData({ $axios }) {
|
||||
return await $axios.$get('/admin/cases')
|
||||
},
|
||||
data() {
|
||||
return { cases: [], editing: false, name: '', description: '', icon: null, saving: false, error: '' }
|
||||
},
|
||||
methods: {
|
||||
async save() {
|
||||
if (this.saving || !this.name) return
|
||||
this.saving = true
|
||||
this.error = ''
|
||||
try {
|
||||
const { case: task } = await this.$axios.$post('/admin/cases', {
|
||||
name: this.name,
|
||||
description: this.description,
|
||||
icon: this.icon,
|
||||
})
|
||||
await this.$router.push('/admin/cases/' + task.id)
|
||||
} catch (e) {
|
||||
this.error = 'Не удалось добавить кейс.'
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,317 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="page-heading">
|
||||
<h1>Результаты</h1>
|
||||
<button class="button" type="button" :disabled="refreshing" @click="refresh">
|
||||
{{ refreshing ? 'Обновляем…' : 'Обновить' }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="toolbar">
|
||||
<div class="tabs report-tabs" role="group" aria-label="Отчёт">
|
||||
<button
|
||||
v-for="item in tabs"
|
||||
:key="item.id"
|
||||
class="tab"
|
||||
:class="{ active: tab === item.id }"
|
||||
:aria-pressed="String(tab === item.id)"
|
||||
type="button"
|
||||
@click="tab = item.id"
|
||||
>
|
||||
{{ item.name }}
|
||||
</button>
|
||||
</div>
|
||||
<select v-model="selectedCase" class="filter-select" aria-label="Кейс">
|
||||
<option value="">Все кейсы</option>
|
||||
<option v-for="(name, id) in cases" :key="id" :value="id">{{ name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-if="error" class="form-error" role="alert">{{ error }}</div>
|
||||
<template v-if="tab === 'ranking'"
|
||||
><section v-for="(ranking, id) in filteredPositions" :key="id" class="panel report-section">
|
||||
<div class="panel-header">
|
||||
<h2>{{ cases[id] }}</h2>
|
||||
</div>
|
||||
<div class="table-scroll">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<SortHeader
|
||||
v-for="column in rankingColumns"
|
||||
:key="column.key"
|
||||
:active="sorting.key === column.key"
|
||||
:direction="sorting.direction"
|
||||
@sort="sortBy(column.key)"
|
||||
>{{ column.name }}</SortHeader
|
||||
>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="[teamId, place] in sortedRanking(ranking)" :key="teamId">
|
||||
<td style="width: 80px">{{ place }}</td>
|
||||
<td>{{ teams[teamId] }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
<div v-if="!Object.keys(filteredPositions).length" class="panel table-empty">Оценок пока нет.</div></template
|
||||
>
|
||||
<template v-else-if="tab === 'details'">
|
||||
<section v-for="task in filteredDetails" :key="task.id" class="panel report-section">
|
||||
<div class="panel-header">
|
||||
<h2>{{ task.name }}</h2>
|
||||
</div>
|
||||
<div class="table-scroll">
|
||||
<table class="data-table all-marks-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<SortHeader
|
||||
v-for="column in detailColumns"
|
||||
:key="column.key"
|
||||
:active="sorting.key === column.key"
|
||||
:direction="sorting.direction"
|
||||
@sort="sortBy(column.key)"
|
||||
>{{ column.name }}</SortHeader
|
||||
>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="row in sortedDetails(task.rows)" :key="row.teamId + row.userId">
|
||||
<td>{{ row.team }}</td>
|
||||
<td>{{ row.expert }}<span v-if="row.role === 'technical'" class="badge">Технический эксперт</span></td>
|
||||
<td v-for="(_, type) in criteria" :key="type">
|
||||
{{ row.marks[type] === null ? '—' : row.marks[type] }}
|
||||
</td>
|
||||
<td>{{ row.total === null ? '—' : row.total }}</td>
|
||||
</tr>
|
||||
<tr v-if="!task.rows.length">
|
||||
<td :colspan="Object.keys(criteria).length + 3" class="table-empty">
|
||||
Нет назначенных экспертов или команд.
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
<div v-if="!filteredDetails.length" class="panel table-empty">Кейсов пока нет.</div>
|
||||
</template>
|
||||
<section v-else class="panel">
|
||||
<div class="table-scroll">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<SortHeader
|
||||
v-for="column in reportColumns"
|
||||
:key="column.key"
|
||||
:active="sorting.key === column.key"
|
||||
:direction="sorting.direction"
|
||||
@sort="sortBy(column.key)"
|
||||
>{{ column.name }}</SortHeader
|
||||
>
|
||||
</tr>
|
||||
</thead>
|
||||
<template v-if="tab === 'zero'">
|
||||
<tbody v-for="group in zeroGroups" :key="group.id">
|
||||
<tr v-for="(row, index) in group.rows" :key="index">
|
||||
<td v-if="index === 0" :rowspan="group.rows.length">{{ group.user }}</td>
|
||||
<td>{{ row.task }}</td>
|
||||
<td class="assignment-cell">{{ row.teams[0] }}</td>
|
||||
<td class="assignment-cell">{{ row.criterion }}</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</template>
|
||||
<tbody v-if="tab !== 'zero' || !reportRows.length">
|
||||
<tr v-for="(row, index) in reportRows" :key="index">
|
||||
<td>{{ row.user }}</td>
|
||||
<td>{{ row.task }}</td>
|
||||
<td class="assignment-cell">{{ row.teams.join(', ') }}</td>
|
||||
<td v-if="tab === 'zero'">{{ row.criterion }}</td>
|
||||
<td v-if="tab === 'zero'">0</td>
|
||||
</tr>
|
||||
<tr v-if="!reportRows.length">
|
||||
<td :colspan="reportColumns.length" class="table-empty">
|
||||
{{ tab === 'missing' ? 'Все оценки заполнены.' : 'Нулевых оценок нет.' }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: 'Results',
|
||||
async asyncData({ $axios }) {
|
||||
const [missing, ranking, detail] = await Promise.all([
|
||||
$axios.$get('/admin/marks'),
|
||||
$axios.$get('/admin/positions'),
|
||||
$axios.$get('/admin/marks/details'),
|
||||
])
|
||||
return { ...missing, ...ranking, ...detail }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
noMarks: {},
|
||||
zeroMarks: {},
|
||||
positions: {},
|
||||
details: [],
|
||||
criteria: {},
|
||||
cases: {},
|
||||
teams: {},
|
||||
selectedCase: '',
|
||||
tab: 'ranking',
|
||||
sorts: {
|
||||
ranking: { key: 'place', direction: 'asc' },
|
||||
details: { key: '', direction: 'asc' },
|
||||
missing: { key: '', direction: 'asc' },
|
||||
zero: { key: '', direction: 'asc' },
|
||||
},
|
||||
rankingColumns: [
|
||||
{ key: 'place', name: 'Место' },
|
||||
{ key: 'team', name: 'Команда' },
|
||||
],
|
||||
missingColumns: [
|
||||
{ key: 'user', name: 'Эксперт' },
|
||||
{ key: 'task', name: 'Кейс' },
|
||||
{ key: 'teams', name: 'Команды' },
|
||||
],
|
||||
refreshing: false,
|
||||
error: '',
|
||||
tabs: [
|
||||
{ id: 'ranking', name: 'Рейтинг' },
|
||||
{ id: 'details', name: 'Все оценки' },
|
||||
{ id: 'missing', name: 'Без оценок' },
|
||||
{ id: 'zero', name: 'Нулевые оценки' },
|
||||
],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
zeroGroups() {
|
||||
if (this.tab !== 'zero') return []
|
||||
const groups = new Map()
|
||||
for (const row of this.reportRows) {
|
||||
if (!groups.has(row.userId)) groups.set(row.userId, { id: row.userId, user: row.user, rows: [] })
|
||||
groups.get(row.userId).rows.push(row)
|
||||
}
|
||||
const direction = this.sorting.key === 'user' && this.sorting.direction === 'desc' ? -1 : 1
|
||||
return [...groups.values()].sort(
|
||||
(a, b) => direction * a.user.localeCompare(b.user, 'ru', { sensitivity: 'base', numeric: true })
|
||||
)
|
||||
},
|
||||
reportColumns() {
|
||||
if (this.tab !== 'zero') return this.missingColumns
|
||||
return [
|
||||
{ key: 'user', name: 'Эксперт' },
|
||||
{ key: 'task', name: 'Кейс' },
|
||||
{ key: 'teams', name: 'Команда' },
|
||||
{ key: 'criterion', name: 'Критерий' },
|
||||
{ key: 'value', name: 'Оценка' },
|
||||
]
|
||||
},
|
||||
sorting() {
|
||||
return this.sorts[this.tab]
|
||||
},
|
||||
detailColumns() {
|
||||
return [
|
||||
{ key: 'team', name: 'Команда' },
|
||||
{ key: 'expert', name: 'Эксперт' },
|
||||
...Object.entries(this.criteria).map(([type, name]) => ({
|
||||
key: 'mark:' + type,
|
||||
name: name + ([20, 30].includes(+type) ? ' (тех.)' : ''),
|
||||
})),
|
||||
{ key: 'total', name: 'Сумма' },
|
||||
]
|
||||
},
|
||||
filteredDetails() {
|
||||
return this.details.filter(task => !this.selectedCase || task.id === this.selectedCase)
|
||||
},
|
||||
filteredPositions() {
|
||||
return this.selectedCase
|
||||
? this.positions[this.selectedCase]
|
||||
? { [this.selectedCase]: this.positions[this.selectedCase] }
|
||||
: {}
|
||||
: this.positions
|
||||
},
|
||||
reportRows() {
|
||||
if (this.tab === 'zero') {
|
||||
const rows = this.filteredDetails.flatMap(task =>
|
||||
task.rows.flatMap(row => {
|
||||
const types = Object.entries(row.marks)
|
||||
.filter(([, value]) => value === 0)
|
||||
.map(([type]) => type)
|
||||
return types.length
|
||||
? [
|
||||
{
|
||||
userId: row.userId,
|
||||
user: row.expert + (row.role === 'technical' ? ' (тех.)' : ''),
|
||||
task: task.name,
|
||||
teams: [row.team],
|
||||
criterion: types
|
||||
.map(type => this.criteria[type] + ([20, 30].includes(+type) ? ' (тех.)' : ''))
|
||||
.join(', '),
|
||||
value: 0,
|
||||
},
|
||||
]
|
||||
: []
|
||||
})
|
||||
)
|
||||
return this.sortRows(rows, (row, key) => (key === 'teams' ? row.teams[0] : row[key]))
|
||||
}
|
||||
const data = this.noMarks
|
||||
const rows = Object.entries(data).flatMap(([user, tasks]) =>
|
||||
Object.entries(tasks)
|
||||
.filter(([name]) => !this.selectedCase || name === this.cases[this.selectedCase])
|
||||
.map(([task, teams]) => ({ user, task, teams }))
|
||||
)
|
||||
return this.sortRows(rows, (row, key) => (key === 'teams' ? row.teams.join(', ') : row[key]))
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
sortBy(key) {
|
||||
this.$set(this.sorts, this.tab, {
|
||||
key,
|
||||
direction: this.sorting.key === key && this.sorting.direction === 'asc' ? 'desc' : 'asc',
|
||||
})
|
||||
},
|
||||
sortRows(rows, value) {
|
||||
const { key, direction } = this.sorting
|
||||
if (!key) return rows
|
||||
return [...rows].sort((a, b) => {
|
||||
const left = value(a, key)
|
||||
const right = value(b, key)
|
||||
if (left == null) return right == null ? 0 : 1
|
||||
if (right == null) return -1
|
||||
const result =
|
||||
typeof left === 'number' && typeof right === 'number'
|
||||
? left - right
|
||||
: String(left).localeCompare(String(right), 'ru', { numeric: true, sensitivity: 'base' })
|
||||
return direction === 'asc' ? result : -result
|
||||
})
|
||||
},
|
||||
sortedDetails(rows) {
|
||||
return this.sortRows(rows, (row, key) => (key.startsWith('mark:') ? row.marks[key.slice(5)] : row[key]))
|
||||
},
|
||||
sortedRanking(ranking) {
|
||||
return this.sortRows(Object.entries(ranking), (row, key) => (key === 'place' ? row[1] : this.teams[row[0]]))
|
||||
},
|
||||
async refresh() {
|
||||
this.refreshing = true
|
||||
this.error = ''
|
||||
try {
|
||||
const [missing, ranking, detail] = await Promise.all([
|
||||
this.$axios.$get('/admin/marks'),
|
||||
this.$axios.$get('/admin/positions'),
|
||||
this.$axios.$get('/admin/marks/details'),
|
||||
])
|
||||
Object.assign(this, missing, ranking, detail)
|
||||
} catch (e) {
|
||||
this.error = 'Не удалось обновить результаты.'
|
||||
} finally {
|
||||
this.refreshing = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,452 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="page-heading expert-heading">
|
||||
<h1>Эксперты</h1>
|
||||
<div class="expert-header-actions">
|
||||
<button class="button" type="button" :disabled="!activeCount" @click="openExport">QR-коды PDF</button
|
||||
><button class="button button-primary" type="button" @click="openNew">
|
||||
<AppIcon name="plus" :size="16" /> Добавить эксперта
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="toolbar">
|
||||
<div class="tabs" role="group" aria-label="Статус эксперта">
|
||||
<button
|
||||
v-for="tab in tabs"
|
||||
:key="tab.id"
|
||||
class="tab"
|
||||
:class="{ active: filter === tab.id }"
|
||||
:aria-pressed="String(filter === tab.id)"
|
||||
type="button"
|
||||
@click="filter = tab.id"
|
||||
>
|
||||
{{ tab.name }}
|
||||
</button>
|
||||
</div>
|
||||
<label class="search-box"
|
||||
><AppIcon name="search" :size="16" /><input
|
||||
v-model="search"
|
||||
type="search"
|
||||
aria-label="Найти эксперта"
|
||||
placeholder="Найти эксперта"
|
||||
/></label>
|
||||
</div>
|
||||
<div v-if="pageError" class="form-error" role="alert">{{ pageError }}</div>
|
||||
<div class="panel">
|
||||
<div class="table-scroll">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Эксперт</th>
|
||||
<th scope="col">Роль</th>
|
||||
<th scope="col">Логин / пароль</th>
|
||||
<th scope="col">Кейсы</th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="user in filteredUsers" :key="user.id">
|
||||
<td>{{ fullName(user) }}</td>
|
||||
<td>{{ user.role === 'technical' ? 'Технический эксперт' : 'Эксперт' }}</td>
|
||||
<td>
|
||||
<span class="mono">{{ user.login }}</span>
|
||||
<div class="password-cell">
|
||||
<span class="mono">{{ revealed[user.id] ? user.passwordForAdmin || '—' : '••••••••' }}</span
|
||||
><button
|
||||
v-if="user.passwordForAdmin"
|
||||
class="icon-button"
|
||||
type="button"
|
||||
:aria-label="(revealed[user.id] ? 'Скрыть пароль: ' : 'Показать пароль: ') + user.login"
|
||||
:aria-pressed="String(!!revealed[user.id])"
|
||||
@click="$set(revealed, user.id, !revealed[user.id])"
|
||||
>
|
||||
<AppIcon name="eye" :size="15" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
<td class="assignment-cell">{{ user.cases.map(c => c.name).join(', ') || 'Не назначены' }}</td>
|
||||
<td>
|
||||
<div class="expert-actions">
|
||||
<template v-if="!user.deletedAt"
|
||||
><button
|
||||
class="button button-sm"
|
||||
type="button"
|
||||
:aria-label="'Назначить кейсы: ' + user.login"
|
||||
:disabled="saving"
|
||||
@click="assign(user)"
|
||||
>
|
||||
Кейсы</button
|
||||
><button
|
||||
class="button button-sm"
|
||||
type="button"
|
||||
:aria-label="'Изменить эксперта: ' + user.login"
|
||||
:disabled="saving"
|
||||
@click="openEdit(user)"
|
||||
>
|
||||
Изменить</button
|
||||
><button
|
||||
class="button button-sm danger-text"
|
||||
type="button"
|
||||
:aria-label="'Удалить эксперта: ' + user.login"
|
||||
:disabled="saving"
|
||||
@click="openDelete(user)"
|
||||
>
|
||||
Удалить
|
||||
</button></template
|
||||
><button
|
||||
v-else
|
||||
class="button button-sm"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
:aria-label="'Восстановить эксперта: ' + user.login"
|
||||
@click="restore(user)"
|
||||
>
|
||||
Восстановить
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!filteredUsers.length">
|
||||
<td colspan="5" class="table-empty">Эксперты не найдены.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<FormDialog
|
||||
v-if="editor === 'new' || editor === 'edit'"
|
||||
:title="editor === 'new' ? 'Новый эксперт' : 'Изменить эксперта'"
|
||||
:busy="saving"
|
||||
:submit-label="editor === 'new' ? 'Добавить' : 'Сохранить'"
|
||||
@close="editor = null"
|
||||
@save="saveUser"
|
||||
><label class="field" for="lastName"
|
||||
><span>Фамилия</span
|
||||
><input
|
||||
id="lastName"
|
||||
v-model.trim="draft.lastName"
|
||||
class="text-input"
|
||||
maxlength="50"
|
||||
autocomplete="family-name"
|
||||
required /></label
|
||||
><label class="field" for="firstName"
|
||||
><span>Имя</span
|
||||
><input
|
||||
id="firstName"
|
||||
v-model.trim="draft.firstName"
|
||||
class="text-input"
|
||||
maxlength="50"
|
||||
autocomplete="given-name"
|
||||
required /></label
|
||||
><label class="field" for="middleName"
|
||||
><span>Отчество</span
|
||||
><input
|
||||
id="middleName"
|
||||
v-model.trim="draft.middleName"
|
||||
class="text-input"
|
||||
maxlength="50"
|
||||
autocomplete="additional-name" /></label
|
||||
><template v-if="editor === 'edit'"
|
||||
><label class="field" for="expertLogin"
|
||||
><span>Логин</span
|
||||
><input
|
||||
id="expertLogin"
|
||||
v-model.trim="draft.login"
|
||||
class="text-input"
|
||||
minlength="2"
|
||||
maxlength="100"
|
||||
pattern="[a-zA-Z0-9_.@\-]+"
|
||||
autocomplete="off"
|
||||
required /></label
|
||||
><label class="field" for="expertPassword"
|
||||
><span>Новый пароль</span
|
||||
><input
|
||||
id="expertPassword"
|
||||
v-model="draft.password"
|
||||
class="text-input"
|
||||
type="password"
|
||||
placeholder="Не менять"
|
||||
minlength="6"
|
||||
maxlength="72"
|
||||
autocomplete="new-password" /></label
|
||||
></template>
|
||||
<label class="field" for="expertRole">
|
||||
<span>Роль</span>
|
||||
<select id="expertRole" v-model="draft.role" class="text-input" aria-label="Роль" :disabled="saving">
|
||||
<option value="expert">Эксперт</option>
|
||||
<option value="technical">Технический эксперт</option>
|
||||
</select>
|
||||
</label>
|
||||
<div v-if="editor === 'new'" class="field">
|
||||
<span>Кейсы</span>
|
||||
<div class="checkbox-list">
|
||||
<label v-for="task in cases" :key="task.id" class="checkbox-row">
|
||||
<input v-model="selectedCaseIds" type="checkbox" :value="task.id" :disabled="saving" />
|
||||
<span>{{ task.name }}</span>
|
||||
</label>
|
||||
<p v-if="!cases.length" class="muted">Сначала добавьте кейсы.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="error" class="form-error" role="alert">{{ error }}</div></FormDialog
|
||||
>
|
||||
<FormDialog
|
||||
v-if="editor === 'cases'"
|
||||
:title="fullName(selectedUser)"
|
||||
:busy="saving"
|
||||
@close="editor = null"
|
||||
@save="saveAssignments"
|
||||
><div class="checkbox-list">
|
||||
<label v-for="task in cases" :key="task.id" class="checkbox-row"
|
||||
><input v-model="selectedCaseIds" type="checkbox" :value="task.id" :disabled="saving" /><span>{{
|
||||
task.name
|
||||
}}</span></label
|
||||
>
|
||||
<p v-if="!cases.length" class="muted">Сначала добавьте кейсы.</p>
|
||||
</div>
|
||||
<div v-if="error" class="form-error" role="alert">{{ error }}</div></FormDialog
|
||||
>
|
||||
<FormDialog
|
||||
v-if="editor === 'delete'"
|
||||
title="Удалить эксперта?"
|
||||
:busy="saving"
|
||||
submit-label="Удалить"
|
||||
danger
|
||||
@close="editor = null"
|
||||
@save="deleteUser"
|
||||
><p>{{ fullName(selectedUser) }}</p>
|
||||
<p class="muted" style="margin-top: 12px">Доступ будет закрыт. Оценки сохранятся.</p>
|
||||
<div v-if="error" class="form-error" role="alert" style="margin-top: 16px">{{ error }}</div></FormDialog
|
||||
>
|
||||
<FormDialog
|
||||
v-if="editor === 'export'"
|
||||
title="QR-коды экспертов"
|
||||
:busy="exporting"
|
||||
submit-label="Скачать PDF"
|
||||
@close="editor = null"
|
||||
@save="downloadQr"
|
||||
><label class="field" for="baseUrl"
|
||||
><span>Адрес приложения</span
|
||||
><input
|
||||
id="baseUrl"
|
||||
v-model.trim="baseUrl"
|
||||
class="text-input"
|
||||
type="url"
|
||||
maxlength="300"
|
||||
placeholder="https://grading.example.ru/"
|
||||
required
|
||||
/></label>
|
||||
<p class="muted">Все активные эксперты · A4 · 3 × 4 карточки</p>
|
||||
<p v-if="localAddress" class="muted" style="margin-top: 10px">
|
||||
Для входа с телефона укажите адрес, доступный экспертам.
|
||||
</p>
|
||||
<div v-if="error" class="form-error" role="alert" style="margin-top: 16px">{{ error }}</div></FormDialog
|
||||
>
|
||||
<div v-if="message" class="toast" role="status">{{ message }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: 'Experts',
|
||||
async asyncData({ $axios }) {
|
||||
const [{ users }, { cases }] = await Promise.all([$axios.$get('/admin/users'), $axios.$get('/admin/cases')])
|
||||
return { users, cases }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
users: [],
|
||||
cases: [],
|
||||
search: '',
|
||||
filter: 'active',
|
||||
tabs: [
|
||||
{ id: 'active', name: 'Активные' },
|
||||
{ id: 'deleted', name: 'Удалённые' },
|
||||
],
|
||||
revealed: {},
|
||||
editor: null,
|
||||
selectedUser: null,
|
||||
selectedCaseIds: [],
|
||||
draft: { firstName: '', lastName: '', middleName: '', login: '', password: '', role: 'expert' },
|
||||
error: '',
|
||||
pageError: '',
|
||||
saving: false,
|
||||
exporting: false,
|
||||
baseUrl: '',
|
||||
message: '',
|
||||
timer: null,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
activeCount() {
|
||||
return this.users.filter(u => !u.deletedAt).length
|
||||
},
|
||||
filteredUsers() {
|
||||
const query = this.search.toLowerCase()
|
||||
return this.users.filter(
|
||||
u =>
|
||||
(this.filter === 'deleted' ? !!u.deletedAt : !u.deletedAt) &&
|
||||
`${this.fullName(u)} ${u.login}`.toLowerCase().includes(query)
|
||||
)
|
||||
},
|
||||
localAddress() {
|
||||
try {
|
||||
return ['localhost', '127.0.0.1', '[::1]'].includes(new URL(this.baseUrl).hostname)
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
},
|
||||
},
|
||||
beforeDestroy() {
|
||||
clearTimeout(this.timer)
|
||||
},
|
||||
methods: {
|
||||
fullName(user) {
|
||||
return [user.lastName, user.firstName, user.middleName].filter(Boolean).join(' ')
|
||||
},
|
||||
async reload() {
|
||||
const { users } = await this.$axios.$get('/admin/users')
|
||||
this.users = users
|
||||
},
|
||||
notify(message) {
|
||||
this.message = message
|
||||
clearTimeout(this.timer)
|
||||
this.timer = setTimeout(() => {
|
||||
this.message = ''
|
||||
}, 3500)
|
||||
},
|
||||
openNew() {
|
||||
this.draft = { firstName: '', lastName: '', middleName: '', login: '', password: '', role: 'expert' }
|
||||
this.selectedCaseIds = []
|
||||
this.error = ''
|
||||
this.editor = 'new'
|
||||
},
|
||||
openEdit(user) {
|
||||
this.selectedUser = user
|
||||
this.draft = {
|
||||
firstName: user.firstName,
|
||||
lastName: user.lastName,
|
||||
middleName: user.middleName || '',
|
||||
login: user.login,
|
||||
password: '',
|
||||
role: user.role || 'expert',
|
||||
}
|
||||
this.error = ''
|
||||
this.editor = 'edit'
|
||||
},
|
||||
openDelete(user) {
|
||||
this.selectedUser = user
|
||||
this.error = ''
|
||||
this.editor = 'delete'
|
||||
},
|
||||
openExport() {
|
||||
this.baseUrl = 'https://cg.vkhost.ru/'
|
||||
this.error = ''
|
||||
this.editor = 'export'
|
||||
},
|
||||
assign(user) {
|
||||
this.selectedUser = user
|
||||
this.selectedCaseIds = user.cases.map(c => c.id)
|
||||
this.error = ''
|
||||
this.editor = 'cases'
|
||||
},
|
||||
async saveUser() {
|
||||
if (this.saving) return
|
||||
this.saving = true
|
||||
this.error = ''
|
||||
try {
|
||||
if (this.editor === 'new')
|
||||
await this.$axios.$post('/admin/users', { ...this.draft, caseIds: this.selectedCaseIds })
|
||||
else await this.$axios.$put('/admin/users/' + this.selectedUser.id, this.draft)
|
||||
await this.reload()
|
||||
this.editor = null
|
||||
this.revealed = {}
|
||||
this.filter = 'active'
|
||||
this.search = ''
|
||||
this.notify('Эксперт сохранён')
|
||||
} catch (e) {
|
||||
this.error =
|
||||
e.response?.status === 409
|
||||
? e.response.data.key === 'SYSTEM_ERROR'
|
||||
? e.response.data.message
|
||||
: 'Эксперт или логин уже существует.'
|
||||
: 'Не удалось сохранить эксперта. Проверьте ФИО, логин и пароль.'
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
},
|
||||
async deleteUser() {
|
||||
if (this.saving) return
|
||||
this.saving = true
|
||||
this.error = ''
|
||||
try {
|
||||
await this.$axios.$delete('/admin/users/' + this.selectedUser.id)
|
||||
await this.reload()
|
||||
this.editor = null
|
||||
this.revealed = {}
|
||||
this.notify('Эксперт удалён')
|
||||
} catch (e) {
|
||||
this.error = 'Не удалось удалить эксперта.'
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
},
|
||||
async restore(user) {
|
||||
if (this.saving) return
|
||||
this.saving = true
|
||||
this.pageError = ''
|
||||
try {
|
||||
await this.$axios.$post('/admin/users/' + user.id + '/restore')
|
||||
await this.reload()
|
||||
this.notify('Эксперт восстановлен')
|
||||
} catch (e) {
|
||||
this.pageError = e.response?.data?.message || 'Не удалось восстановить эксперта.'
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
},
|
||||
async saveAssignments() {
|
||||
if (this.saving) return
|
||||
this.saving = true
|
||||
this.error = ''
|
||||
try {
|
||||
await this.$axios.$put('/admin/users/' + this.selectedUser.id + '/cases', { caseIds: this.selectedCaseIds })
|
||||
await this.reload()
|
||||
this.editor = null
|
||||
this.notify('Кейсы назначены')
|
||||
} catch (e) {
|
||||
this.error = e.response?.data?.message || 'Не удалось сохранить назначения.'
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
},
|
||||
async downloadQr() {
|
||||
if (this.exporting) return
|
||||
this.exporting = true
|
||||
this.error = ''
|
||||
try {
|
||||
const response = await this.$axios.post(
|
||||
'/admin/users/qr-pdf',
|
||||
{ baseUrl: this.baseUrl },
|
||||
{ responseType: 'blob' }
|
||||
)
|
||||
const url = URL.createObjectURL(response.data)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = 'experts-qr.pdf'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
link.remove()
|
||||
setTimeout(() => URL.revokeObjectURL(url), 10000)
|
||||
this.editor = null
|
||||
} catch (e) {
|
||||
let message = ''
|
||||
try {
|
||||
message = JSON.parse(await e.response.data.text()).message
|
||||
} catch (ignored) {}
|
||||
this.error = message || 'Не удалось скачать PDF. Попробуйте ещё раз.'
|
||||
} finally {
|
||||
this.exporting = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,5 @@
|
||||
<script>
|
||||
import ExpertCases from '../index.vue'
|
||||
|
||||
export default { ...ExpertCases, name: 'ExpertCase' }
|
||||
</script>
|
||||
@@ -0,0 +1,375 @@
|
||||
<template>
|
||||
<div>
|
||||
<button v-if="selectedCase" class="back-link" type="button" @click="home">
|
||||
<AppIcon name="back" :size="15" /> Кейсы
|
||||
</button>
|
||||
<div class="page-heading">
|
||||
<div class="case-title">
|
||||
<CaseIcon v-if="selectedCase" :src="currentCase.icon" />
|
||||
<h1>{{ selectedCase ? currentCase.name : 'Кейсы' }}</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel">
|
||||
<button
|
||||
v-for="item in items"
|
||||
:key="item.id"
|
||||
class="simple-row clickable-row"
|
||||
type="button"
|
||||
:aria-label="(selectedCase ? 'Оценить ' : 'Открыть ') + item.name"
|
||||
@click="selectItem(item.id)"
|
||||
>
|
||||
<span class="case-row-label">
|
||||
<CaseIcon v-if="!selectedCase" :src="item.icon" />
|
||||
<span>
|
||||
<strong>{{ item.name }}</strong>
|
||||
<span v-if="item.description" class="row-description">{{ item.description }}</span>
|
||||
<span v-if="!selectedCase" class="row-description"
|
||||
>{{ item.teams.length }} {{ teamWord(item.teams.length) }}</span
|
||||
>
|
||||
<span v-if="selectedCase && isComplete(item)" class="badge team-status-mobile">Оценено</span>
|
||||
</span>
|
||||
</span>
|
||||
<span class="row-actions">
|
||||
<span v-if="selectedCase && isComplete(item)" class="badge team-status-desktop">Оценено</span
|
||||
><span class="button" aria-hidden="true">
|
||||
{{ selectedCase ? 'Оценить' : 'Открыть' }}
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
<div v-if="!items.length" class="table-empty">
|
||||
{{ selectedCase ? 'Команд пока нет.' : 'Кейсы не назначены.' }}
|
||||
</div>
|
||||
</div>
|
||||
<dialog
|
||||
ref="scoreDialog"
|
||||
class="score-dialog team-score-dialog"
|
||||
aria-labelledby="score-title"
|
||||
@cancel="closeScore"
|
||||
@click="backdropClick"
|
||||
>
|
||||
<template v-if="team"
|
||||
><div class="dialog-header">
|
||||
<div>
|
||||
<h2 id="score-title">{{ team.name }}</h2>
|
||||
</div>
|
||||
<button class="icon-button" type="button" aria-label="Закрыть оценки" :disabled="saving" @click="closeScore">
|
||||
<AppIcon name="close" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="dialog-body">
|
||||
<p v-if="loadingScore" class="muted" role="status">Загрузка…</p>
|
||||
<div v-if="loadError" class="form-error" role="alert">
|
||||
Не удалось загрузить оценки и комментарий. Откройте команду ещё раз.
|
||||
</div>
|
||||
<div v-if="saveError" class="form-error" role="alert">
|
||||
Не удалось сохранить изменения. Попробуйте ещё раз.
|
||||
</div>
|
||||
<div v-for="(criterion, index) in editableCriteria" :key="criterion.type" class="score-criterion">
|
||||
<div :id="'criterion-' + criterion.type" class="criterion-heading">
|
||||
<span
|
||||
><span class="criterion-index">0{{ index + 1 }}</span
|
||||
>{{ criterion.name }}</span
|
||||
><span>{{ draft[criterion.type] }} / 5</span>
|
||||
</div>
|
||||
<div class="score-scale" role="group" :aria-labelledby="'criterion-' + criterion.type">
|
||||
<button
|
||||
v-for="value in [0, 1, 2, 3, 4, 5]"
|
||||
:key="value"
|
||||
class="score-option"
|
||||
:class="{ selected: draft[criterion.type] === value }"
|
||||
:aria-pressed="String(draft[criterion.type] === value)"
|
||||
:aria-label="criterion.name + ': ' + value"
|
||||
:disabled="saving || loadingScore || loadError"
|
||||
type="button"
|
||||
@click="$set(draft, criterion.type, value)"
|
||||
>
|
||||
{{ value }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="scale-labels"><span>Не проявлено</span><span>Отлично</span></div>
|
||||
</div>
|
||||
<div v-if="isTechnicalExpert" class="field technical-comment-editor">
|
||||
<label for="technicalComment">Комментарий</label>
|
||||
<textarea
|
||||
id="technicalComment"
|
||||
v-model="draftComment"
|
||||
class="text-input"
|
||||
maxlength="5000"
|
||||
rows="4"
|
||||
:disabled="saving || loadingScore || loadError"
|
||||
@input="commentSaved = false"
|
||||
/>
|
||||
<button
|
||||
class="button button-sm"
|
||||
type="button"
|
||||
:disabled="saving || loadingScore || loadError"
|
||||
@click="save(true)"
|
||||
>
|
||||
Сохранить комментарий
|
||||
</button>
|
||||
<p v-if="commentSaved" class="muted" role="status">Комментарий сохранён</p>
|
||||
</div>
|
||||
<section v-if="!isTechnicalExpert && team.technicalComment" class="technical-comment">
|
||||
<h3>Комментарий тех. эксперта</h3>
|
||||
<p>{{ team.technicalComment }}</p>
|
||||
</section>
|
||||
<div v-if="!isTechnicalExpert" class="admin-criteria">
|
||||
<div class="admin-criteria-title"><AppIcon name="lock" :size="13" /> Оценки тех. экспертов</div>
|
||||
<div v-for="criterion in lockedCriteria" :key="criterion.type" class="locked-score">
|
||||
<span>{{ criterion.name }}</span
|
||||
><strong>{{ savedMark(criterion.type) }} / 5</strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dialog-footer">
|
||||
<div class="score-total">
|
||||
Ваша оценка<strong
|
||||
>{{ draftTotal }} <span>/ {{ editableCriteria.length * 5 }}</span></strong
|
||||
>
|
||||
</div>
|
||||
<div class="dialog-footer-actions">
|
||||
<button class="button button-quiet" type="button" :disabled="saving" @click="closeScore">Отмена</button
|
||||
><button
|
||||
class="button button-primary"
|
||||
type="button"
|
||||
:disabled="saving || loadingScore || loadError"
|
||||
@click="save()"
|
||||
>
|
||||
<AppIcon name="check" :size="16" /> {{ saving ? 'Сохраняем…' : 'Сохранить оценки' }}
|
||||
</button>
|
||||
</div>
|
||||
</div></template
|
||||
>
|
||||
</dialog>
|
||||
<Transition name="fade"
|
||||
><div v-if="saved" class="toast" role="status">
|
||||
<AppIcon name="check" :size="17" /> {{ savedMessage }}
|
||||
</div></Transition
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Index',
|
||||
middleware: 'home',
|
||||
async asyncData({ $axios, $auth, params, error }) {
|
||||
try {
|
||||
const [{ cases }, appdata] = await Promise.all([$axios.$get('/cases'), $axios.$get('/system/appdata')])
|
||||
if (params.id && !cases?.some(task => task.id === params.id)) {
|
||||
error({ statusCode: 404, message: 'Кейс не найден' })
|
||||
return {}
|
||||
}
|
||||
return { cases: cases || [], appdata }
|
||||
} catch (e) {
|
||||
await $auth.logout()
|
||||
return { cases: [], appdata: { markType: {}, markTypesNames: {} } }
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
cases: [],
|
||||
appdata: { markType: {}, markTypesNames: {} },
|
||||
selectedTeam: null,
|
||||
showScore: false,
|
||||
saving: false,
|
||||
saveError: false,
|
||||
loadingScore: false,
|
||||
loadError: false,
|
||||
scoreRequest: 0,
|
||||
draftComment: '',
|
||||
commentSaved: false,
|
||||
savedMessage: 'Оценки сохранены',
|
||||
saved: false,
|
||||
draft: {},
|
||||
search: '',
|
||||
filter: 'all',
|
||||
toastTimer: null,
|
||||
tabs: [
|
||||
{ id: 'all', label: 'Все' },
|
||||
{ id: 'pending', label: 'К оценке' },
|
||||
{ id: 'done', label: 'Оценено' },
|
||||
],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isTechnicalExpert() {
|
||||
return this.$auth.user?.role === 'technical'
|
||||
},
|
||||
selectedCase() {
|
||||
return this.$route.params.id || null
|
||||
},
|
||||
currentCase() {
|
||||
return this.cases.find(c => c.id === this.selectedCase)
|
||||
},
|
||||
items() {
|
||||
return this.currentCase?.teams || this.cases
|
||||
},
|
||||
team() {
|
||||
return this.currentCase?.teams.find(t => t.id === this.selectedTeam)
|
||||
},
|
||||
allTeams() {
|
||||
return this.cases.flatMap(c => c.teams)
|
||||
},
|
||||
relevantTeams() {
|
||||
return this.currentCase?.teams || this.allTeams
|
||||
},
|
||||
completedTeams() {
|
||||
return this.relevantTeams.filter(this.teamComplete).length
|
||||
},
|
||||
criteria() {
|
||||
return Object.entries(this.appdata.markTypesNames).map(([type, name]) => ({ type: +type, name }))
|
||||
},
|
||||
editableCriteria() {
|
||||
return this.criteria.filter(c => this.isTechnicalExpert === this.isAdminOnlyMarkType(c.type))
|
||||
},
|
||||
lockedCriteria() {
|
||||
return this.criteria.filter(c => this.isAdminOnlyMarkType(c.type))
|
||||
},
|
||||
draftTotal() {
|
||||
return this.editableCriteria.reduce((total, c) => total + (this.draft[c.type] || 0), 0)
|
||||
},
|
||||
visibleItems() {
|
||||
return this.items.filter(
|
||||
item =>
|
||||
item.name.toLowerCase().includes(this.search.toLowerCase()) &&
|
||||
(this.filter === 'all' || (this.filter === 'done' ? this.isComplete(item) : !this.isComplete(item)))
|
||||
)
|
||||
},
|
||||
},
|
||||
beforeDestroy() {
|
||||
clearTimeout(this.toastTimer)
|
||||
this.scoreRequest++
|
||||
},
|
||||
methods: {
|
||||
isAdminOnlyMarkType(type) {
|
||||
return type === this.appdata.markType.WORK || type === this.appdata.markType.IMPLEMENTATION
|
||||
},
|
||||
teamComplete(team) {
|
||||
return (
|
||||
this.editableCriteria.length > 0 &&
|
||||
this.editableCriteria.every(c => team.marks.some(m => m.markType === c.type && m.mark !== null))
|
||||
)
|
||||
},
|
||||
isComplete(item) {
|
||||
return this.selectedCase ? this.teamComplete(item) : item.teams.length > 0 && item.teams.every(this.teamComplete)
|
||||
},
|
||||
itemCompleted(item) {
|
||||
return this.selectedCase
|
||||
? this.editableCriteria.filter(c => item.marks.some(m => m.markType === c.type && m.mark !== null)).length
|
||||
: item.teams.filter(this.teamComplete).length
|
||||
},
|
||||
itemTotal(item) {
|
||||
return this.selectedCase ? this.editableCriteria.length : item.teams.length
|
||||
},
|
||||
teamWord(n) {
|
||||
return n % 10 === 1 && n % 100 !== 11
|
||||
? 'команда'
|
||||
: [2, 3, 4].includes(n % 10) && ![12, 13, 14].includes(n % 100)
|
||||
? 'команды'
|
||||
: 'команд'
|
||||
},
|
||||
savedMark(type) {
|
||||
return this.team?.marks.find(m => m.markType === type)?.mark ?? '—'
|
||||
},
|
||||
home() {
|
||||
this.$router.push('/')
|
||||
},
|
||||
fillDraft() {
|
||||
this.commentSaved = false
|
||||
this.draftComment = this.team.technicalComment || ''
|
||||
this.draft = Object.fromEntries(
|
||||
this.editableCriteria.map(c => [c.type, Math.min(5, Math.max(0, Number(this.savedMark(c.type)) || 0))])
|
||||
)
|
||||
},
|
||||
async selectItem(id) {
|
||||
if (!this.selectedCase) {
|
||||
this.$router.push('/cases/' + id)
|
||||
return
|
||||
}
|
||||
this.selectedTeam = id
|
||||
this.saveError = false
|
||||
this.loadError = false
|
||||
this.loadingScore = true
|
||||
const request = ++this.scoreRequest
|
||||
this.showScore = true
|
||||
this.fillDraft()
|
||||
this.$nextTick(() => this.$refs.scoreDialog.showModal())
|
||||
try {
|
||||
const data = await this.$axios.$get(`/cases/${this.selectedCase}/teams/${id}/marks`)
|
||||
if (request !== this.scoreRequest) return
|
||||
this.$set(this.team, 'marks', data.marks)
|
||||
this.$set(this.team, 'technicalComment', data.technicalComment || '')
|
||||
this.fillDraft()
|
||||
} catch (e) {
|
||||
if (request === this.scoreRequest) this.loadError = true
|
||||
} finally {
|
||||
if (request === this.scoreRequest) this.loadingScore = false
|
||||
}
|
||||
},
|
||||
closeScore(event) {
|
||||
if (this.saving) {
|
||||
event?.preventDefault()
|
||||
return
|
||||
}
|
||||
this.$refs.scoreDialog.close()
|
||||
this.showScore = false
|
||||
this.scoreRequest++
|
||||
this.loadingScore = false
|
||||
},
|
||||
backdropClick(event) {
|
||||
if (event.target !== this.$refs.scoreDialog) return
|
||||
const rect = event.target.getBoundingClientRect()
|
||||
if (
|
||||
event.clientX < rect.left ||
|
||||
event.clientX > rect.right ||
|
||||
event.clientY < rect.top ||
|
||||
event.clientY > rect.bottom
|
||||
)
|
||||
this.closeScore(event)
|
||||
},
|
||||
async save(commentOnly = false) {
|
||||
if (this.saving || this.loadingScore || this.loadError) return
|
||||
const marks = commentOnly
|
||||
? []
|
||||
: this.editableCriteria.map(c => ({
|
||||
markType: c.type,
|
||||
mark: Math.min(5, Math.max(0, Number(this.draft[c.type]) || 0)),
|
||||
}))
|
||||
this.saveError = false
|
||||
this.commentSaved = false
|
||||
this.saving = true
|
||||
try {
|
||||
await this.$axios.put(`/cases/${this.selectedCase}/teams/${this.selectedTeam}/marks`, {
|
||||
marks,
|
||||
...(this.isTechnicalExpert ? { technicalComment: this.draftComment } : {}),
|
||||
})
|
||||
if (this.isTechnicalExpert) {
|
||||
this.draftComment = this.draftComment.trim()
|
||||
this.$set(this.team, 'technicalComment', this.draftComment)
|
||||
}
|
||||
for (const { markType, mark } of marks) {
|
||||
const existing = this.team.marks.find(m => m.markType === markType)
|
||||
if (existing) existing.mark = mark
|
||||
else this.team.marks.push({ markType, mark })
|
||||
}
|
||||
if (!commentOnly) {
|
||||
this.$refs.scoreDialog.close()
|
||||
this.showScore = false
|
||||
}
|
||||
this.savedMessage = commentOnly ? 'Комментарий сохранён' : 'Оценки сохранены'
|
||||
this.commentSaved = commentOnly
|
||||
this.saved = true
|
||||
clearTimeout(this.toastTimer)
|
||||
this.toastTimer = setTimeout(() => {
|
||||
this.saved = false
|
||||
}, 4500)
|
||||
} catch (e) {
|
||||
this.saveError = true
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,68 @@
|
||||
<template>
|
||||
<main class="login-page">
|
||||
<form class="login-form" aria-label="Вход" @submit.prevent="userLogin">
|
||||
<img class="login-logo" src="/logo2026.png" alt="CyberGarden" width="180" height="170" />
|
||||
<h1 class="login-title">Система оценки команд</h1>
|
||||
<div v-if="error" class="form-error" role="alert">{{ error }}</div>
|
||||
<input
|
||||
id="login"
|
||||
v-model.trim="login.login"
|
||||
class="text-input"
|
||||
name="username"
|
||||
autocomplete="username"
|
||||
aria-label="Логин"
|
||||
placeholder="Логин"
|
||||
required
|
||||
/>
|
||||
<input
|
||||
id="password"
|
||||
v-model="login.password"
|
||||
class="text-input"
|
||||
name="password"
|
||||
type="password"
|
||||
autocomplete="current-password"
|
||||
aria-label="Пароль"
|
||||
placeholder="Пароль"
|
||||
required
|
||||
/>
|
||||
<button class="button button-primary" type="submit" :disabled="loading">
|
||||
{{ loading ? 'Входим…' : 'Войти' }}
|
||||
</button>
|
||||
</form>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Login',
|
||||
layout: 'empty',
|
||||
data() {
|
||||
return { login: { login: '', password: '' }, loading: false, error: '' }
|
||||
},
|
||||
mounted() {
|
||||
this.login.login = this.$route.query.l ?? ''
|
||||
this.login.password = this.$route.query.p ?? ''
|
||||
},
|
||||
methods: {
|
||||
async userLogin() {
|
||||
if (this.loading) return
|
||||
this.loading = true
|
||||
this.error = ''
|
||||
try {
|
||||
const { data } = await this.$auth.loginWith('local', { data: this.login })
|
||||
this.$auth.setUser(data.user)
|
||||
localStorage.setItem('user.firstName', data.user.firstName || '')
|
||||
localStorage.setItem('user.lastName', data.user.lastName || '')
|
||||
await this.$router.push(data.user.login === 'admin' ? '/admin' : '/')
|
||||
} catch (e) {
|
||||
this.error =
|
||||
e.response?.status === 403
|
||||
? 'Проверьте логин и пароль и попробуйте ещё раз.'
|
||||
: 'Не удалось войти. Проверьте соединение и попробуйте ещё раз.'
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 319 KiB |
@@ -0,0 +1 @@
|
||||
export const state = () => ({})
|
||||
@@ -0,0 +1,9 @@
|
||||
module.exports = {
|
||||
extends: [
|
||||
'stylelint-config-standard',
|
||||
'stylelint-config-prettier'
|
||||
],
|
||||
// add your custom config here
|
||||
// https://stylelint.io/user-guide/configuration
|
||||
rules: {}
|
||||
}
|
||||
Reference in new issue
Block a user