From 54982d758ecb7fe740baf649a6668c88ef3fea5b Mon Sep 17 00:00:00 2001 From: dev Date: Thu, 8 Oct 2026 11:47:57 +0300 Subject: [PATCH] feat(files): photo-style cards with main-design buttons and links --- public/files.html | 23 ++++++++++++++++++----- public/js/files.js | 37 +++++++++++++++++++------------------ 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/public/files.html b/public/files.html index 3bad45e..1de21ef 100644 --- a/public/files.html +++ b/public/files.html @@ -6,10 +6,23 @@ Файлы — Админ-панель @@ -30,7 +43,7 @@ -
Загрузка...
+
Загрузка...
diff --git a/public/js/files.js b/public/js/files.js index d494cc7..93ffaf0 100644 --- a/public/js/files.js +++ b/public/js/files.js @@ -34,26 +34,25 @@ function humanSize(b) { function fileCardHTML(f) { const url = `${API}/api/files/${f.token}`; const thumb = isImageFile(f.name) - ? `` - : `
📄
`; - const target = isImageFile(f.name) - ? `href="#" data-img="${esc(url)}"` - : `href="${url}" download`; + ? `` + : `
📄
`; const meta = mode === 'detached' - ? `
Откреплён от записи, не привязан
` - : `
${esc(f.student_name)} · ${esc(f.group_name)}
`; + ? '
Откреплён от записи, не привязан
' + : `
${esc(f.student_name || '')} · ${esc(f.group_name || '')}
`; + const time = `
${fmtFull(f.created_at)}${f.size ? ' · ' + humanSize(f.size) : ''}
`; const action = mode === 'detached' - ? `` - : ``; + ? `` + : ``; return ` -
+
${thumb} -
- +
+ 📎 Файл +
${isImageFile(f.name) ? esc(f.name) : `${esc(f.name)}`}
${meta} -
${fmtFull(f.created_at)}${f.size ? ' · ' + humanSize(f.size) : ''}
+ ${time} + ${action}
-
${action}
`; } @@ -61,16 +60,18 @@ function fileCardHTML(f) { function renderGrid() { const grid = document.getElementById('grid'); if (!currentFiles.length) { - grid.className = 'grid'; + grid.className = 'ph-grid'; grid.innerHTML = mode === 'detached' - ? '
Откреплённых файлов нет
' - : '
Файлов не найдено
'; + ? '
Откреплённых файлов нет
' + : '
Файлов не найдено
'; return; } - grid.className = 'grid'; + grid.className = 'ph-grid'; grid.innerHTML = currentFiles.map(fileCardHTML).join(''); } + + async function detachFile(id) { if (!confirm('Открепить файл от записи? Он переместится во вкладку «Откреплённые».')) return; const res = await fetch(`${API}/api/files/${id}/detach`, { method: 'POST', headers: hdr() });