Files
juli 5ad4fac46a Export packages and condition/works when adding items
- Export page: audience-specific zip with CSV, PDF catalogue (cover,
  contents, photos, details), optional full-size photos and JSON
- All-of + any-of selection (e.g. notable OR before 2000), PDF subset
  (all / notable / min value / top N), per-package privacy switches
- Presets: book dealer, computer museum, record dealer, auction house,
  insurance, charity, recycler, keepsakes; save your own
- Optional condition and works/untested dropdowns on web and Android
  capture; the AI keeps the team's answer unless photos contradict it
- App 1.4.0
2026-11-12 19:51:52 +01:00

129 lines
9.1 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>Add items · IndexiPro</title>
<meta name="theme-color" content="#0e1120">
<link rel="icon" href="/icons/favicon.svg" type="image/svg+xml">
<link rel="manifest" href="/manifest.webmanifest">
<link rel="stylesheet" href="/styles.css">
<style>
.wrap { max-width: 560px; margin: 0 auto; padding: 16px; }
.shoot { width: 100%; padding: 26px 16px; font-size: 1.2rem; border-style: dashed; border-width: 2px; }
.previews { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.previews .p { position: relative; aspect-ratio: 1; border-radius: 10px; background: var(--bg2) center/cover; }
.previews .p button { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; border: none; background: var(--red); color: #fff; padding: 0; }
.qty { display: flex; align-items: center; gap: 8px; }
.qty button { width: 42px; height: 42px; font-size: 1.3rem; }
.qty input { text-align: center; width: 70px; }
.recent li { display: flex; gap: 10px; align-items: center; }
.recent .ph { width: 48px; height: 48px; border-radius: 8px; background: var(--bg2) center/cover; flex: 0 0 48px; }
.submit { width: 100%; padding: 15px; font-size: 1.1rem; }
.codebig { font: 800 2.6rem var(--mono); color: var(--green); }
</style>
</head>
<body>
<header class="topbar">
<a class="brand" href="/"><img src="/icons/logo.svg" alt=""><span class="word">Indexi<b>Pro</b></span></a>
<span class="spacer"></span><a href="/#/todo" class="btn small" id="todo">Questions</a><a href="/" class="btn small">Browse</a>
</header>
<div class="wrap" id="root"><p class="muted">Loading…</p></div>
<input type="file" id="cam" accept="image/*" capture="environment" class="hidden">
<input type="file" id="gal" accept="image/*" multiple class="hidden">
<script type="module">
import { api, esc, toast, shrinkImage, fmtRange, ago } from '/common.js';
const root = document.getElementById('root');
const store = { get: (k, d) => { try { return localStorage.getItem(k) ?? d; } catch { return d; } }, set: (k, v) => { try { localStorage.setItem(k, v); } catch {} } };
const info = await api('/info');
if (info.me?.role === 'viewer') {
root.innerHTML = `<div class="card empty"><div class="big">👀</div><p>This is a read-only link — it can't add items.</p><p><a href="/">Back to the overview</a></p></div>`;
} else if (!info.me) {
root.innerHTML = `<div class="card empty"><div class="big">📷</div><p>To add items, scan the <b>join QR code</b> the organiser shows you with your phone camera.</p><p>Already have an account? <a href="/">Sign in</a></p></div>`;
} else {
let files = [];
root.innerHTML = `
<p class="muted small">Signed in as <b>${esc(info.me.name)}</b>. One item (or one pile of identical items) per entry. Take a few photos: all sides, plus any labels, signatures, stamps or maker's marks. Records & CDs: front, back, both labels / the disc.</p>
<button class="btn shoot" id="shoot">📷 Take photo</button>
<div class="row" style="margin-top:8px"><button class="btn small" id="pick">🖼 Choose from gallery</button></div>
<div class="previews" id="prev"></div>
<form id="f" class="grid">
<label class="f"><span>Note (optional)</span><textarea name="note" rows="3" placeholder="Anything you know: 'from the attic', 'powers on', 'box of 20 books'…"></textarea></label>
<div class="row" style="align-items:flex-end">
<label class="f" style="flex:1"><span>Location / box</span><input name="location" list="locs" value="${esc(store.get('ipx_loc', ''))}" placeholder="e.g. Shelf B3"></label>
<div><span class="small muted" style="display:block;margin-bottom:4px">QUANTITY</span>
<div class="qty"><button type="button" class="btn" id="minus">−</button><input name="quantity" type="number" min="1" value="1"><button type="button" class="btn" id="plus">+</button></div></div>
</div>
<div class="row">
<label class="f" style="flex:1;min-width:140px"><span>Condition (optional)</span><select name="condition">
<option value="">— not sure —</option><option value="new">New / unused</option><option value="excellent">Excellent</option><option value="good">Good</option>
<option value="fair">Fair — visible wear</option><option value="poor">Poor — damaged</option><option value="for_parts">For parts / broken</option></select></label>
<label class="f" style="flex:1;min-width:140px"><span>Works? (optional)</span><select name="working">
<option value="">— not applicable —</option><option value="working">Works</option><option value="partially">Partly works</option>
<option value="not_working">Doesn't work</option><option value="untested">Untested</option></select></label>
</div>
<datalist id="locs"></datalist>
<button class="btn primary submit" id="go">Save item</button>
</form>
<div class="card section hidden" id="done" style="text-align:center"></div>
<div class="card section"><h2>Your recent items</h2><ul class="feed recent" id="recent"></ul></div>`;
const prev = document.getElementById('prev');
const draw = () => {
prev.innerHTML = files.map((f, i) => `<div class="p" style="background-image:url(${f.url})"><button type="button" data-i="${i}">✕</button></div>`).join('');
document.getElementById('shoot').textContent = files.length ? `📷 Add another photo (${files.length})` : '📷 Take photo';
};
prev.onclick = (e) => { const i = e.target.dataset.i; if (i != null) { URL.revokeObjectURL(files[i].url); files.splice(i, 1); draw(); } };
const add = async (list) => { for (const f of list) { const s = await shrinkImage(f); files.push({ file: s, url: URL.createObjectURL(s) }); } draw(); };
document.getElementById('shoot').onclick = () => document.getElementById('cam').click();
document.getElementById('pick').onclick = () => document.getElementById('gal').click();
document.getElementById('cam').onchange = (e) => { add(e.target.files); e.target.value = ''; };
document.getElementById('gal').onchange = (e) => { add(e.target.files); e.target.value = ''; };
const q = document.querySelector('[name=quantity]');
document.getElementById('minus').onclick = () => { q.value = Math.max(1, (+q.value || 1) - 1); };
document.getElementById('plus').onclick = () => { q.value = (+q.value || 1) + 1; };
const meta = await api('/meta');
document.getElementById('locs').innerHTML = meta.locations.map((l) => `<option>${esc(l.location)}</option>`).join('');
const loadRecent = async () => {
const r = await api('/items?mine=1&limit=15');
document.getElementById('recent').innerHTML = r.items.length ? r.items.map((it) => `<li><a class="ph" href="/#/item/${it.id}" style="background-image:url(/photos/${it.cover_id}/thumb)"></a>
<div style="flex:1"><a href="/#/item/${it.id}" class="mono">#${it.id}</a> ${esc(it.title || 'waiting for AI…')}
<div class="small muted">${it.status === 'needs_info' ? `❓ ${esc(it.question || '')}` : ''} ${fmtRange(it.value_low, it.value_high, it.value_currency || meta.currency)} · ${ago(it.created_at)}</div></div></li>`).join('')
: '<li class="muted">Nothing yet.</li>';
};
loadRecent();
document.getElementById('f').onsubmit = async (e) => {
e.preventDefault();
const form = e.target;
if (!files.length && !form.note.value.trim()) return toast('Take at least one photo', true);
const btn = document.getElementById('go');
btn.disabled = true; btn.textContent = 'Uploading…';
const fd = new FormData();
files.forEach((f) => fd.append('photos', f.file));
fd.append('note', form.note.value);
fd.append('location', form.location.value);
fd.append('quantity', form.quantity.value);
if (form.condition.value) fd.append('condition', form.condition.value);
if (form.working.value) fd.append('working', form.working.value);
fd.append('client_id', crypto.randomUUID ? crypto.randomUUID() : String(Date.now() + Math.random()));
try {
const it = await api('/items', { method: 'POST', body: fd });
store.set('ipx_loc', form.location.value);
files.forEach((f) => URL.revokeObjectURL(f.url)); files = []; draw();
form.note.value = ''; q.value = 1; form.condition.value = ''; form.working.value = '';
const done = document.getElementById('done');
done.classList.remove('hidden');
done.innerHTML = `<div class="muted">Saved! Write this number on a sticker:</div><div class="codebig">#${it.id}</div>`;
loadRecent();
window.scrollTo({ top: 0, behavior: 'smooth' });
} catch (err) { toast(err.message, true); }
btn.disabled = false; btn.textContent = 'Save item';
};
}
</script>
</body>
</html>