diff --git a/public/admin.css b/public/admin.css
index c7bb04d..59b8a94 100644
--- a/public/admin.css
+++ b/public/admin.css
@@ -3,26 +3,50 @@
body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;background:var(--bg);color:var(--text);min-height:100dvh}
.layout{display:flex;min-height:100dvh}
-.sidebar{width:var(--sidebar);background:var(--card);border-right:1px solid var(--border);padding:24px 0;position:fixed;top:0;left:0;height:100dvh;display:flex;flex-direction:column}
-.sidebar .logo{font-size:1.1rem;font-weight:700;padding:0 20px 20px;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:10px;min-width:0}
-.sidebar .logo-ic{height:28px;width:auto;min-width:28px;background:var(--bg);border:1px solid var(--border);display:flex;align-items:center;justify-content:center;overflow:hidden;flex-shrink:0}
+.sidebar{width:var(--sidebar);background:var(--card);border-right:1px solid var(--border);position:fixed;top:0;left:0;height:100dvh;display:flex;flex-direction:column;z-index:50;box-shadow:1px 0 0 rgba(0,0,0,.02);user-select:none}
+.sidebar .logo{height:58px;padding:0 16px;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:10px;min-width:0;flex-shrink:0;font-size:1.02rem;font-weight:700;letter-spacing:-.01em;background:var(--card)}
+.sidebar .logo-ic{height:28px;width:auto;min-width:28px;border-radius:6px;background:var(--bg);border:1px solid var(--border);display:flex;align-items:center;justify-content:center;overflow:hidden;flex-shrink:0}
.sidebar .logo-ic img{max-width:100%;max-height:100%;object-fit:contain}
.sidebar #sidebarName{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
-.user-box{padding:14px 20px;border-bottom:1px solid var(--border);display:flex;flex-direction:column;gap:2px}
-.user-box .user-name{font-weight:600;font-size:.9rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
-.user-box .user-role{color:var(--muted);font-size:.72rem}
-.sidebar nav{flex:1;padding:12px 0}
-.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}
+.user-box{padding:10px 14px;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:10px;flex-shrink:0;background:var(--card)}
+.user-box .user-avatar{width:32px;height:32px;border-radius:8px;background:rgba(37,99,235,.08);color:var(--accent);display:flex;align-items:center;justify-content:center;flex-shrink:0}
+.user-box .user-avatar svg{width:16px;height:16px}
+.user-box .user-meta{display:flex;flex-direction:column;min-width:0;flex:1}
+.user-box .user-name{font-weight:600;font-size:.85rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text);line-height:1.25}
+.user-box .user-role{color:var(--muted);font-size:.7rem;font-weight:500;line-height:1.2}
+
+.nav-scroll-wrap{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;padding:8px 0;scrollbar-width:thin;scrollbar-color:rgba(0,0,0,.15) transparent}
+.nav-scroll-wrap::-webkit-scrollbar{width:5px}
+.nav-scroll-wrap::-webkit-scrollbar-track{background:transparent}
+.nav-scroll-wrap::-webkit-scrollbar-thumb{background:rgba(0,0,0,.12);border-radius:10px}
+.nav-scroll-wrap::-webkit-scrollbar-thumb:hover{background:rgba(0,0,0,.22)}
+
+.sidebar nav{display:flex;flex-direction:column;gap:10px;padding:0 8px}
+.nav-group{display:flex;flex-direction:column;gap:2px}
+.nav-group-title{font-size:.66rem;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);padding:6px 10px 4px;user-select:none;opacity:.8}
+.nav-items{display:flex;flex-direction:column;gap:1px}
+
+.sidebar nav a{display:flex;align-items:center;gap:10px;padding:7px 10px;border-radius:8px;color:var(--muted);text-decoration:none;font-size:.84rem;font-weight:500;line-height:1.3;transition:all .14s ease;position:relative}
.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 nav a.active{color:var(--accent);background:rgba(37,99,235,.08);font-weight:600}
+.sidebar nav a.active::before{content:'';position:absolute;left:0;top:6px;bottom:6px;width:3px;border-radius:0 3px 3px 0;background:var(--accent)}
+.sidebar nav a i,.sidebar .bottom a i{width:16px;height:16px;flex-shrink:0;transition:transform .14s ease}
+.sidebar nav a:hover i{transform:scale(1.06)}
+.sidebar nav a .nav-text{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
+
+.sidebar-badge{min-width:18px;height:18px;padding:0 6px;border-radius:999px;background:#ef4444;color:#fff;font-size:.65rem;font-weight:700;line-height:18px;text-align:center;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;margin-left:auto;box-shadow:0 1px 3px rgba(239,68,68,.35)}
+.sidebar-badge[hidden]{display:none}
+
.sidebar nav a[data-nav=dashboard] svg{color:#6366f1}
.sidebar nav a[data-nav=journal] svg{color:#0ea5e9}
+.sidebar nav a[data-nav=notifications] svg{color:#f59e0b}
.sidebar nav a[data-nav=students] svg{color:#14b8a6}
.sidebar nav a[data-nav=groups] svg{color:#8b5cf6}
.sidebar nav a[data-nav=files] svg{color:#f59e0b}
+.sidebar nav a[data-nav=photos] svg{color:#0891b2}
.sidebar nav a[data-nav=links] svg{color:#06b6d4}
.sidebar nav a[data-nav=trash] svg{color:#ef4444}
+.sidebar nav a[data-nav=modules] svg{color:#3b82f6}
.sidebar nav a[data-nav=branches] svg{color:#10b981}
.sidebar nav a[data-nav=users] svg{color:#ec4899}
.sidebar nav a[data-nav=worker] svg{color:#a855f7}
@@ -30,12 +54,18 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;b
.sidebar nav a[data-nav=bans] svg{color:#dc2626}
.sidebar nav a[data-nav=settings] svg{color:#475569}
.sidebar nav a.active svg{color:var(--accent)}
-.sidebar .bottom a[data-nav=home] svg{color:#2563eb}
-.sidebar .bottom{padding:12px 20px;border-top:1px solid var(--border)}
-.sidebar .version{color:var(--muted);font-size:.72rem;padding:0 20px 8px}
-.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}
+
+.sidebar .bottom{padding:10px 10px 12px;border-top:1px solid var(--border);display:flex;flex-direction:column;gap:8px;flex-shrink:0;background:var(--card)}
+.sidebar .bottom-actions{display:flex;flex-direction:column;gap:1px}
+.sidebar .bottom-actions a{display:flex;align-items:center;gap:10px;padding:6px 10px;border-radius:8px;color:var(--muted);text-decoration:none;font-size:.82rem;font-weight:500;transition:all .14s ease;position:relative}
+.sidebar .bottom-actions a:hover{color:var(--text);background:var(--bg)}
+.sidebar .bottom-actions a[data-nav=home] svg{color:#2563eb}
+.sidebar .bottom-actions .notify-bell svg{color:#f59e0b}
+.sidebar .bottom-footer{display:flex;align-items:center;justify-content:space-between;gap:8px;padding-top:6px;border-top:1px dashed var(--border)}
+.sidebar .bottom-footer .logout-btn{display:inline-flex;align-items:center;gap:6px;padding:4px 8px;border-radius:6px;color:#ef4444;text-decoration:none;font-size:.78rem;font-weight:600;cursor:pointer;transition:background .14s ease}
+.sidebar .bottom-footer .logout-btn:hover{background:rgba(239,68,68,.08)}
+.sidebar .bottom-footer .logout-btn svg{width:14px;height:14px;color:#ef4444}
+.sidebar .bottom-footer .version{color:var(--muted);font-size:.7rem;font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;opacity:.8}
.main{flex:1;margin-left:var(--sidebar);padding:32px}
.main h2{font-size:1.3rem;font-weight:600;margin-bottom:20px}
@@ -569,7 +599,6 @@ body[data-page=settings] .page-head{align-items:flex-end}
@media (prefers-reduced-motion: reduce){.save-bar{animation:none}.toggle-track,.toggle-thumb{transition:none}.icon-btn.spinning svg{animation:none}}
/* --- Notifications --- */
-.sidebar nav a[data-nav=notifications] svg{color:#f59e0b}
.notify-bell{position:relative}
.notify-badge{position:absolute;left:20px;top:-3px;min-width:16px;height:16px;padding:0 4px;border-radius:999px;background:#ef4444;color:#fff;font-size:.62rem;font-weight:700;line-height:16px;text-align:center}
.notify-badge[hidden]{display:none}
diff --git a/public/admin.js b/public/admin.js
index c9a0620..009201e 100644
--- a/public/admin.js
+++ b/public/admin.js
@@ -49,9 +49,10 @@ function buildSidebar(active) {
const base = [
{ page: 'dashboard', label: 'Дашборд', icon: 'layout-dashboard' },
{ page: 'journal', label: 'Журнал', icon: 'book-open' },
- { page: 'notifications', label: 'Уведомления', icon: 'bell' },
+ { page: 'notifications', label: 'Уведомления', icon: 'bell', badge: true },
{ page: 'students', label: 'Ученики', icon: 'graduation-cap' },
{ page: 'groups', label: 'Группы', icon: 'users' },
+ { page: 'photos', label: 'Фото', icon: 'Image' },
{ page: 'files', label: 'Файлы', icon: 'folder' },
{ page: 'links', label: 'Ссылки', icon: 'link' },
{ page: 'trash', label: 'Корзина', icon: 'trash-2' },
@@ -65,26 +66,65 @@ function buildSidebar(active) {
{ page: 'bans', label: 'Блокировки', icon: 'shield-off' },
{ page: 'settings', label: 'Настройки', icon: 'settings' },
];
- const nav = [...base, ...(isAdmin() ? adminNav : [])];
const userName = currentUser?.name || currentUser?.username || '';
const roleLabel = isAdmin() ? 'Администратор' : 'Тутор';
+ const renderItem = n => {
+ const isAct = n.page === active;
+ const badgeHtml = n.badge ? `` : '';
+ return `
+
+ ${n.label}
+ ${badgeHtml}
+ `;
+ };
el.innerHTML = `
-
${esc(userName)}
-
${roleLabel}
+
+
+
+
-
`;
renderIcons();
loadVersion();
@@ -162,9 +202,15 @@ function notifyTime(ts) {
function setNotifyUnread(n) {
notifyUnread = Number(n) || 0;
const badge = document.getElementById('notifyBadge');
- if (!badge) return;
- badge.textContent = notifyUnread > 99 ? '99+' : String(notifyUnread);
- badge.hidden = notifyUnread <= 0;
+ if (badge) {
+ badge.textContent = notifyUnread > 99 ? '99+' : String(notifyUnread);
+ badge.hidden = notifyUnread <= 0;
+ }
+ const navBadge = document.getElementById('sidebarNotifyBadge');
+ if (navBadge) {
+ navBadge.textContent = notifyUnread > 99 ? '99+' : String(notifyUnread);
+ navBadge.hidden = notifyUnread <= 0;
+ }
}
function notifyItemHtml(n, expanded) {
diff --git a/public/dashboard.html b/public/dashboard.html
index 97d610c..4bf81b1 100644
--- a/public/dashboard.html
+++ b/public/dashboard.html
@@ -41,6 +41,7 @@
Журнал
Файлы
+
Фото
Группы
Ссылки
Корзина
diff --git a/public/js/photos.js b/public/js/photos.js
new file mode 100644
index 0000000..30a78bc
--- /dev/null
+++ b/public/js/photos.js
@@ -0,0 +1,144 @@
+const PAGE_SIZE = 24;
+let page = 1;
+let totalPhotos = 0;
+let currentPhotos = [];
+let groupsLoaded = false;
+let studentsLoaded = false;
+let sourcesLoaded = false;
+let searchTimer = null;
+
+function humanSize(b) {
+ if (!b) return '';
+ if (b < 1024) return b + ' Б';
+ if (b < 1048576) return (b / 1024).toFixed(1) + ' КБ';
+ return (b / 1048576).toFixed(1) + ' МБ';
+}
+
+function photoLink(p) {
+ if (p.source_type === 'entry') return `journal.html#entry-${p.source_id}`;
+ if (p.source_type === 'entry_photo') return `journal.html#entry-${p.source_id}`;
+ if (p.source_type === 'group_photo') return 'groups.html';
+ if (p.source_type === 'student_photo') return 'students.html';
+ if (p.source_type === 'module_photo') return 'modules.html';
+ return '';
+}
+
+function photoCardHTML(p) {
+ const url = p.path;
+ const meta = [];
+ if (p.student_name) meta.push(esc(p.student_name));
+ if (p.group_name) meta.push(esc(p.group_name));
+ const link = photoLink(p);
+ return `
+
+
)})
+
+
${esc(p.source_label)}
+
${esc(p.title || 'Без описания')}
+ ${meta.length ? `
${meta.join(' · ')}
` : ''}
+
${new Date(p.created_at).toLocaleString('ru')}
+ ${link ? `
Открыть источник →` : ''}
+
+
+ `;
+}
+
+function renderGrid() {
+ const grid = document.getElementById('grid');
+ if (!currentPhotos.length) {
+ grid.innerHTML = '
Фотографий не найдено
';
+ return;
+ }
+ grid.innerHTML = currentPhotos.map(photoCardHTML).join('');
+}
+
+async function loadGroupOptions() {
+ if (groupsLoaded) return;
+ const sel = document.getElementById('groupFilter');
+ while (sel.options.length > 1) sel.remove(1);
+ const res = await fetch(`${API}/api/groups`, { headers: hdr() });
+ const groups = await res.json();
+ groups.forEach(g => {
+ const o = document.createElement('option');
+ o.value = g.id; o.textContent = g.name;
+ sel.appendChild(o);
+ });
+ groupsLoaded = true;
+}
+
+async function loadStudentOptions() {
+ if (studentsLoaded) return;
+ const dl = document.getElementById('studentFilterList');
+ const res = await fetch(`${API}/api/students/names`, { headers: hdr() });
+ const names = await res.json();
+ dl.innerHTML = names.map(n => `