fix(photo): preserve photo_jobs history in backup/restore; paginate photo history on worker page

This commit is contained in:
dev
2026-09-23 16:37:27 +03:00
parent 30cf04b0cf
commit cb3f010cd9
3 changed files with 53 additions and 9 deletions
+10 -2
View File
@@ -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 ? `<img class="photo-thumb" loading="lazy" src="${esc(thumbUrl(r.before_path))}" alt="было">` : '<span style="color:var(--muted)">—</span>';
@@ -257,6 +263,7 @@ function renderPhoto() {
</td>
</tr>`;
}).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 {