Files

286 lines
22 KiB
HTML

<!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">
<link rel="stylesheet" href="/admin-dark.css" disabled id="themeCss">
<script src="js/theme.js"></script>
<style>
.digest-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px; align-items: start; }
.digest-side { position: sticky; top: 20px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; max-height: calc(100dvh - 40px); }
.digest-side-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.digest-side-title { font-size: .85rem; font-weight: 700; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.digest-deleted-btn { width: 28px; height: 28px; padding: 0; flex: 0 0 auto; }
.digest-deleted-btn svg { width: 15px; height: 15px; }
.digest-deleted-btn.active { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.35); color: #dc2626; }
.digest-side-search { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.digest-side-search .digest-search { min-width: 0; max-width: none; }
.digest-nav { overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.digest-nav-item { display: flex; flex-direction: column; gap: 3px; width: 100%; padding: 10px 14px; text-align: left; background: transparent; border: none; border-bottom: 1px solid var(--border); font-family: inherit; cursor: pointer; transition: background .15s; }
.digest-nav-item:last-child { border-bottom: none; }
.digest-nav-item:hover { background: var(--bg); }
.digest-nav-item.active { background: rgba(37,99,235,.07); box-shadow: inset 3px 0 0 var(--accent); }
.digest-nav-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .85rem; font-weight: 600; line-height: 1.35; color: var(--text); overflow-wrap: anywhere; }
.digest-nav-title svg { width: 12px; height: 12px; margin-right: 4px; vertical-align: -1px; color: #b45309; }
.digest-nav-date { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.digest-nav-item.is-deleted .digest-nav-title { color: var(--muted); }
.digest-nav-item.is-deleted .digest-nav-title svg { color: #dc2626; }
.digest-nav-empty { padding: 22px 14px; color: var(--muted); font-size: .85rem; text-align: center; }
.digest-search { position: relative; flex: 1; min-width: 240px; max-width: 460px; display: flex; align-items: center; }
.digest-search > svg { position: absolute; left: 14px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.digest-search input { width: 100%; background: var(--card); border: 1px solid var(--border); color: var(--text); border-radius: 11px; padding: 11px 14px 11px 40px; font-size: .9rem; font-family: inherit; outline: none; transition: border-color .15s, box-shadow .15s; }
.digest-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.digest-count { font-size: .75rem; font-weight: 500; color: var(--muted); margin-left: auto; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.digest-list { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.digest-card { position: relative; background: var(--card); border: 1px solid var(--border); border-radius: 16px; display: flex; flex-direction: column; min-width: 0; overflow: hidden; scroll-margin-top: 20px; transition: box-shadow .18s, border-color .18s; }
.digest-card:hover { box-shadow: 0 6px 24px rgba(0,0,0,.06); }
.digest-card.pinned { border-left: 3px solid #f59e0b; background: linear-gradient(180deg, rgba(245,158,11,.055), var(--card) 180px); }
.digest-card.digest-hidden { opacity: .62; }
.digest-card.is-deleted { border-style: dashed; background: var(--bg); }
.digest-card.is-deleted .digest-body { opacity: .78; }
.digest-card.is-deleted .digest-cover { filter: grayscale(.6); }
.digest-card-top { padding: 24px 28px 0; display: flex; flex-direction: column; gap: 12px; }
.digest-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.digest-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: .68rem; font-weight: 700; letter-spacing: .02em; background: rgba(245,158,11,.12); color: #b45309; white-space: nowrap; }
.digest-badge svg { width: 12px; height: 12px; }
.digest-badge.scheduled { background: rgba(37,99,235,.1); color: var(--accent); }
.digest-badge.dim { background: var(--bg); color: var(--muted); }
.digest-badge.deleted { background: rgba(239,68,68,.12); color: #dc2626; }
.digest-title { margin: 0; font-size: 1.35rem; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; word-break: break-word; }
.digest-meta { display: flex; align-items: center; gap: 10px; min-width: 0; }
.digest-avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: rgba(37,99,235,.1); color: var(--accent); font-weight: 700; font-size: .85rem; text-transform: uppercase; }
.digest-meta-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.digest-author { font-size: .85rem; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.digest-date { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; color: var(--muted); }
.digest-date svg { width: 12px; height: 12px; opacity: .75; }
.digest-main { display: flex; align-items: flex-start; gap: 22px; padding: 20px 28px 0; }
.digest-cover { flex: 0 0 34%; min-width: 200px; max-width: 360px; aspect-ratio: 4/3; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--bg); }
.digest-cover button { display: block; width: 100%; height: 100%; padding: 0; border: none; background: none; cursor: zoom-in; }
.digest-cover img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.digest-cover:hover img { transform: scale(1.015); }
.digest-content { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.digest-body { font-size: 1rem; line-height: 1.72; color: var(--text); overflow-wrap: anywhere; white-space: pre-wrap; }
.digest-body.clamp { max-height: 260px; overflow: hidden; -webkit-mask-image: linear-gradient(to bottom, #000 76%, transparent); mask-image: linear-gradient(to bottom, #000 76%, transparent); }
.digest-body-toggle { align-self: flex-start; display: inline-flex; align-items: center; gap: 5px; margin: 0 0 0 -8px; padding: 5px 8px; background: none; border: none; border-radius: 8px; color: var(--accent); font-size: .84rem; font-weight: 600; font-family: inherit; cursor: pointer; }
.digest-body-toggle:hover { background: rgba(37,99,235,.08); }
.digest-body-toggle svg { width: 14px; height: 14px; transition: transform .18s; }
.digest-body-toggle.open svg { transform: rotate(180deg); }
.digest-gallery { display: flex; flex-wrap: wrap; gap: 6px; }
.digest-shot { position: relative; display: block; width: 68px; aspect-ratio: 4/3; flex: 0 0 auto; padding: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg); cursor: zoom-in; }
.digest-shot img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.digest-shot:hover img { transform: scale(1.05); }
.digest-more { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(17,24,39,.55); color: #fff; font-size: .72rem; font-weight: 700; pointer-events: none; }
.digest-foot { margin-top: 20px; padding: 14px 28px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.digest-foot-note { display: inline-flex; align-items: center; gap: 5px; font-size: .76rem; color: var(--muted); }
.digest-foot-note svg { width: 12px; height: 12px; }
.digest-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.digest-act { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; background: transparent; border: 1px solid transparent; border-radius: 9px; color: var(--muted); font-size: .82rem; font-weight: 600; font-family: inherit; cursor: pointer; white-space: nowrap; transition: background .15s, color .15s, border-color .15s; }
.digest-act svg { width: 14px; height: 14px; }
.digest-act:hover { background: var(--bg); border-color: var(--border); color: var(--text); }
.digest-act.is-pinned { color: #b45309; background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.28); }
.digest-act.is-pinned:hover { background: rgba(245,158,11,.16); border-color: rgba(245,158,11,.45); color: #b45309; }
.digest-act.danger:hover { color: #ef4444; background: rgba(239,68,68,.06); border-color: rgba(239,68,68,.3); }
.digest-empty { border: 1px dashed var(--border); border-radius: 16px; padding: 56px 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; color: var(--muted); background: var(--card); }
.digest-empty svg { width: 30px; height: 30px; opacity: .5; }
.digest-empty.error svg { color: #ef4444; opacity: .8; }
.digest-empty p { margin: 0; font-size: 1rem; color: var(--text); font-weight: 600; }
.digest-empty .sub { font-size: .85rem; opacity: .85; max-width: 440px; font-weight: 400; color: var(--muted); }
.digest-empty .btn-primary { margin-top: 10px; }
.digest-none { color: var(--muted); font-size: .85rem; font-style: italic; }
.digest-highlight { outline: 2px solid #f59e0b; outline-offset: 3px; }
.digest-new-btn { margin-left: 0; }
.digest-view-toggle { margin-left: auto; align-self: center; padding: 6px 10px; gap: 8px; }
.digest-view-toggle .toggle-text small { font-size: .8rem; }
.digest-list.digest-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.digest-list.digest-cards .digest-empty { grid-column: 1 / -1; }
.digest-cards .digest-card { border-radius: var(--radius); animation: entryEnter .4s cubic-bezier(.22,1,.36,1) both; }
.digest-cards .digest-card-top { padding: 16px 16px 0; gap: 8px; }
.digest-cards .digest-title { font-size: .95rem; font-weight: 600; }
.digest-cards .digest-badge { font-size: .62rem; padding: 3px 8px; }
.digest-cards .digest-avatar { display: none; }
.digest-cards .digest-meta { gap: 0; min-width: 0; }
.digest-cards .digest-meta-text { flex-direction: row; align-items: center; justify-content: space-between; gap: 6px; width: 100%; min-width: 0; }
.digest-cards .digest-author,
.digest-cards .digest-date { display: inline-flex; align-items: center; max-width: calc(50% - 3px); min-width: 0; background: rgba(0,0,0,.55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); color: #fff; font-size: .72rem; font-weight: 600; line-height: 1.3; padding: 3px 9px; border-radius: 999px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.digest-cards .digest-date svg { width: 11px; height: 11px; opacity: .85; }
.digest-cards .digest-main { flex: 1 1 auto; flex-direction: column; gap: 0; padding: 0; }
.digest-cards .digest-cover { flex: 0 0 auto; position: relative; width: 100%; max-width: none; min-width: 0; aspect-ratio: 4/3; border-radius: 0; border-left: none; border-right: none; border-bottom: 1px solid var(--border); }
.digest-cards .digest-cover .digest-meta { position: absolute; top: 8px; left: 8px; right: 8px; z-index: 2; pointer-events: none; }
.digest-cards .digest-content { padding: 12px 16px 0; gap: 8px; }
.digest-cards .digest-body { font-size: .9rem; line-height: 1.62; }
.digest-cards .digest-body.clamp { max-height: 168px; }
.digest-cards .digest-shot { width: 46px; }
.digest-cards .digest-foot { margin-top: auto; padding: 10px 14px; gap: 8px; }
.digest-cards .digest-act { padding: 6px; font-size: 0; gap: 0; }
@media (max-width: 1200px) {
.digest-list.digest-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
.digest-cards .digest-card { animation: none; }
}
.field-hint { font-size: .78rem; color: var(--muted); margin-top: 4px; display: block; }
.digest-file-hidden { display: none; }
.digest-file-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.digest-pick { cursor: pointer; }
.digest-preview-wrap { display: block; margin-top: 8px; }
.digest-preview-img { display: block; width: 100%; max-width: 100%; max-height: 220px; object-fit: cover; border: 1px solid var(--border); border-radius: 10px; }
.digest-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.digest-image { position: relative; width: 132px; flex-shrink: 0; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; aspect-ratio: 4/3; }
.digest-image img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer; }
.digest-image-remove { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.7); color: #fff; border: none; border-radius: 6px; padding: 3px 8px; font-size: .75rem; cursor: pointer; }
.digest-image-remove:hover { background: #ef4444; }
#digestModal .edit-modal { width: 1000px; max-width: none; display: flex; flex-direction: column; max-height: 85vh; }
#digestModal .bookmark-modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
#digestModal .digest-modal-body { flex: 0 0 auto; max-height: 62vh; overflow-y: auto; padding: 12px 0 8px 0; }
.digest-modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.digest-modal-col { display: flex; flex-direction: column; gap: 12px; }
.digest-modal-col .settings-field { margin: 0; }
.digest-counter { font-size: .75rem; font-weight: 400; color: var(--muted); margin-left: auto; }
.digest-section-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding-top: 4px; border-top: 1px solid var(--border); }
.digest-modal-col > .digest-section-title:first-child { padding-top: 0; border-top: none; }
.digest-check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 400 !important; }
.digest-check input { width: auto; }
#digestModal .card-foot { flex: 0 0 auto; margin-top: 10px; justify-content: flex-end; }
@media (max-width: 900px) {
.digest-layout { grid-template-columns: 1fr; gap: 16px; }
.digest-side { position: static; max-height: 260px; }
}
@media (max-width: 720px) {
.digest-list.digest-cards { grid-template-columns: 1fr; }
.digest-card-top { padding: 20px 18px 0; }
.digest-main { flex-direction: column; gap: 16px; padding: 16px 18px 0; }
.digest-cover { flex: none; width: 100%; max-width: none; }
.digest-foot { padding: 12px 18px; }
.digest-title { font-size: 1.18rem; }
.digest-modal-grid { grid-template-columns: 1fr; }
}
</style>
</head>
<body data-page="digest">
<div class="layout">
<div class="sidebar" id="sidebar"></div>
<div class="main">
<div class="page-head">
<h2>Дайджест</h2>
<p class="page-sub">Важные сообщения для команды</p>
<label class="toggle digest-view-toggle" title="Показывать сообщения карточками">
<input type="checkbox" id="digestCardsView">
<span class="toggle-track"><span class="toggle-thumb"></span></span>
<span class="toggle-text"><small>Карточки</small></span>
</label>
<button type="button" class="btn-primary digest-new-btn" id="digestNewBtn"><i data-lucide="plus"></i> Новое сообщение</button>
</div>
<div class="digest-layout">
<aside class="digest-side">
<div class="digest-side-head">
<span class="digest-side-title" id="digestSideTitle">Сообщения</span>
<span id="digestCount" class="digest-count"></span>
<button type="button" class="icon-btn digest-deleted-btn" id="digestDeletedBtn" title="Удалённые сообщения" aria-pressed="false"><i data-lucide="trash-2"></i></button>
</div>
<div class="digest-side-search">
<div class="digest-search">
<i data-lucide="search"></i>
<input type="search" id="digestSearch" placeholder="Поиск по сообщениям" autocomplete="off">
</div>
</div>
<div id="digestNav" class="digest-nav"></div>
</aside>
<div id="digestList" class="digest-list"></div>
</div>
</div>
</div>
<div class="modal-overlay" id="digestModal">
<div class="edit-modal">
<div class="bookmark-modal-head">
<h3 id="digestModalTitle">Новое сообщение</h3>
<button type="button" class="icon-btn" id="digestModalClose"><i data-lucide="x"></i></button>
</div>
<div class="digest-modal-body">
<div class="digest-modal-grid">
<div class="digest-modal-col">
<div class="settings-field">
<label>Заголовок <span style="color:#ef4444">*</span><span class="digest-counter" id="digestTitleCount">0 / 200</span></label>
<input id="digestTitle" class="settings-input" maxlength="200" placeholder="Например: Мероприятия на этой неделе">
</div>
<div class="settings-field">
<label>Текст сообщения <span style="color:#ef4444">*</span><span class="digest-counter" id="digestBodyCount">0 / 5000</span></label>
<textarea id="digestBody" class="settings-input" rows="10" maxlength="5000" placeholder="Что нужно сообщить ученикам и тьюторам..."></textarea>
<span class="field-hint">Курсор в поле текста + Ctrl+V — вставит картинку из буфера обмена.</span>
</div>
<div class="digest-section-title">Публикация</div>
<div class="settings-field">
<label class="digest-check"><input type="checkbox" id="digestPinned"> Закрепить в начале списка</label>
<span class="field-hint">Закреплённые сообщения всегда сверху. Доступно администраторам.</span>
</div>
<div class="settings-field">
<label>Дата публикации</label>
<input type="datetime-local" id="digestPostAt">
<span class="field-hint">Пусто — опубликовать сразу. Будущая дата — публикация и уведомление произойдут автоматически.</span>
</div>
<div class="settings-field">
<label>Скрыть после</label>
<input type="datetime-local" id="digestHideAt">
<span class="field-hint">После этой даты сообщение скрывается для всех, кроме администратора.</span>
</div>
</div>
<div class="digest-modal-col">
<div class="digest-section-title">Медиа</div>
<div class="settings-field">
<label>Превью / обложка сообщения</label>
<div id="digestPreviewWrap" class="digest-preview-wrap">
<img id="digestPreviewImg" class="digest-preview-img" src="" alt="превью">
</div>
<div class="digest-file-row">
<label class="btn-primary ghost digest-pick" for="digestPreviewFile"><i data-lucide="image-plus"></i> Выбрать файл</label>
<button type="button" class="btn-primary danger-ghost" id="digestPreviewRemove" style="display:none"><i data-lucide="trash-2"></i> Убрать превью</button>
</div>
<input type="file" id="digestPreviewFile" accept="image/*" class="digest-file-hidden">
<span class="field-hint">Обложка сообщения. Загружается при сохранении.</span>
</div>
<div class="settings-field">
<label>Картинки в сообщение</label>
<div id="digestImagesWrap" class="digest-images"></div>
<div class="digest-file-row">
<label class="btn-primary ghost digest-pick" id="digestImageAdd" for="digestImageFile"><i data-lucide="images"></i> Добавить картинки</label>
<input type="file" id="digestImageFile" accept="image/*" multiple class="digest-file-hidden">
</div>
<span class="field-hint">До 20 картинок. Удаление картинки стирает файл с диска.</span>
</div>
</div>
</div>
</div>
<div class="card-foot">
<button type="button" class="btn-primary ghost" id="digestCancel">Отмена</button>
<button type="button" class="btn-primary" id="digestSave">Сохранить</button>
</div>
</div>
</div>
<div class="modal-overlay" id="imgModal"><img id="imgModalSrc" alt=""></div>
<div class="toast" id="toast"></div>
<script src="vendor/lucide.min.js"></script>
<script src="js/datetime.js"></script>
<script src="admin.js"></script>
<script src="js/digest.js"></script>
</body>
</html>