232 lines
11 KiB
HTML
232 lines
11 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Review — photo-pipeline</title>
|
|
<script src="/static/htmx.min.js" defer></script>
|
|
<style>
|
|
:root { color-scheme: dark; }
|
|
body { font-family: system-ui, sans-serif; margin: 0; background: #111; color: #eee; }
|
|
header { padding: 1rem 1.5rem; border-bottom: 1px solid #333; display: flex; gap: 1.5rem; align-items: baseline; }
|
|
header h1 { font-size: 1.2rem; margin: 0; }
|
|
header a { color: #6cf; text-decoration: none; }
|
|
.filters { padding: 1rem 1.5rem; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
|
|
.filters select, .filters input, .filters button { background: #222; color: #eee; border: 1px solid #444; border-radius: 6px; padding: .4rem .8rem; }
|
|
.bulk-bar { display: none; gap: .5rem; align-items: center; padding: .6rem 1.5rem; background: #16222a; border-top: 1px solid #2a4a5a; border-bottom: 1px solid #2a4a5a; }
|
|
.bulk-bar.visible { display: flex; }
|
|
.bulk-bar .count { color: #6cf; }
|
|
.btn-keep { background: #1d4; color: #031; border: 0; border-radius: 6px; padding: .45rem 1rem; cursor: pointer; font-weight: 600; }
|
|
.btn-reject { background: #d43; color: #fff; border: 0; border-radius: 6px; padding: .45rem 1rem; cursor: pointer; font-weight: 600; }
|
|
.btn-reset { background: #444; color: #eee; border: 0; border-radius: 6px; padding: .45rem 1rem; cursor: pointer; }
|
|
.count { padding: 0 1.5rem .5rem; color: #999; font-size: .9rem; }
|
|
main { padding: 1.5rem; max-width: 1400px; margin: 0 auto; }
|
|
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
|
|
.card { background: #1a1a1a; border: 1px solid #333; border-radius: 8px; overflow: hidden; position: relative; }
|
|
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
|
|
.card .check { position: absolute; top: .4rem; left: .4rem; z-index: 2; }
|
|
.card .check input { width: 1.1rem; height: 1.1rem; cursor: pointer; }
|
|
.card.selected { border-color: #6cf; box-shadow: 0 0 0 1px #6cf; }
|
|
.card .meta { padding: .5rem; font-size: .7rem; color: #aaa; word-break: break-all; }
|
|
.card .badge { display: inline-block; padding: .1rem .4rem; border-radius: 999px; font-size: .65rem; margin-top: .25rem; }
|
|
.badge.approved { background: #1d4; color: #031; }
|
|
.badge.rejected { background: #d43; color: #fff; }
|
|
.badge.scanned { background: #333; }
|
|
.badge.keep { background: #1d4; color: #031; }
|
|
.badge.delete_candidate { background: #d43; color: #fff; }
|
|
.badge.review { background: #da4; color: #321; }
|
|
.card .actions { display: flex; gap: .25rem; padding: .5rem; }
|
|
.card button { flex: 1; border: 0; border-radius: 4px; padding: .4rem; cursor: pointer; font-size: .75rem; }
|
|
.approve { background: #1d4; color: #031; }
|
|
.reject { background: #d43; color: #fff; }
|
|
.reset { background: #444; color: #eee; }
|
|
.none { color: #666; font-style: italic; padding: 2rem; text-align: center; }
|
|
.selall { display: inline-flex; align-items: center; gap: .35rem; background: #222; border: 1px solid #444; border-radius: 6px; padding: .4rem .8rem; cursor: pointer; }
|
|
.toast { position: fixed; bottom: 1.2rem; right: 1.2rem; background: #1d4; color: #031; padding: .7rem 1rem; border-radius: 8px; display: none; z-index: 50; font-size: .9rem; box-shadow: 0 2px 12px rgba(0,0,0,.5); }
|
|
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; padding: 1.5rem; }
|
|
.pager a { color: #6cf; text-decoration: none; padding: .4rem .8rem; background: #222; border: 1px solid #444; border-radius: 6px; }
|
|
.pager span { color: #999; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<h1>📸 photo-pipeline</h1>
|
|
<a href="/">Overview</a>
|
|
<a href="/review">Review queue</a>
|
|
<a href="/review?status=approved">Approved</a>
|
|
</header>
|
|
<div class="filters">
|
|
<form method="get" action="/review" style="display:flex;gap:.5rem;" autocomplete="off" id="filter-form">
|
|
<button type="submit" style="display:none;">Filter</button>
|
|
<select name="status">
|
|
<option value="">all (every stage)</option>
|
|
<option value="delete_candidate" {% if status == "delete_candidate" %}selected{% endif %}>⚠ flagged (dark/blurry) — start here</option>
|
|
<option value="keep" {% if status == "keep" %}selected{% endif %}>keep (clean, machine verdict)</option>
|
|
<option value="approved" {% if status == "approved" %}selected{% endif %}>approved (your Keep)</option>
|
|
<option value="rejected" {% if status == "rejected" %}selected{% endif %}>rejected (your Reject)</option>
|
|
<option value="review" {% if status == "review" %}selected{% endif %}>review (reserved)</option>
|
|
<option value="scanned" {% if status == "scanned" %}selected{% endif %}>scanned (no verdict yet)</option>
|
|
</select>
|
|
<input type="text" name="source" value="{{ source or '' }}" placeholder="source (e.g. archive-pictures)">
|
|
<button type="submit">Filter</button>
|
|
</form>
|
|
<button class="selall" id="sel-all" type="button">
|
|
<input type="checkbox" id="sel-all-box" style="pointer-events:none;" autocomplete="off"> Select all on page
|
|
</button>
|
|
</div>
|
|
<div class="bulk-bar" id="bulk-bar">
|
|
<span class="count" id="sel-count">0 selected</span>
|
|
<button class="btn-keep" id="bulk-keep">✅ Bulk Keep</button>
|
|
<button class="btn-reject" id="bulk-reject">🗑 Bulk Reject</button>
|
|
<button class="btn-reset" id="bulk-reset">↺ Reset</button>
|
|
</div>
|
|
<div class="toast" id="toast"></div>
|
|
<p class="count">{{ total }} images · page {{ page }}/{{ pages }}</p>
|
|
<main>
|
|
<div class="grid" id="review-grid">
|
|
{% for item in items %}
|
|
{% include "_card.html" %}
|
|
{% else %}
|
|
<p class="none">No images match the filter.</p>
|
|
{% endfor %}
|
|
</div>
|
|
{% if pages > 1 %}
|
|
<div class="pager">
|
|
{% if page > 1 %}
|
|
<a href="/review?page={{ page-1 }}{% if source %}&source={{ source }}{% endif %}{% if status %}&status={{ status }}{% endif %}">← Prev</a>
|
|
{% endif %}
|
|
<span>page {{ page }} / {{ pages }}</span>
|
|
{% if page < pages %}
|
|
<a href="/review?page={{ page+1 }}{% if source %}&source={{ source }}{% endif %}{% if status %}&status={{ status }}{% endif %}">Next →</a>
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
</main>
|
|
<script>
|
|
// Selection is DERIVED from DOM checkboxes — single source of truth.
|
|
// No separate Set that can drift from the visible state.
|
|
|
|
function getSelected() {
|
|
return [...document.querySelectorAll('.item-check:checked')].map(cb => cb.value);
|
|
}
|
|
|
|
function refresh() {
|
|
const n = getSelected().length;
|
|
document.getElementById('sel-count').textContent = n + ' selected';
|
|
document.getElementById('bulk-bar').classList.toggle('visible', n > 0);
|
|
document.querySelectorAll('.card').forEach(c => {
|
|
const cb = c.querySelector('.item-check');
|
|
if (cb) c.classList.toggle('selected', cb.checked);
|
|
});
|
|
}
|
|
|
|
// any checkbox change → refresh derived state
|
|
document.addEventListener('change', e => {
|
|
if (e.target.classList.contains('item-check') || e.target.id === 'sel-all-box') {
|
|
refresh();
|
|
}
|
|
});
|
|
|
|
document.getElementById('sel-all').addEventListener('click', () => {
|
|
const box = document.getElementById('sel-all-box');
|
|
box.checked = !box.checked;
|
|
document.querySelectorAll('.item-check').forEach(cb => {
|
|
cb.checked = box.checked;
|
|
});
|
|
refresh();
|
|
});
|
|
|
|
// clear any browser-restored form state on load (defensive)
|
|
window.addEventListener('load', () => {
|
|
document.querySelectorAll('.item-check').forEach(cb => { cb.checked = false; });
|
|
document.getElementById('sel-all-box').checked = false;
|
|
refresh();
|
|
});
|
|
|
|
async function cardAction(action, btn) {
|
|
const card = btn.closest('.card');
|
|
const sha = card.dataset.sha;
|
|
try {
|
|
const resp = await fetch(`/review/${sha}/${action}`, { method: 'POST' });
|
|
if (resp.ok) {
|
|
card.remove();
|
|
updateCount();
|
|
showToast(action === 'approve' ? 'Approved' : action === 'reject' ? 'Rejected' : 'Reset');
|
|
// if reset, refresh the page (item returns to a different view)
|
|
if (action === 'reset') location.reload();
|
|
} else {
|
|
showToast('Action failed', true);
|
|
}
|
|
} catch (e) {
|
|
showToast('Action failed: ' + e, true);
|
|
}
|
|
}
|
|
|
|
async function bulk(action) {
|
|
const shas = getSelected();
|
|
if (shas.length === 0) return;
|
|
setBulkBusy(true);
|
|
try {
|
|
const resp = await fetch('/review/bulk', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ action, shas })
|
|
});
|
|
const data = await resp.json();
|
|
shas.forEach(s => {
|
|
const cb = document.querySelector(`.item-check[value="${s}"]`);
|
|
if (cb) cb.closest('.card')?.remove();
|
|
});
|
|
refresh();
|
|
updateCount();
|
|
showToast(`Bulk ${action}: ${data.updated ?? data.moved} done, ${data.missing ?? 0} missing`);
|
|
} catch (e) {
|
|
showToast('Bulk action failed: ' + e, true);
|
|
} finally {
|
|
setBulkBusy(false);
|
|
}
|
|
}
|
|
|
|
function setBulkBusy(busy) {
|
|
['bulk-keep','bulk-reject','bulk-reset'].forEach(id => {
|
|
const b = document.getElementById(id);
|
|
if (b) { b.disabled = busy; b.textContent = busy ? 'Working…' : b.dataset.orig; }
|
|
});
|
|
}
|
|
|
|
function updateCount() {
|
|
const el = document.querySelector('.count');
|
|
const n = document.querySelectorAll('.card').length;
|
|
if (el && el.textContent.includes('images')) {
|
|
// preserve the "· page X/Y" part, update the leading card count
|
|
const m = el.textContent.match(/page (\d+)\/(\d+)/);
|
|
el.textContent = n + ' images' + (m ? ' · page ' + m[1] + '/' + m[2] : '');
|
|
}
|
|
}
|
|
|
|
function showToast(msg, isErr) {
|
|
const t = document.getElementById('toast');
|
|
t.textContent = msg;
|
|
t.style.background = isErr ? '#d43' : '#1d4';
|
|
t.style.color = isErr ? '#fff' : '#031';
|
|
t.style.display = 'block';
|
|
setTimeout(() => { t.style.display = 'none'; }, 3000);
|
|
}
|
|
|
|
// auto-submit filter when dropdown/input changes (no need to press Filter)
|
|
document.getElementById('filter-form').addEventListener('change', e => {
|
|
if (e.target.name === 'status' || e.target.name === 'source') {
|
|
document.getElementById('filter-form').submit();
|
|
}
|
|
});
|
|
|
|
// stash original labels for busy-state restore
|
|
document.querySelectorAll('.bulk-bar button').forEach(b => { b.dataset.orig = b.textContent; });
|
|
|
|
document.getElementById('bulk-keep').addEventListener('click', () => bulk('approve'));
|
|
document.getElementById('bulk-reject').addEventListener('click', () => bulk('reject'));
|
|
document.getElementById('bulk-reset').addEventListener('click', () => bulk('reset'));
|
|
</script>
|
|
</body>
|
|
</html>
|