feat(photos): раздел «Фото» — единая галерея всех загруженных фотографий
Новый read-only раздел для просмотра всех фотографий системы:
GET /api/photos собирает через UNION ALL пять источников — главное фото
записи, фото записи (entry_photos), фотохронику групп, фото учеников и фото
тем модулей. Фильтры search/student_name/group_id/date_from/date_to и
пагинация limit/offset, ответ { photos, total }. Не-admin ограничен
своими филиалами (branch_id), чужой group_id отдаёт 403.
Фронтенд: public/photos.html + public/js/photos.js — сетка превью
(/uploads/thumb/...), бейдж источника, описание, ученик/группа, дата,
ссылка на источник, lightbox по клику, поиск с debounce и пагинация.
Навигация: пункт «Фото» в сайдбаре и плитка в быстрых действиях дашборда.
This commit is contained in:
+46
-17
@@ -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}
|
||||
|
||||
+60
-14
@@ -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 ? `<span class="sidebar-badge" id="sidebarNotifyBadge" ${notifyUnread > 0 ? '' : 'hidden'}>${notifyUnread > 99 ? '99+' : notifyUnread}</span>` : '';
|
||||
return `<a href="${n.page}.html" data-nav="${n.page}" class="${isAct ? 'active' : ''}" title="${n.label}">
|
||||
<i data-lucide="${n.icon}"></i>
|
||||
<span class="nav-text">${n.label}</span>
|
||||
${badgeHtml}
|
||||
</a>`;
|
||||
};
|
||||
el.innerHTML = `
|
||||
<div class="logo">
|
||||
<span class="logo-ic" id="sidebarLogo"></span>
|
||||
<span id="sidebarName">Админ-панель</span>
|
||||
</div>
|
||||
<div class="user-box">
|
||||
<div class="user-name">${esc(userName)}</div>
|
||||
<div class="user-role">${roleLabel}</div>
|
||||
<div class="user-avatar"><i data-lucide="${isAdmin() ? 'shield-check' : 'user'}"></i></div>
|
||||
<div class="user-meta">
|
||||
<div class="user-name" title="${esc(userName)}">${esc(userName)}</div>
|
||||
<div class="user-role">${roleLabel}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="nav-scroll-wrap">
|
||||
<nav>
|
||||
<div class="nav-group">
|
||||
<div class="nav-group-title">Основное</div>
|
||||
<div class="nav-items">
|
||||
${base.map(renderItem).join('')}
|
||||
</div>
|
||||
</div>
|
||||
${isAdmin() ? `
|
||||
<div class="nav-group">
|
||||
<div class="nav-group-title">Администрирование</div>
|
||||
<div class="nav-items">
|
||||
${adminNav.map(renderItem).join('')}
|
||||
</div>
|
||||
</div>` : ''}
|
||||
</nav>
|
||||
</div>
|
||||
<nav>
|
||||
${nav.map(n => `<a href="${n.page}.html" data-nav="${n.page}" class="${n.page === active ? 'active' : ''}"><i data-lucide="${n.icon}"></i>${n.label}</a>`).join('')}
|
||||
</nav>
|
||||
<div class="bottom">
|
||||
<div class="version" id="sidebarVersion"></div>
|
||||
<a href="#" class="notify-bell" id="notifyBell" title="Уведомления"><i data-lucide="bell"></i>Уведомления<span class="notify-badge" id="notifyBadge" hidden>0</span></a>
|
||||
<a href="/" data-nav="home"><i data-lucide="home"></i>На главную</a>
|
||||
<a class="logout" href="#" data-action="logout"><i data-lucide="log-out"></i>Выйти</a>
|
||||
<div class="bottom-actions">
|
||||
<a href="#" class="notify-bell" id="notifyBell" title="Быстрые уведомления">
|
||||
<i data-lucide="bell"></i>
|
||||
<span>Уведомления</span>
|
||||
<span class="notify-badge" id="notifyBadge" ${notifyUnread > 0 ? '' : 'hidden'}>${notifyUnread > 99 ? '99+' : notifyUnread}</span>
|
||||
</a>
|
||||
<a href="/" data-nav="home" title="Перейти на главную страницу">
|
||||
<i data-lucide="home"></i>
|
||||
<span>На главную</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="bottom-footer">
|
||||
<a class="logout-btn" href="#" data-action="logout" title="Выйти из аккаунта">
|
||||
<i data-lucide="log-out"></i>
|
||||
<span>Выйти</span>
|
||||
</a>
|
||||
<span class="version" id="sidebarVersion"></span>
|
||||
</div>
|
||||
</div>`;
|
||||
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) {
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
<div class="actions-grid">
|
||||
<a class="action-btn" href="journal.html"><span class="aic"><i data-lucide="book-open"></i></span>Журнал</a>
|
||||
<a class="action-btn" href="files.html"><span class="aic"><i data-lucide="folder"></i></span>Файлы</a>
|
||||
<a class="action-btn" href="photos.html"><span class="aic"><i data-lucide="Image"></i></span>Фото</a>
|
||||
<a class="action-btn" href="groups.html"><span class="aic"><i data-lucide="users"></i></span>Группы</a>
|
||||
<a class="action-btn" href="links.html"><span class="aic"><i data-lucide="link"></i></span>Ссылки</a>
|
||||
<a class="action-btn" href="trash.html"><span class="aic"><i data-lucide="trash-2"></i></span>Корзина</a>
|
||||
|
||||
@@ -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 `
|
||||
<div class="ph-card">
|
||||
<img src="${esc(thumbSrc(url))}" data-img="${esc(url)}" loading="lazy" decoding="async" alt="">
|
||||
<div class="ph-body">
|
||||
<span class="ph-badge">${esc(p.source_label)}</span>
|
||||
<div class="ph-title">${esc(p.title || 'Без описания')}</div>
|
||||
${meta.length ? `<div class="ph-meta">${meta.join(' · ')}</div>` : ''}
|
||||
<div class="ph-time">${new Date(p.created_at).toLocaleString('ru')}</div>
|
||||
${link ? `<a class="ph-link" href="${link}">Открыть источник →</a>` : ''}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
function renderGrid() {
|
||||
const grid = document.getElementById('grid');
|
||||
if (!currentPhotos.length) {
|
||||
grid.innerHTML = '<div class="empty" style="grid-column:1/-1">Фотографий не найдено</div>';
|
||||
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 => `<option value="${esc(n)}">`).join('');
|
||||
studentsLoaded = true;
|
||||
}
|
||||
|
||||
function fillSourceOptions() {
|
||||
if (sourcesLoaded) return;
|
||||
const sel = document.getElementById('sourceFilter');
|
||||
const labels = [];
|
||||
currentPhotos.forEach(p => { if (!labels.includes(p.source_label)) labels.push(p.source_label); });
|
||||
const known = ['Главное фото записи', 'Фото записи', 'Фотохроника группы', 'Фото ученика', 'Тема модуля'];
|
||||
known.concat(labels.filter(l => !known.includes(l))).forEach(label => {
|
||||
const o = document.createElement('option');
|
||||
o.value = label; o.textContent = label;
|
||||
sel.appendChild(o);
|
||||
});
|
||||
sourcesLoaded = true;
|
||||
}
|
||||
|
||||
async function loadPhotos() {
|
||||
const p = new URLSearchParams();
|
||||
const q = document.getElementById('searchInput').value;
|
||||
const sn = document.getElementById('studentFilter').value;
|
||||
const gid = document.getElementById('groupFilter').value;
|
||||
const df = document.getElementById('dateFrom').value;
|
||||
const dt = document.getElementById('dateTo').value;
|
||||
if (q) p.set('search', q);
|
||||
if (sn) p.set('student_name', sn);
|
||||
if (gid) p.set('group_id', gid);
|
||||
if (df) p.set('date_from', df);
|
||||
if (dt) p.set('date_to', dt);
|
||||
p.set('limit', PAGE_SIZE);
|
||||
p.set('offset', (page - 1) * PAGE_SIZE);
|
||||
const res = await fetch(`${API}/api/photos?${p}`, { headers: hdr() });
|
||||
if (!res.ok) {
|
||||
document.getElementById('grid').innerHTML = '<div class="empty" style="grid-column:1/-1">Не удалось загрузить фотографии</div>';
|
||||
return;
|
||||
}
|
||||
const data = await res.json();
|
||||
const srcFilter = document.getElementById('sourceFilter').value;
|
||||
currentPhotos = srcFilter ? data.photos.filter(x => x.source_label === srcFilter) : data.photos;
|
||||
totalPhotos = srcFilter ? currentPhotos.length : data.total;
|
||||
fillSourceOptions();
|
||||
renderGrid();
|
||||
renderPager(document.getElementById('pager'), page, Math.max(1, Math.ceil(totalPhotos / PAGE_SIZE)), goPage);
|
||||
}
|
||||
|
||||
function goPage(p) {
|
||||
page = p;
|
||||
loadPhotos();
|
||||
}
|
||||
|
||||
document.getElementById('studentFilter').addEventListener('change', () => { page = 1; loadPhotos(); });
|
||||
document.getElementById('groupFilter').addEventListener('change', () => { page = 1; loadPhotos(); });
|
||||
document.getElementById('sourceFilter').addEventListener('change', () => { page = 1; loadPhotos(); });
|
||||
document.getElementById('dateFrom').addEventListener('change', () => { page = 1; loadPhotos(); });
|
||||
document.getElementById('dateTo').addEventListener('change', () => { page = 1; loadPhotos(); });
|
||||
document.getElementById('searchInput').addEventListener('input', () => {
|
||||
clearTimeout(searchTimer);
|
||||
searchTimer = setTimeout(() => { page = 1; loadPhotos(); }, 300);
|
||||
});
|
||||
|
||||
document.getElementById('imgModal').addEventListener('click', e => e.currentTarget.classList.remove('open'));
|
||||
|
||||
(async () => {
|
||||
if (await checkAuth()) {
|
||||
buildSidebar('photos');
|
||||
await loadGroupOptions();
|
||||
await loadStudentOptions();
|
||||
loadPhotos();
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,49 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Фото — Админ-панель</title>
|
||||
<link rel="stylesheet" href="admin.css">
|
||||
<style>
|
||||
.ph-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:14px}
|
||||
.ph-card{background:var(--card);border:1px solid var(--border);border-radius:12px;overflow:hidden;display:flex;flex-direction:column;min-width:0}
|
||||
.ph-card img{width:100%;aspect-ratio:4/3;object-fit:cover;display:block;cursor:zoom-in;background:var(--bg);transition:opacity .15s}
|
||||
.ph-card:hover img{opacity:.9}
|
||||
.ph-card .ph-body{padding:10px 12px;display:flex;flex-direction:column;gap:4px;min-width:0}
|
||||
.ph-badge{align-self:flex-start;background:var(--bg);border:1px solid var(--border);color:var(--muted);border-radius:999px;padding:2px 8px;font-size:.68rem;font-weight:700}
|
||||
.ph-title{font-size:.82rem;font-weight:600;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;word-break:break-word}
|
||||
.ph-meta{font-size:.72rem;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.ph-time{font-size:.7rem;color:var(--muted)}
|
||||
.ph-link{font-size:.72rem;color:var(--accent);text-decoration:none}
|
||||
.ph-link:hover{text-decoration:underline}
|
||||
</style>
|
||||
</head>
|
||||
<body data-page="photos">
|
||||
<div class="layout">
|
||||
<div class="sidebar" id="sidebar"></div>
|
||||
<div class="main">
|
||||
<h2>Фото</h2>
|
||||
<div class="filters">
|
||||
<div><label>Поиск</label><input type="text" id="searchInput" class="search-input" placeholder="Описание или имя"></div>
|
||||
<div><label>Ученик</label><input type="text" id="studentFilter" list="studentFilterList" placeholder="Все / введите имя..."><datalist id="studentFilterList"></datalist></div>
|
||||
<div><label>Группа</label><select id="groupFilter"><option value="">Все группы</option></select></div>
|
||||
<div><label>Источник</label><select id="sourceFilter"><option value="">Все источники</option></select></div>
|
||||
<div><label>С</label><input type="date" id="dateFrom"></div>
|
||||
<div><label>По</label><input type="date" id="dateTo"></div>
|
||||
</div>
|
||||
<div class="ph-grid" id="grid"><div class="empty" style="grid-column:1/-1">Загрузка...</div></div>
|
||||
<div class="pager" id="pager"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-overlay" id="imgModal">
|
||||
<img id="imgModalSrc">
|
||||
</div>
|
||||
|
||||
<div class="toast" id="toast"></div>
|
||||
<script src="vendor/lucide.min.js"></script>
|
||||
<script src="admin.js"></script>
|
||||
<script src="js/photos.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user