fix: dropdown «Файлы» на FS, а не на таблице users
В таблице users БД нет env-only аккаунтов (smeta) и удалённых пользователей, у которых на диске остались файлы — они не показывались в админке. Новый endpoint /api/admin/file_users сканирует DATA_DIR, возвращает имена и счётчики файлов. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+17
-7
@@ -184,8 +184,6 @@ function loadUsers() {
|
||||
fetch('/api/admin/users', {headers: H}).then(r=>r.json()).then(users => {
|
||||
const t = document.getElementById('users');
|
||||
t.innerHTML = '<tr><th>Email</th><th>Роль</th><th>Статус</th><th>Создан</th><th>Действия</th></tr>';
|
||||
const fSel = document.getElementById('files-user');
|
||||
if (fSel) fSel.innerHTML = '<option value="">— выберите пользователя —</option>';
|
||||
for (const u of users) {
|
||||
const d = new Date(u.created_at < 1e12 ? u.created_at*1000 : u.created_at);
|
||||
const tr = document.createElement('tr');
|
||||
@@ -200,11 +198,6 @@ function loadUsers() {
|
||||
actions += btn('Удалить', "userAction('delete','"+u.email+"')");
|
||||
tr.innerHTML = '<td>'+u.email+'</td><td>'+u.role+'</td><td>'+status+'</td><td class="time">'+ts+'</td><td>'+actions+'</td>';
|
||||
t.appendChild(tr);
|
||||
if (fSel) {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = u.email; opt.textContent = u.email;
|
||||
fSel.appendChild(opt);
|
||||
}
|
||||
}
|
||||
}).catch(()=>{});
|
||||
}
|
||||
@@ -216,6 +209,23 @@ function fmtSize(n){
|
||||
if (n < 1024*1024) return (n/1024).toFixed(1)+' KB';
|
||||
return (n/1024/1024).toFixed(1)+' MB';
|
||||
}
|
||||
// dropdown файловой страницы наполняется из FS, не из БД-юзеров —
|
||||
// бывают env-only / удалённые аккаунты, чьи файлы всё ещё на диске
|
||||
async function loadFileUsers() {
|
||||
const sel = document.getElementById('files-user');
|
||||
if (!sel) return;
|
||||
const r = await fetch('/api/admin/file_users', {headers: H});
|
||||
if (!r.ok) return;
|
||||
const d = await r.json();
|
||||
sel.innerHTML = '<option value="">— выберите пользователя —</option>';
|
||||
for (const u of d.users) {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = u.username;
|
||||
opt.textContent = u.username + ' (' + u.file_count + ')';
|
||||
sel.appendChild(opt);
|
||||
}
|
||||
}
|
||||
loadFileUsers();
|
||||
async function loadFiles() {
|
||||
const u = document.getElementById('files-user').value;
|
||||
const tbl = document.getElementById('files');
|
||||
|
||||
Reference in New Issue
Block a user