feat: WebSocket real-time + rAF render gate + guest board + screen picker
Classroom performance: - WebSocket server (ws-server.js) for low-latency cursor & stroke preview Replaces HTTP POST per event → eliminates per-message auth overhead Session member cache (30s TTL) avoids SQLite query per WS message Fallback to HTTP POST when WS not connected - Cursor throttle reduced 100ms → 33ms (~30fps) - Stroke preview throttle reduced 50ms → 20ms - whiteboard.js: render() is now rAF-gated (_doRender/_rafPending) Multiple render() calls within one frame collapse into one repaint document.hidden check — zero CPU when tab is in background visibilitychange listener restores canvas on tab focus Guest board: - guestClassroom.js route: public token-based read-only access - guest-board.html: name entry + read-only whiteboard + SSE - SSE: addGuestClient/removeGuestClient/emitToGuests Screen share picker: - Discord-style modal with tab switching (screen/window/tab) - Live video preview before confirming share - useExistingScreenStream() in ClassroomRTC Fullscreen exit overlay: - #cr-fs-exit-overlay button inside cr-board-wrap - Visible only via CSS :fullscreen selector (touchpad users) File sharing from library: - Teacher picks file from library, sends as styled card in chat - crDownloadLibraryFile() fetches with Bearer auth Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -709,6 +709,124 @@
|
||||
}
|
||||
.sl-filter-select:focus { border-color: var(--violet); outline: none; }
|
||||
.sl-count { font-size: 0.78rem; color: #8898AA; font-weight: 600; }
|
||||
|
||||
/* ══════════ CLASSROOM ADMIN TAB ══════════ */
|
||||
.cr-admin-section { margin-bottom: 40px; }
|
||||
.cr-admin-section-title {
|
||||
font-family: 'Unbounded', sans-serif; font-size: 0.82rem; font-weight: 800;
|
||||
color: var(--text-3); text-transform: uppercase; letter-spacing: 0.07em;
|
||||
margin-bottom: 16px; display: flex; align-items: center; gap: 10px;
|
||||
}
|
||||
.cr-admin-section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
|
||||
|
||||
/* Active session card */
|
||||
.cr-live-list { display: flex; flex-direction: column; gap: 10px; }
|
||||
.cr-live-card {
|
||||
display: flex; align-items: center; gap: 14px;
|
||||
background: var(--surface); border: 1.5px solid var(--border);
|
||||
border-left: 4px solid #EF4444; border-radius: 16px;
|
||||
padding: 14px 18px; transition: box-shadow 0.15s, transform 0.15s;
|
||||
}
|
||||
.cr-live-card:hover { box-shadow: 0 4px 20px rgba(15,23,42,0.1); transform: translateX(2px); }
|
||||
.cr-live-pulse {
|
||||
width: 10px; height: 10px; border-radius: 50%; background: #EF4444; flex-shrink: 0;
|
||||
animation: pulse-live 1.4s ease-in-out infinite;
|
||||
}
|
||||
@keyframes pulse-live {
|
||||
0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.5); }
|
||||
50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
|
||||
}
|
||||
.cr-live-info { flex: 1; min-width: 0; }
|
||||
.cr-live-title { font-size: 0.96rem; font-weight: 700; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.cr-live-meta { font-size: 0.81rem; color: var(--text-3); }
|
||||
.cr-live-badges { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }
|
||||
.cr-badge {
|
||||
display: inline-flex; align-items: center; gap: 5px;
|
||||
padding: 4px 10px; border-radius: 99px; font-size: 0.76rem; font-weight: 700;
|
||||
}
|
||||
.cr-badge-online { background: rgba(6,214,100,0.12); color: #059652; }
|
||||
.cr-badge-msgs { background: rgba(6,214,224,0.12); color: #05aab3; }
|
||||
.cr-badge-dur { background: rgba(155,93,229,0.1); color: var(--violet); }
|
||||
.cr-live-actions { display: flex; gap: 6px; flex-shrink: 0; }
|
||||
|
||||
/* History session row */
|
||||
.cr-hist-list { display: flex; flex-direction: column; gap: 8px; }
|
||||
.cr-hist-row {
|
||||
display: flex; align-items: center; gap: 14px;
|
||||
background: var(--surface); border: 1px solid var(--border);
|
||||
border-radius: 14px; padding: 12px 16px; cursor: pointer;
|
||||
transition: border-color 0.15s, box-shadow 0.15s;
|
||||
}
|
||||
.cr-hist-row:hover { border-color: var(--violet); box-shadow: 0 2px 12px rgba(109,40,217,0.07); }
|
||||
.cr-hist-row.open { border-color: var(--violet); background: rgba(155,93,229,0.03); border-radius: 14px 14px 0 0; border-bottom: none; }
|
||||
.cr-hist-icon { width: 38px; height: 38px; border-radius: 10px; background: rgba(155,93,229,0.1); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
|
||||
.cr-hist-main { flex: 1; min-width: 0; }
|
||||
.cr-hist-title { font-size: 0.94rem; font-weight: 700; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.cr-hist-meta { font-size: 0.79rem; color: var(--text-3); }
|
||||
.cr-hist-chips { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
|
||||
.cr-hist-chevron { width: 18px; height: 18px; color: var(--text-3); transition: transform 0.2s; flex-shrink: 0; }
|
||||
.cr-hist-row.open .cr-hist-chevron { transform: rotate(180deg); color: var(--violet); }
|
||||
|
||||
/* Session detail drawer */
|
||||
.cr-detail-drawer {
|
||||
overflow: hidden; max-height: 0; transition: max-height 0.35s ease;
|
||||
border: 1px solid var(--violet); border-top: none;
|
||||
border-radius: 0 0 14px 14px; background: rgba(238,242,255,0.5);
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.cr-detail-drawer.open { max-height: 3000px; margin-bottom: 8px; }
|
||||
.cr-detail-inner { padding: 20px 24px; }
|
||||
.cr-detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
|
||||
@media(max-width:700px) { .cr-detail-grid { grid-template-columns: repeat(2, 1fr); } }
|
||||
.cr-detail-stat {
|
||||
background: #fff; border: 1px solid var(--border); border-radius: 12px;
|
||||
padding: 14px 16px; text-align: center;
|
||||
}
|
||||
.cr-detail-val { font-family: 'Unbounded', sans-serif; font-size: 1.3rem; font-weight: 800; color: var(--violet); margin-bottom: 4px; }
|
||||
.cr-detail-label { font-size: 0.72rem; color: var(--text-3); font-weight: 700; text-transform: uppercase; }
|
||||
.cr-attend-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
|
||||
.cr-attend-row {
|
||||
display: flex; align-items: center; gap: 12px; padding: 8px 12px;
|
||||
border: 1px solid var(--border); border-radius: 10px; background: #fff;
|
||||
font-size: 0.88rem;
|
||||
}
|
||||
.cr-attend-name { flex: 1; font-weight: 600; }
|
||||
.cr-attend-time { color: var(--text-3); font-size: 0.8rem; }
|
||||
.cr-attend-dur { color: var(--cyan); font-weight: 700; font-size: 0.8rem; min-width: 60px; text-align: right; }
|
||||
.cr-pages-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: 8px; margin-top: 10px; }
|
||||
.cr-page-chip {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
background: #fff; border: 1px solid var(--border); border-radius: 8px;
|
||||
padding: 8px 12px; font-size: 0.82rem;
|
||||
}
|
||||
.cr-page-num { font-weight: 700; color: var(--violet); }
|
||||
.cr-page-cnt { color: var(--text-3); font-size: 0.76rem; }
|
||||
.cr-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
|
||||
.btn-cr-export { padding: 8px 18px; border: 1.5px solid var(--cyan); border-radius: 99px; background: rgba(6,214,224,0.06); color: #05aab3; font-family:'Manrope',sans-serif; font-size:0.82rem; font-weight:700; cursor:pointer; transition: all 0.15s; }
|
||||
.btn-cr-export:hover { background: rgba(6,214,224,0.15); }
|
||||
.btn-cr-del { padding: 8px 18px; border: 1.5px solid rgba(241,91,181,0.4); border-radius: 99px; background: transparent; color: var(--pink); font-family:'Manrope',sans-serif; font-size:0.82rem; font-weight:700; cursor:pointer; transition: all 0.15s; }
|
||||
.btn-cr-del:hover { background: rgba(241,91,181,0.08); border-color: var(--pink); }
|
||||
.btn-cr-end { padding: 8px 18px; border: none; border-radius: 99px; background: #EF4444; color: #fff; font-family:'Manrope',sans-serif; font-size:0.82rem; font-weight:700; cursor:pointer; transition: opacity 0.15s; }
|
||||
.btn-cr-end:hover { opacity: 0.85; }
|
||||
|
||||
/* Pagination */
|
||||
.cr-pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 24px; flex-wrap: wrap; }
|
||||
.cr-page-btn {
|
||||
min-width: 36px; height: 36px; padding: 0 12px; border: 1.5px solid var(--border);
|
||||
border-radius: 10px; background: var(--surface); font-family:'Manrope',sans-serif;
|
||||
font-size:0.85rem; font-weight:700; color:var(--text-2); cursor:pointer; transition:all 0.14s;
|
||||
display:flex; align-items:center; justify-content:center;
|
||||
}
|
||||
.cr-page-btn:hover:not(:disabled) { border-color:var(--violet); color:var(--violet); }
|
||||
.cr-page-btn.active { background:var(--violet); border-color:var(--violet); color:#fff; }
|
||||
.cr-page-btn:disabled { opacity:0.4; cursor:default; }
|
||||
.cr-page-info { font-size:0.82rem; color:var(--text-3); font-weight:600; }
|
||||
|
||||
/* toolbar for classroom history */
|
||||
.cr-hist-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
|
||||
.cr-hist-search { flex: 1; min-width: 180px; padding: 9px 14px; border: 1.5px solid var(--border-h); border-radius: var(--r-pill); font-family:'Manrope',sans-serif; font-size:0.88rem; background:var(--surface); color:var(--text); }
|
||||
.cr-hist-search:focus { outline:none; border-color:var(--violet); }
|
||||
.cr-hist-count { font-size:0.85rem; color:var(--text-3); font-weight:600; white-space:nowrap; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -733,6 +851,7 @@
|
||||
<a href="/knowledge-map" class="sb-link"><i data-lucide="share-2" class="sb-icon"></i><span class="sb-lbl">Карта знаний</span></a>
|
||||
<a href="/red-book.html" class="sb-link"><i data-lucide="leaf" class="sb-icon"></i><span class="sb-lbl">Красная книга</span></a>
|
||||
<a href="/classroom" class="sb-link"><i data-lucide="presentation" class="sb-icon"></i><span class="sb-lbl">Онлайн-урок</span></a>
|
||||
<a href="/lesson-history" class="sb-link"><i data-lucide="archive" class="sb-icon"></i><span class="sb-lbl">Архив уроков</span></a>
|
||||
<div class="sb-divider"></div>
|
||||
<span class="sb-link active"><i data-lucide="settings" class="sb-icon"></i><span class="sb-lbl">Управление</span></span>
|
||||
</nav>
|
||||
@@ -762,6 +881,9 @@
|
||||
<button class="admin-nav-item" data-tab="sessions" onclick="switchTab(this)">
|
||||
<i data-lucide="clock" style="width:15px;height:15px"></i> История сессий
|
||||
</button>
|
||||
<button class="admin-nav-item" data-tab="classroom" onclick="switchTab(this)">
|
||||
<i data-lucide="video" style="width:15px;height:15px"></i> Онлайн-уроки
|
||||
</button>
|
||||
|
||||
<div class="admin-nav-sep"></div>
|
||||
<div class="admin-nav-label">Контент</div>
|
||||
@@ -967,6 +1089,51 @@
|
||||
<div id="t-body"><div class="spinner"></div></div>
|
||||
</div>
|
||||
|
||||
<!-- ── Онлайн-уроки ── -->
|
||||
<div class="tab-pane" id="tab-classroom">
|
||||
|
||||
<!-- Module master toggle -->
|
||||
<div style="display:flex;align-items:center;justify-content:space-between;background:var(--surface);border:1.5px solid var(--border-h);border-radius:var(--r-lg);padding:20px 24px;margin-bottom:32px">
|
||||
<div>
|
||||
<div style="font-size:0.97rem;font-weight:700;margin-bottom:4px">Модуль онлайн-уроков</div>
|
||||
<div class="perm-desc" style="margin:0">Если отключить, учителя не смогут создавать новые уроки. Уже активные сессии продолжат работу до завершения.</div>
|
||||
</div>
|
||||
<label class="perm-toggle" id="cr-master-lbl" title="Включить / выключить модуль" style="margin-left:24px;flex-shrink:0">
|
||||
<input type="checkbox" id="cr-master-chk" onchange="crMasterToggle(this.checked)" checked />
|
||||
<span class="perm-track"></span>
|
||||
<span class="perm-thumb"></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- Active sessions -->
|
||||
<div class="cr-admin-section">
|
||||
<div class="cr-admin-section-title">
|
||||
<svg class="ic" viewBox="0 0 24 24" style="width:14px;height:14px"><circle cx="12" cy="12" r="10"/><polygon points="10 8 16 12 10 16 10 8"/></svg>
|
||||
Активные уроки
|
||||
<span id="cr-live-refresh-btn" style="font-size:0.76rem;font-weight:600;color:var(--violet);cursor:pointer;text-transform:none;letter-spacing:0;margin-left:-4px" onclick="loadCrActiveSessions()">
|
||||
<svg class="ic" viewBox="0 0 24 24" style="width:12px;height:12px;vertical-align:-2px"><polyline points="23 4 23 10 17 10"/><polyline points="1 20 1 14 7 14"/><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/></svg>
|
||||
Обновить
|
||||
</span>
|
||||
</div>
|
||||
<div id="cr-live-list"><div class="spinner"></div></div>
|
||||
</div>
|
||||
|
||||
<!-- Session history -->
|
||||
<div class="cr-admin-section">
|
||||
<div class="cr-admin-section-title">
|
||||
<svg class="ic" viewBox="0 0 24 24" style="width:14px;height:14px"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
|
||||
История уроков
|
||||
</div>
|
||||
<div class="cr-hist-toolbar">
|
||||
<input class="cr-hist-search" id="cr-hist-q" type="text" placeholder="Поиск по теме или учителю…" oninput="crHistDebounce()">
|
||||
<span class="cr-hist-count" id="cr-hist-count"></span>
|
||||
</div>
|
||||
<div id="cr-hist-list"><div class="spinner"></div></div>
|
||||
<div id="cr-hist-pagination"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- ── Права доступа ── -->
|
||||
<div class="tab-pane" id="tab-permissions">
|
||||
<div class="perm-header">
|
||||
@@ -4321,9 +4488,13 @@
|
||||
{ id: 'magnetic', cat: 'Физика', title: 'Магнитное поле токов' },
|
||||
{ id: 'circuit', cat: 'Физика', title: 'Электрические цепи' },
|
||||
{ id: 'coulomb', cat: 'Физика', title: 'Закон Кулона' },
|
||||
{ id: 'hydrostatics', cat: 'Физика', title: 'Гидростатика' },
|
||||
{ id: 'dynamics', cat: 'Физика', title: 'Динамика' },
|
||||
{ id: 'thinlens', cat: 'Физика', title: 'Тонкая линза' },
|
||||
{ id: 'refraction', cat: 'Физика', title: 'Преломление света' },
|
||||
{ id: 'mirrors', cat: 'Физика', title: 'Зеркала' },
|
||||
{ id: 'isoprocess', cat: 'Физика', title: 'Изопроцессы' },
|
||||
{ id: 'waves', cat: 'Физика', title: 'Волны и звук' },
|
||||
{ id: 'molphys', cat: 'Химия', title: 'Молекулярная физика' },
|
||||
{ id: 'chemistry', cat: 'Химия', title: 'Химические реакции' },
|
||||
{ id: 'equilibrium', cat: 'Химия', title: 'Химическое равновесие' },
|
||||
@@ -4814,6 +4985,260 @@
|
||||
} catch (e) { el.innerHTML = `<div style="color:var(--pink)">${esc(e.message)}</div>`; }
|
||||
}
|
||||
|
||||
/* ════════════════════════════════════════════════
|
||||
ОНЛАЙН-УРОКИ (classroom admin)
|
||||
════════════════════════════════════════════════ */
|
||||
let _crHistPage = 1, _crHistTotal = 0, _crHistPages = 0, _crHistSearch = '';
|
||||
let _crOpenDetailId = null, _crHistDebTimer = null;
|
||||
|
||||
async function loadCrModuleState() {
|
||||
try {
|
||||
const features = await LS.api('/api/admin/features');
|
||||
const chk = document.getElementById('cr-master-chk');
|
||||
if (chk) chk.checked = features.classroom !== false;
|
||||
} catch(e) { /* silent */ }
|
||||
}
|
||||
|
||||
async function crMasterToggle(enabled) {
|
||||
try {
|
||||
await LS.api('/api/admin/features', { method: 'PATCH', body: JSON.stringify({ classroom: enabled }) });
|
||||
LS.toast(enabled ? 'Модуль онлайн-уроков включён' : 'Модуль онлайн-уроков отключён', enabled ? 'success' : 'warning', 3000);
|
||||
} catch(e) {
|
||||
LS.toast('Ошибка: ' + e.message, 'error');
|
||||
// revert checkbox
|
||||
const chk = document.getElementById('cr-master-chk');
|
||||
if (chk) chk.checked = !enabled;
|
||||
}
|
||||
}
|
||||
|
||||
function fmtDuration(sec) {
|
||||
if (!sec || sec < 0) return '—';
|
||||
const h = Math.floor(sec / 3600), m = Math.floor((sec % 3600) / 60), s = sec % 60;
|
||||
if (h) return `${h}ч ${m}м`;
|
||||
if (m) return `${m} мин ${s} сек`;
|
||||
return `${s} сек`;
|
||||
}
|
||||
function fmtLiveDuration(createdAt) {
|
||||
const sec = Math.round((Date.now() - new Date(createdAt).getTime()) / 1000);
|
||||
return fmtDuration(sec);
|
||||
}
|
||||
|
||||
async function loadCrActiveSessions() {
|
||||
const el = document.getElementById('cr-live-list');
|
||||
try {
|
||||
const { sessions } = await LS.api('/api/classroom/admin/active');
|
||||
if (!sessions.length) {
|
||||
el.innerHTML = '<div class="empty">Нет активных уроков</div>';
|
||||
return;
|
||||
}
|
||||
el.innerHTML = sessions.map(s => {
|
||||
const dur = fmtLiveDuration(s.created_at);
|
||||
const title = s.title || `Урок #${s.id}`;
|
||||
const cls = s.class_name ? `Класс: ${esc(s.class_name)}` : 'Личный урок';
|
||||
return `<div class="cr-live-card">
|
||||
<div class="cr-live-pulse"></div>
|
||||
<div class="cr-live-info">
|
||||
<div class="cr-live-title">${esc(title)}</div>
|
||||
<div class="cr-live-meta">${esc(s.teacher_name)} · ${cls}</div>
|
||||
</div>
|
||||
<div class="cr-live-badges">
|
||||
<span class="cr-badge cr-badge-online">
|
||||
<svg class="ic" viewBox="0 0 24 24" style="width:11px;height:11px"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
|
||||
${s.online_count}
|
||||
</span>
|
||||
<span class="cr-badge cr-badge-msgs">
|
||||
<svg class="ic" viewBox="0 0 24 24" style="width:11px;height:11px"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>
|
||||
${s.message_count}
|
||||
</span>
|
||||
<span class="cr-badge cr-badge-dur">
|
||||
<svg class="ic" viewBox="0 0 24 24" style="width:11px;height:11px"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
|
||||
${dur}
|
||||
</span>
|
||||
</div>
|
||||
<div class="cr-live-actions">
|
||||
<button class="btn-cr-end" onclick="adminEndSession(${s.id})">Завершить</button>
|
||||
</div>
|
||||
</div>`;
|
||||
}).join('');
|
||||
} catch(e) {
|
||||
el.innerHTML = `<div class="error">Ошибка: ${esc(e.message)}</div>`;
|
||||
}
|
||||
if (window.lucide) lucide.createIcons();
|
||||
}
|
||||
|
||||
async function adminEndSession(id) {
|
||||
if (!await LS.confirm(`Завершить урок #${id}? Все участники будут отключены.`, { title: 'Завершить урок', confirmText: 'Завершить' })) return;
|
||||
try {
|
||||
await LS.api(`/api/classroom/${id}`, { method: 'DELETE' });
|
||||
LS.toast('Урок завершён', 'success', 2500);
|
||||
loadCrActiveSessions();
|
||||
} catch(e) { LS.toast('Ошибка: ' + e.message, 'error'); }
|
||||
}
|
||||
|
||||
function crHistDebounce() {
|
||||
clearTimeout(_crHistDebTimer);
|
||||
_crHistDebTimer = setTimeout(() => { _crHistPage = 1; loadCrHistory(); }, 350);
|
||||
}
|
||||
|
||||
async function loadCrHistory(page) {
|
||||
if (page) _crHistPage = page;
|
||||
_crHistSearch = (document.getElementById('cr-hist-q')?.value || '').trim();
|
||||
const el = document.getElementById('cr-hist-list');
|
||||
el.innerHTML = '<div class="spinner"></div>';
|
||||
try {
|
||||
const params = new URLSearchParams({ page: _crHistPage, limit: 20 });
|
||||
if (_crHistSearch) params.set('search', _crHistSearch);
|
||||
const { sessions, total, pages } = await LS.api('/api/classroom/admin/sessions?' + params);
|
||||
_crHistTotal = total; _crHistPages = pages;
|
||||
document.getElementById('cr-hist-count').textContent = `${total} уроков`;
|
||||
if (!sessions.length) {
|
||||
el.innerHTML = '<div class="empty">Нет завершённых уроков</div>';
|
||||
renderCrPagination();
|
||||
return;
|
||||
}
|
||||
el.innerHTML = sessions.map(s => {
|
||||
const title = s.title || `Урок #${s.id}`;
|
||||
const cls = s.class_name ? `Класс: ${esc(s.class_name)}` : 'Личный урок';
|
||||
const dur = fmtDuration(s.ended_at ? Math.round((new Date(s.ended_at)-new Date(s.created_at))/1000) : null);
|
||||
return `<div>
|
||||
<div class="cr-hist-row${_crOpenDetailId===s.id?' open':''}" onclick="toggleCrDetail(${s.id},this)">
|
||||
<div class="cr-hist-icon">
|
||||
<svg class="ic" viewBox="0 0 24 24" style="width:18px;height:18px;color:var(--violet)"><rect x="2" y="3" width="20" height="14" rx="2" ry="2"/><line x1="8" y1="21" x2="16" y2="21"/><line x1="12" y1="17" x2="12" y2="21"/></svg>
|
||||
</div>
|
||||
<div class="cr-hist-main">
|
||||
<div class="cr-hist-title">${esc(title)}</div>
|
||||
<div class="cr-hist-meta">${esc(s.teacher_name)} · ${cls} · ${fmtDate(s.ended_at || s.created_at)}</div>
|
||||
</div>
|
||||
<div class="cr-hist-chips">
|
||||
<span class="cr-badge cr-badge-online">${s.participant_count} уч.</span>
|
||||
<span class="cr-badge cr-badge-msgs">${s.message_count} сообщ.</span>
|
||||
<span class="cr-badge cr-badge-dur">${dur}</span>
|
||||
</div>
|
||||
<svg class="cr-hist-chevron ic" viewBox="0 0 24 24"><polyline points="6 9 12 15 18 9"/></svg>
|
||||
</div>
|
||||
<div class="cr-detail-drawer${_crOpenDetailId===s.id?' open':''}" id="cr-detail-${s.id}">
|
||||
<div class="cr-detail-inner" id="cr-detail-inner-${s.id}">
|
||||
<div class="spinner"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
}).join('');
|
||||
if (_crOpenDetailId) {
|
||||
const dr = document.getElementById(`cr-detail-${_crOpenDetailId}`);
|
||||
if (dr) loadCrSessionDetail(_crOpenDetailId);
|
||||
}
|
||||
renderCrPagination();
|
||||
} catch(e) {
|
||||
el.innerHTML = `<div class="error">Ошибка: ${esc(e.message)}</div>`;
|
||||
}
|
||||
if (window.lucide) lucide.createIcons();
|
||||
}
|
||||
|
||||
function renderCrPagination() {
|
||||
const el = document.getElementById('cr-hist-pagination');
|
||||
if (_crHistPages <= 1) { el.innerHTML = ''; return; }
|
||||
const p = _crHistPage, total = _crHistPages;
|
||||
let html = '<div class="cr-pagination">';
|
||||
html += `<button class="cr-page-btn" onclick="loadCrHistory(${p-1})" ${p<=1?'disabled':''}>
|
||||
<svg class="ic" viewBox="0 0 24 24" style="width:14px;height:14px"><polyline points="15 18 9 12 15 6"/></svg>
|
||||
</button>`;
|
||||
const range = [];
|
||||
for (let i=1;i<=total;i++) {
|
||||
if (i===1||i===total||Math.abs(i-p)<=1) range.push(i);
|
||||
else if (range[range.length-1]!=='…') range.push('…');
|
||||
}
|
||||
range.forEach(r => {
|
||||
if (r==='…') html += `<span class="cr-page-info">…</span>`;
|
||||
else html += `<button class="cr-page-btn${r===p?' active':''}" onclick="loadCrHistory(${r})">${r}</button>`;
|
||||
});
|
||||
html += `<button class="cr-page-btn" onclick="loadCrHistory(${p+1})" ${p>=total?'disabled':''}>
|
||||
<svg class="ic" viewBox="0 0 24 24" style="width:14px;height:14px"><polyline points="9 18 15 12 9 6"/></svg>
|
||||
</button></div>`;
|
||||
el.innerHTML = html;
|
||||
}
|
||||
|
||||
async function toggleCrDetail(id, rowEl) {
|
||||
const wasOpen = _crOpenDetailId === id;
|
||||
// close all
|
||||
document.querySelectorAll('.cr-hist-row.open').forEach(r => r.classList.remove('open'));
|
||||
document.querySelectorAll('.cr-detail-drawer.open').forEach(d => { d.classList.remove('open'); d.style.maxHeight=''; });
|
||||
_crOpenDetailId = null;
|
||||
if (wasOpen) return;
|
||||
// open this one
|
||||
rowEl.classList.add('open');
|
||||
const dr = document.getElementById(`cr-detail-${id}`);
|
||||
if (dr) { dr.classList.add('open'); }
|
||||
_crOpenDetailId = id;
|
||||
await loadCrSessionDetail(id);
|
||||
}
|
||||
|
||||
async function loadCrSessionDetail(id) {
|
||||
const inner = document.getElementById(`cr-detail-inner-${id}`);
|
||||
if (!inner) return;
|
||||
inner.innerHTML = '<div class="spinner"></div>';
|
||||
try {
|
||||
const { session, stats, attendance, pages } = await LS.api(`/api/classroom/${id}/summary`);
|
||||
const dur = fmtDuration(stats.duration_sec);
|
||||
inner.innerHTML = `
|
||||
<div class="cr-detail-grid">
|
||||
<div class="cr-detail-stat"><div class="cr-detail-val">${stats.participant_count}</div><div class="cr-detail-label">Участников</div></div>
|
||||
<div class="cr-detail-stat"><div class="cr-detail-val">${stats.message_count}</div><div class="cr-detail-label">Сообщений</div></div>
|
||||
<div class="cr-detail-stat"><div class="cr-detail-val">${stats.page_count}</div><div class="cr-detail-label">Страниц</div></div>
|
||||
<div class="cr-detail-stat"><div class="cr-detail-val" style="font-size:1rem">${dur}</div><div class="cr-detail-label">Длительность</div></div>
|
||||
</div>
|
||||
${attendance.length ? `
|
||||
<div class="section-title" style="font-size:0.72rem;margin-bottom:8px">Посещаемость</div>
|
||||
<div class="cr-attend-list">
|
||||
${attendance.map(a => `
|
||||
<div class="cr-attend-row">
|
||||
<svg class="ic" viewBox="0 0 24 24" style="width:15px;height:15px;flex-shrink:0;color:var(--violet)"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
|
||||
<span class="cr-attend-name">${esc(a.user_name)}</span>
|
||||
<span class="cr-attend-time">${a.joined_at ? new Date(a.joined_at).toLocaleTimeString('ru-RU',{hour:'2-digit',minute:'2-digit'}) : '—'}</span>
|
||||
<span class="cr-attend-dur">${a.duration_sec ? fmtDuration(a.duration_sec) : (a.left_at ? '—' : '<span style="color:var(--green)">онлайн</span>')}</span>
|
||||
</div>
|
||||
`).join('')}
|
||||
</div>
|
||||
` : ''}
|
||||
${pages.length > 1 ? `
|
||||
<div class="section-title" style="font-size:0.72rem;margin:16px 0 8px">Страницы доски</div>
|
||||
<div class="cr-pages-list">
|
||||
${pages.map(p => `
|
||||
<div class="cr-page-chip">
|
||||
<span class="cr-page-num">Стр. ${p.page_num}</span>
|
||||
<span class="cr-page-cnt">${p.stroke_count} штр.</span>
|
||||
</div>
|
||||
`).join('')}
|
||||
</div>
|
||||
` : ''}
|
||||
<div class="cr-detail-actions">
|
||||
<button class="btn-cr-export" onclick="adminExportChat(${id})">
|
||||
<svg class="ic" viewBox="0 0 24 24" style="width:13px;height:13px;vertical-align:-2px"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
|
||||
Экспорт чата
|
||||
</button>
|
||||
<button class="btn-cr-del" onclick="adminDeleteSession(${id})">
|
||||
<svg class="ic" viewBox="0 0 24 24" style="width:13px;height:13px;vertical-align:-2px"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M10 11v6"/><path d="M14 11v6"/></svg>
|
||||
Удалить запись
|
||||
</button>
|
||||
</div>`;
|
||||
} catch(e) {
|
||||
inner.innerHTML = `<div class="error">Ошибка: ${esc(e.message)}</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
function adminExportChat(id) {
|
||||
window.open(`/api/classroom/${id}/chat/export`, '_blank');
|
||||
}
|
||||
|
||||
async function adminDeleteSession(id) {
|
||||
if (!await LS.confirm('Удалить всю запись об этом уроке? Данные нельзя восстановить.', { title: 'Удалить урок', confirmText: 'Удалить', dangerous: true })) return;
|
||||
try {
|
||||
await LS.api(`/api/classroom/${id}/history`, { method: 'DELETE' });
|
||||
LS.toast('Урок удалён', 'success', 2500);
|
||||
_crOpenDetailId = null;
|
||||
loadCrHistory();
|
||||
} catch(e) { LS.toast('Ошибка: ' + e.message, 'error'); }
|
||||
}
|
||||
|
||||
/* ─── wire tab loading ─── */
|
||||
const _origSwitchTab = window.switchTab;
|
||||
window.switchTab = function(btn) {
|
||||
@@ -4823,6 +5248,7 @@
|
||||
else if (tab === 'audit') loadAuditLog();
|
||||
else if (tab === 'errors') loadErrorLog();
|
||||
else if (tab === 'health') loadHealth();
|
||||
else if (tab === 'classroom') { loadCrModuleState(); loadCrActiveSessions(); loadCrHistory(); }
|
||||
};
|
||||
|
||||
/* ─── init ─── */
|
||||
|
||||
Reference in New Issue
Block a user