diff --git a/README.md b/README.md index cf5c967..0d3ab57 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ ## Возможности -- **Журнал записей** — отметки о занятиях с фото и прикреплёнными файлами (проектные работы), мягкое удаление и корзина +- **Журнал записей** — отметки о занятиях с фото и прикреплёнными файлами (проектные работы), мягкое удаление и корзина; в режиме карточек у записи показывается бейдж группы поверх фото и иконка статуса AI-проверки +- **AI-проверка (воркер)** — фоновый авто-чек текста записей (`worker.js`); статус каждой записи (очередь / проверка / проверено / пропущено / ошибка) отображается компактной иконкой в журнале с всплывающей подсказкой - **Файлы** — централизованный раздел со всеми загруженными файлами, фильтры (имя воспитанника, группа, даты, поиск) и вкладка «Откреплённые» - **Группы** — учебные группы, расписание (день недели, время), фотохроника группы - **Воспитанники** — справочник с привязкой к группам @@ -19,6 +20,7 @@ - Node.js + Express - PostgreSQL (pg) - Multer (загрузка файлов), Tar (бэкапы) +- Lucide (иконки UI) - Docker / Docker Compose - Tailscale (Serve / Funnel) — публикация по HTTPS @@ -239,6 +241,7 @@ docker exec whatido-tailscale-1 tailscale funnel status ├── .env.example # шаблон переменных окружения ├── Dockerfile # сборка образа (Node 20, генерация TLS-сертификата) ├── server.js # Express-приложение +├── worker.js # фоновый worker AI-проверки записей ├── certs/ # cert.pem приложения (монтируется в tailscale, в git не хранится) ├── db/ │ ├── init.sql # схема при первом запуске diff --git a/package-lock.json b/package-lock.json index 0ed481b..32d1e33 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "express-rate-limit": "^8.7.0", "heic-convert": "^2.1.0", "helmet": "^8.3.0", + "lucide": "^1.44.0", "multer": "^1.4.5-lts.1", "pg": "^8.13.0", "tar": "^7.4.3" @@ -1018,6 +1019,12 @@ "node": ">=8.0.0" } }, + "node_modules/lucide": { + "version": "1.44.0", + "resolved": "https://registry.npmjs.org/lucide/-/lucide-1.44.0.tgz", + "integrity": "sha512-d30uv1R6AOLBddzVMeeSk6aDAhobqh7nFxMsXuWHyhMmxKRhpLivikbfkmgzbWsn8WTLQIceGMlFY4g3gn4reg==", + "license": "ISC" + }, "node_modules/make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", diff --git a/package.json b/package.json index f5918b7..88b375c 100644 --- a/package.json +++ b/package.json @@ -6,14 +6,15 @@ "start": "node server.js" }, "dependencies": { + "bcrypt": "^5.1.1", "express": "^4.21.0", "express-rate-limit": "^8.7.0", + "heic-convert": "^2.1.0", "helmet": "^8.3.0", + "lucide": "^1.44.0", "multer": "^1.4.5-lts.1", "pg": "^8.13.0", - "tar": "^7.4.3", - "bcrypt": "^5.1.1", - "heic-convert": "^2.1.0" + "tar": "^7.4.3" }, "allowScripts": { "bcrypt@5.1.1": true diff --git a/public/admin.css b/public/admin.css index 4654ff4..052db2d 100644 --- a/public/admin.css +++ b/public/admin.css @@ -12,8 +12,9 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;b .sidebar nav a{display:flex;align-items:center;gap:10px;padding:10px 20px;color:var(--muted);text-decoration:none;font-size:.9rem;transition:all .15s;border-left:3px solid transparent} .sidebar nav a:hover{color:var(--text);background:var(--bg)} .sidebar nav a.active{color:var(--accent);background:rgba(37,99,235,.06);border-left-color:var(--accent);font-weight:500} +.sidebar nav a i,.sidebar .bottom a i{width:16px;height:16px;flex-shrink:0} .sidebar .bottom{padding:12px 20px;border-top:1px solid var(--border)} -.sidebar .bottom a{display:block;color:var(--muted);text-decoration:none;font-size:.8rem;padding:6px 0} +.sidebar .bottom a{display:flex;align-items:center;gap:10px;color:var(--muted);text-decoration:none;font-size:.8rem;padding:6px 0} .sidebar .bottom a:hover{color:var(--text)} .sidebar .bottom .logout{color:#ef4444;cursor:pointer;margin-top:4px} @@ -51,15 +52,15 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;b .card .group{color:var(--accent);font-size:.8rem;margin-top:2px} .card .desc{color:var(--muted);font-size:.85rem;margin-top:8px;line-height:1.4;white-space:pre-wrap} .card .time{color:var(--muted);font-size:.75rem;margin-top:8px} -.entry-files{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px} -.entry-files .f-item{display:inline-flex;align-items:center;gap:2px;background:var(--bg);border:1px solid var(--border);border-radius:6px;padding:2px} +.entry-files{display:grid;grid-template-columns:repeat(4,1fr);gap:6px;margin-top:8px} +.entry-files .f-item{display:flex;align-items:center;gap:2px;background:var(--bg);border:1px solid var(--border);border-radius:6px;padding:2px;min-width:0} .entry-files .f-item:hover{border-color:var(--accent)} -.entry-files .f-item a{display:inline-flex;align-items:center;gap:4px;color:var(--text);text-decoration:none;padding:2px 6px;font-size:.75rem;max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +.entry-files .f-item a{display:inline-flex;align-items:center;gap:4px;color:var(--text);text-decoration:none;padding:2px 6px;font-size:.75rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0} .entry-files .f-item a:hover{color:var(--accent)} .entry-files .f-item a::before{content:'📎'} -.entry-files .f-detach{background:none;border:none;color:var(--muted);cursor:pointer;font-size:.75rem;line-height:1;padding:2px 5px;border-radius:4px} +.entry-files .f-detach{flex-shrink:0;background:none;border:none;color:var(--muted);cursor:pointer;font-size:.75rem;line-height:1;padding:2px 5px;border-radius:4px} .entry-files .f-detach:hover{color:#ef4444;background:rgba(239,68,68,.1)} -.entry-files a{display:inline-flex;align-items:center;gap:4px;background:var(--bg);border:1px solid var(--border);color:var(--text);text-decoration:none;border-radius:6px;padding:4px 8px;font-size:.75rem;max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +.entry-files a{display:inline-flex;align-items:center;gap:4px;background:var(--bg);border:1px solid var(--border);color:var(--text);text-decoration:none;border-radius:6px;padding:3px 8px;font-size:.75rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0} .entry-files a:hover{border-color:var(--accent);color:var(--accent)} .entry-files a::before{content:'📎'} .f-actions{display:flex;align-items:center;flex-shrink:0} @@ -77,14 +78,14 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;b .view-toggle button:hover{color:var(--text)} .view-toggle button.active{background:var(--accent);color:#fff} .journal-cards{display:grid;grid-template-columns:repeat(4,1fr);gap:16px} -.journal-card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;display:flex;flex-direction:column} +.journal-card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;display:flex;flex-direction:column;position:relative} .journal-card img{width:100%;aspect-ratio:4/3;object-fit:cover;cursor:pointer;display:block;flex-shrink:0} +.group-badge{position:absolute;top:8px;left:8px;z-index:2;max-width:calc(100% - 16px);background:rgba(0,0,0,.55);backdrop-filter:blur(4px);color:#fff;font-size:.72rem;font-weight:600;line-height:1.3;padding:3px 9px;border-radius:999px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} .journal-card .no-photo{aspect-ratio:4/3;background:var(--bg);display:flex;align-items:center;justify-content:center;flex-shrink:0} .journal-card .no-photo svg{width:64%;height:64%;color:#c7cbd0} .journal-card .no-photo svg *{fill:currentColor} .journal-card .body{padding:12px 14px;display:flex;flex-direction:column;gap:6px;flex:1;min-width:0} .journal-card .name{font-weight:600;font-size:.95rem} -.journal-card .group{color:var(--accent);font-size:.8rem} .journal-card .desc{color:var(--muted);font-size:.85rem;line-height:1.4;white-space:pre-wrap;flex:1} .journal-card .foot{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:10px 14px;border-top:1px solid var(--border);color:var(--muted);font-size:.75rem} .journal-card .foot .edit,.journal-card .foot .del{background:none;border:none;color:var(--muted);cursor:pointer;font-size:1rem;padding:4px} @@ -178,9 +179,9 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;b .toast.show{opacity:1} /* --- Фото группы (хронология) --- */ -.group-cover{width:100%;aspect-ratio:16/9;object-fit:cover;border-radius:10px;cursor:pointer;display:block;background:var(--bg)} +.group-cover{width:100%;aspect-ratio:16/9;object-fit:cover;border-radius:10px;display:block;background:var(--bg)} .group-cover:hover{opacity:.9} -.empty-cover{background:var(--bg);border:1px dashed var(--border);display:flex;align-items:center;justify-content:center;color:var(--muted);font-size:1.6rem;cursor:pointer} +.empty-cover{background:var(--bg);border:1px dashed var(--border);display:flex;align-items:center;justify-content:center;color:var(--muted);font-size:1.6rem} .empty-cover:hover{border-color:var(--accent);color:var(--accent)} .photo-btn{background:var(--bg);border:1px solid var(--border);color:var(--accent);border-radius:8px;padding:8px 14px;font-size:.85rem;font-weight:600;cursor:pointer;transition:all .15s} .photo-btn:hover{border-color:var(--accent);opacity:.85} @@ -277,6 +278,7 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;b .dash-card{background:var(--card);border:1px solid var(--border);border-radius:14px;padding:20px;display:flex;flex-direction:column;gap:16px} .dash-card h3{font-size:1rem;font-weight:700;display:flex;align-items:center;gap:9px;margin:0} .dash-card h3 .ic{width:30px;height:30px;border-radius:9px;background:rgba(37,99,235,.08);display:flex;align-items:center;justify-content:center;font-size:.95rem;flex-shrink:0} +.dash-card h3 .ic i,.settings-card .card-head .ic i{width:17px;height:17px;flex-shrink:0} .dash-empty{color:var(--muted);font-size:.82rem;padding:8px 0} .dash-link-row{margin-top:2px;text-align:right} .dash-link-row a{color:var(--accent);text-decoration:none;font-size:.8rem;font-weight:600} @@ -305,6 +307,8 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;b .actions-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:10px} .action-btn{display:flex;flex-direction:column;align-items:center;gap:8px;padding:16px 10px;background:var(--bg);border:1px solid var(--border);border-radius:12px;color:var(--text);text-decoration:none;font-size:.8rem;font-weight:600;transition:all .15s} .action-btn .aic{font-size:1.3rem} +.action-btn .aic i{width:22px;height:22px} +.recent-item .thumb i{width:18px;height:18px} .action-btn:hover{border-color:var(--accent);color:var(--accent);transform:translateY(-2px)} .active-list{display:flex;flex-direction:column;gap:8px} .active-item{display:flex;justify-content:space-between;align-items:center;gap:8px;background:var(--bg);border:1px solid var(--border);border-radius:10px;padding:9px 12px} @@ -357,10 +361,13 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;b #aiSuggestion{font-size:.9rem;line-height:1.5} /* --- AI auto-check --- */ -.ai-badge{display:inline-block;font-size:.68rem;font-weight:600;padding:2px 7px;border-radius:999px;margin-left:6px;vertical-align:middle;background:rgba(37,99,235,.1);color:var(--accent);white-space:nowrap} +.ai-badge{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:999px;margin-left:8px;vertical-align:middle;background:rgba(37,99,235,.1);color:var(--accent);cursor:help;flex-shrink:0} +.ai-badge svg{width:14px;height:14px;display:block} .ai-badge-done{background:rgba(22,163,74,.12);color:#16a34a} .ai-badge-error{background:rgba(239,68,68,.12);color:#ef4444} .ai-badge-skipped,.ai-badge-reverted{background:rgba(148,163,184,.18);color:var(--muted)} +.ai-badge-processing .lucide-loader{animation:spin 1s linear infinite} +@keyframes spin{to{transform:rotate(360deg)}} .ai-status{margin-top:6px;font-size:.78rem;color:var(--muted)} .ai-queue{margin-top:8px;font-size:.78rem;color:var(--muted)} diff --git a/public/admin.js b/public/admin.js index 932dcb9..299583d 100644 --- a/public/admin.js +++ b/public/admin.js @@ -41,20 +41,20 @@ function buildSidebar(active) { const el = document.getElementById('sidebar'); if (!el) return; const base = [ - { page: 'dashboard', label: 'Дашборд' }, - { page: 'journal', label: 'Журнал' }, - { page: 'trash', label: 'Корзина' }, - { page: 'files', label: 'Файлы' }, - { page: 'links', label: 'Ссылки' }, - { page: 'students', label: 'Ученики' }, - { page: 'groups', label: 'Группы' }, + { page: 'dashboard', label: 'Дашборд', icon: 'layout-dashboard' }, + { page: 'journal', label: 'Журнал', icon: 'book-open' }, + { page: 'students', label: 'Ученики', icon: 'graduation-cap' }, + { page: 'groups', label: 'Группы', icon: 'users' }, + { page: 'files', label: 'Файлы', icon: 'folder' }, + { page: 'links', label: 'Ссылки', icon: 'link' }, + { page: 'trash', label: 'Корзина', icon: 'trash-2' }, ]; const adminNav = [ - { page: 'branches', label: 'Филиалы' }, - { page: 'users', label: 'Пользователи' }, - { page: 'audit', label: 'Аудит' }, - { page: 'worker', label: 'Воркер ИИ' }, - { page: 'settings', label: 'Настройки' }, + { page: 'branches', label: 'Филиалы', icon: 'building-2' }, + { page: 'users', label: 'Пользователи', icon: 'user-cog' }, + { page: 'worker', label: 'Воркер ИИ', icon: 'bot' }, + { page: 'audit', label: 'Аудит', icon: 'scroll-text' }, + { page: 'settings', label: 'Настройки', icon: 'settings' }, ]; const nav = [...base, ...(isAdmin() ? adminNav : [])]; const userName = currentUser?.name || currentUser?.username || ''; @@ -66,15 +66,22 @@ function buildSidebar(active) {
${roleLabel}
- На главную - Выйти + На главную + Выйти
`; + renderIcons(); } // --- Common UI --- +function renderIcons() { + if (window.lucide && typeof window.lucide.createIcons === 'function') { + window.lucide.createIcons(); + } +} + function showToast(msg) { const t = document.getElementById('toast'); if (!t) return; diff --git a/public/audit.html b/public/audit.html index 302017e..a3fadc5 100644 --- a/public/audit.html +++ b/public/audit.html @@ -39,6 +39,7 @@
+ diff --git a/public/branches.html b/public/branches.html index 8d10ec2..2289c79 100644 --- a/public/branches.html +++ b/public/branches.html @@ -63,6 +63,7 @@
+