'use strict'; /* admin → overview (Phase 3 dashboard) — landing page "что требует внимания". * Lazy-init via AdminSections.overview.init(); reloads via .reload(). */ (function () { 'use strict'; let inited = false; /* ── one-time CSS injection (overview-specific bento layout) ────────── */ function ensureOvStyles() { if (document.getElementById('ov-style')) return; const s = document.createElement('style'); s.id = 'ov-style'; s.textContent = ` .ov-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; } .ov-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 22px 20px; position: relative; overflow: hidden; } .ov-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--ov-top, var(--violet)); opacity: 0.7; } .ov-card-icon { width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; background: rgba(155,93,229,0.1); color: var(--violet); } .ov-card-val { font-family: 'Unbounded', sans-serif; font-size: 1.9rem; font-weight: 800; line-height: 1.1; margin-bottom: 4px; } .ov-card-label { font-size: 0.82rem; color: var(--text-3); font-weight: 600; } .ov-card.warn { border-color: rgba(255,179,71,0.4); } .ov-card.warn::before { background: var(--amber); } .ov-card.warn .ov-card-icon { background: rgba(255,179,71,0.12); color: var(--amber); } .ov-card.danger { border-color: rgba(241,91,181,0.35); } .ov-card.danger::before { background: var(--pink); } .ov-card.danger .ov-card-icon { background: rgba(241,91,181,0.1); color: var(--pink); } .ov-section-title { font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); margin: 28px 0 12px; } .ov-banned-list { display: flex; flex-direction: column; gap: 6px; } .ov-banned-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: rgba(241,91,181,0.06); border: 1px solid rgba(241,91,181,0.18); border-radius: 10px; font-size: 0.86rem; } .ov-banned-row .ov-bn-name { font-weight: 600; } .ov-banned-row .ov-bn-email { color: var(--text-3); font-size: 0.78rem; } .ov-banned-row .ov-bn-date { margin-left: auto; color: var(--text-3); font-size: 0.76rem; } .ov-top-table { width: 100%; border-collapse: collapse; } .ov-top-table th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--border); } .ov-top-table td { padding: 10px; font-size: 0.86rem; border-bottom: 1px solid var(--border); } .ov-top-table tr:last-child td { border-bottom: none; } .ov-pct { font-family: 'Unbounded', sans-serif; font-weight: 700; } .ov-pct.hi { color: var(--green); } .ov-pct.mid { color: var(--amber); } .ov-pct.lo { color: var(--pink); } .ov-quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; } .ov-quick-btn { display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; cursor: pointer; font-family: inherit; font-size: 0.88rem; font-weight: 600; color: var(--text); text-align: left; transition: background .12s, border-color .12s, transform .12s; } .ov-quick-btn:hover { background: rgba(155,93,229,0.06); border-color: rgba(155,93,229,0.3); color: var(--violet); transform: translateY(-1px); } .ov-quick-btn svg { width: 16px; height: 16px; flex-shrink: 0; } .ov-empty { padding: 18px; text-align: center; color: var(--text-3); font-size: 0.85rem; } `; document.head.appendChild(s); } function pctClassNum(p) { if (p === null || p === undefined) return ''; return p >= 75 ? 'hi' : p >= 50 ? 'mid' : 'lo'; } function fmtNum(n) { return (n === 0 || n === null || n === undefined) ? '—' : String(n); } function fmtBannedDate(s) { if (!s) return ''; try { const d = new Date(s.replace(' ', 'T') + 'Z'); return d.toLocaleDateString('ru', { day: 'numeric', month: 'short' }); } catch { return ''; } } function fmtFinished(s) { if (!s) return '—'; try { const d = new Date(s.replace(' ', 'T') + 'Z'); return d.toLocaleString('ru', { day: 'numeric', month: 'short', hour: '2-digit', minute: '2-digit' }); } catch { return s; } } function navigateTo(hash) { if (window.AdminRouter) AdminRouter.navigate(hash); else window.location.hash = hash; } function render(data) { const el = document.getElementById('overview-content'); if (!el) return; ensureOvStyles(); const e = LS.esc; const failedCls = data.failedSessions24h > 0 ? 'warn' : ''; const bannedCount = Array.isArray(data.bannedThisWeek) ? data.bannedThisWeek.length : 0; const top = Array.isArray(data.topSessions24h) ? data.topSessions24h : []; let alertsHtml = ''; if (bannedCount > 0 || data.failedSessions24h > 0) { const banned = bannedCount > 0 ? `
| Ученик | Предмет | Счёт | % | Завершён |
|---|---|---|---|---|
| ${e(s.user_name || '—')} | ${e(s.subject_name || '—')} | ${s.score ?? 0} / ${s.total ?? 0} | ${s.percent ?? '—'}% | ${fmtFinished(s.finished_at)} |