diff --git a/public/js/worker.js b/public/js/worker.js index 7b84283..fb4c3df 100644 --- a/public/js/worker.js +++ b/public/js/worker.js @@ -1,5 +1,6 @@ const AUTO_REFRESH_MS = 5000; const RECENT_PAGE_SIZE = 15; +const PHOTO_PAGE_SIZE = 15; const STATUS_LABELS = { pending: 'В очереди', processing: 'Проверяется', @@ -23,6 +24,8 @@ let busy = false; let photoBusy = false; let recentRows = []; let recentPage = 1; +let photoPage = 1; +let photoTotal = 0; const PHOTO_ACTION_LABELS = { ai: 'ИИ-обработка', @@ -236,7 +239,10 @@ function renderPhoto() { renderPhotoPending(); const tbody = document.querySelector('#photoTable tbody'); const empty = document.getElementById('photoEmpty'); - if (!rows.length) { tbody.innerHTML = ''; empty.style.display = 'block'; return; } + const pager = document.getElementById('photoRecentPager'); + const maxPage = Math.max(1, Math.ceil(photoTotal / PHOTO_PAGE_SIZE)); + if (photoPage > maxPage) photoPage = maxPage; + if (!photoTotal) { tbody.innerHTML = ''; empty.style.display = 'block'; renderPager(pager, photoPage, maxPage, p => { photoPage = p; loadPhoto(); }); return; } empty.style.display = 'none'; tbody.innerHTML = rows.map(r => { const before = r.before_path ? `было` : '—'; @@ -257,6 +263,7 @@ function renderPhoto() { `; }).join(''); + renderPager(pager, photoPage, maxPage, p => { photoPage = p; loadPhoto(); }); renderIcons(); } @@ -304,9 +311,10 @@ async function loadPhoto() { if (photoBusy) return; photoBusy = true; try { - const res = await fetch(`${API}/api/photo-jobs/status`, { headers: hdr() }); + const res = await fetch(`${API}/api/photo-jobs/status?recent_limit=${PHOTO_PAGE_SIZE}&recent_offset=${(photoPage - 1) * PHOTO_PAGE_SIZE}`, { headers: hdr() }); if (!res.ok) return; photoState = await res.json(); + photoTotal = photoState.recent_total || 0; renderPhoto(); } catch { } finally { diff --git a/public/worker.html b/public/worker.html index 20dcda4..1dfdc30 100644 --- a/public/worker.html +++ b/public/worker.html @@ -125,6 +125,7 @@ +