// Admin dashboard — loads all data from the API function AdminScreen({ onSelectEntry, user }) { const [tab, setTab] = React.useState('queue'); const [adsEnabled, setAdsEnabled] = React.useState(false); const [adClient, setAdClient] = React.useState('ca-pub-XXXXXXXXXXXXXXXX'); const [stats, setStats] = React.useState({ pending_review: 0, flags_24h: 0, new_submissions_24h: 0, total_entries: 0, total_users: 0 }); const [modQueue, setModQueue] = React.useState([]); const [entries, setEntries] = React.useState([]); const [users, setUsers] = React.useState([]); const [auditLogs, setAuditLogs] = React.useState([]); const [activity, setActivity] = React.useState([0,0,0,0,0,0,0]); // Live state from /api/health: null while loading, then { api, db }. const [health, setHealth] = React.useState(null); // Load data from API React.useEffect(() => { window.api.getAdminStats().then(setStats).catch(() => {}); window.api.getModQueue('pending').then(data => setModQueue(data.queue || [])).catch(() => {}); window.api.getEntries({ limit: 20 }).then(data => setEntries(data.entries || [])).catch(() => {}); window.api.getUsers().then(data => setUsers(data.users || [])).catch(() => {}); window.api.getAuditLog(20).then(data => setAuditLogs(data.logs || [])).catch(() => {}); window.api.get('/health') .then(h => setHealth({ api: true, db: h.db === 'connected' })) .catch(() => setHealth({ api: false, db: false })); window.api.getActivity().then(data => setActivity(data.days || [0,0,0,0,0,0,0])).catch(() => {}); window.api.getSettings().then(settings => { setAdsEnabled(settings.GOOGLE_ADS_ENABLED === 'true'); setAdClient(settings.GOOGLE_ADS_CLIENT || 'ca-pub-XXXXXXXXXXXXXXXX'); }).catch(() => {}); }, []); const resolveModItem = async (id, action) => { try { await window.api.resolveModItem(id, action, 'admin'); setModQueue(modQueue.filter(m => m.id !== id)); // Refresh stats window.api.getAdminStats().then(setStats).catch(() => {}); } catch (err) { console.error('Resolve failed:', err); } }; const toggleAds = async () => { const newVal = !adsEnabled; setAdsEnabled(newVal); try { await window.api.updateSettings({ GOOGLE_ADS_ENABLED: newVal ? 'true' : 'false' }); } catch (err) { console.error('Settings update failed:', err); } }; const updateAdClient = async () => { try { await window.api.updateSettings({ GOOGLE_ADS_CLIENT: adClient }); } catch (err) { console.error('Settings update failed:', err); } }; const allUp = health && health.api && health.db; const sevColor = { high: 'var(--rose)', med: 'var(--amber)', low: 'var(--cyan)' }; const dayNames = ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN']; return (
{/* Admin top bar */}
◆ RESTRICTED · ADMIN CONSOLE

Archive oversight

Signed in as @{user?.username}
● {!health ? 'CHECKING…' : allUp ? 'ALL SYSTEMS NOMINAL' : 'DEGRADED'}
DATABASE · YugabyteDB
ENTRIES · {stats.total_entries} total
{/* Stats */}
{[ ['Pending review', stats.pending_review, 'var(--amber)'], ['Flags (24h)', stats.flags_24h, 'var(--rose)'], ['New submissions (24h)', stats.new_submissions_24h, 'var(--ink-0)'], ['Total users', stats.total_users, 'var(--cyan)'], ['Entries total', stats.total_entries, 'var(--ink-0)'], ].map(([l, v, c], i) => (
{l}
{v}
))}
{/* Tabs */}
{[ ['queue', `Moderation queue · ${modQueue.length}`], ['entries', 'All entries'], ['users', 'Users'], ['settings', 'Settings & revenue'], ['logs', 'Audit log'], ].map(([v, l]) => ( setTab(v)} style={{ padding: '14px 20px', cursor: 'pointer', fontSize: 13, fontFamily: 'var(--mono)', textTransform: 'uppercase', letterSpacing: '0.08em', color: tab === v ? 'var(--amber)' : 'var(--ink-1)', borderBottom: tab === v ? '2px solid var(--amber)' : '2px solid transparent', marginBottom: -1 }}> {l} ))}
{tab === 'queue' && (
{['All', 'PII', 'Duplicates', 'Harassment', 'Misinfo'].map((l, i) => ( {l} ))}
SEVIDTitleFlagged byWhenActions
{modQueue.map((r, i) => (
{r.id.slice(-8)}
{r.title}
{r.reason}
{r.flagged_by}
{r.created_at ? new Date(r.created_at).toLocaleDateString() : ''}
))} {modQueue.length === 0 && (
No pending items in the moderation queue.
)}
)} {tab === 'entries' && (
All types Last 30 days
IDTitleAuthorVotesFlagsFiledActions
{entries.slice(0, 8).map(e => (
{e.id.slice(-10)} {e.title} {e.author_name || e.author} {e.believe}/{e.skeptical} 300 ? 'var(--rose)' : 'var(--ink-2)' }}>{Math.floor(e.skeptical / 50)} {window.formatDate(e.date)}
))}
)} {tab === 'users' && (
UserEmailEntriesKarmaFlagsActions
{users.map((u, i) => (
{u.initials}
{u.name}
{u.status && u.status !== 'active' && {u.status.toUpperCase()}}
{u.email || '—'} {u.entries || 0} {u.karma} 0 ? 'var(--rose)' : 'var(--ink-2)' }}>{u.flags}
))}
)} {tab === 'settings' && (
REVENUE · GOOGLE ADS

Monetization

Enable discreet ad slots in sidebars and between entry results. Never shown on submission or admin pages.
Google AdSense publisher ID
setAdClient(e.target.value)} onBlur={updateAdClient} />
GOOGLE_ADS_ENABLED={adsEnabled ? 'true' : 'false'}
GOOGLE_ADS_CLIENT={adClient}
GOOGLE_ADS_SLOTS=sidebar,list-inline
DEPLOYMENT

Containerized instance

Rootless Podman runs two Caddy web replicas and two Node API replicas; the data lives in the shared YugabyteDB datastore. Status below is live.
$ bash ~/clients/infra/openufoarchive/redeploy.sh
{[ // This page loaded, so the web tier answered. ['web (Caddy)', 'running', 'var(--green)'], !health ? ['api (Node)', 'checking…', 'var(--ink-2)'] : health.api ? ['api (Node)', 'running', 'var(--green)'] : ['api (Node)', 'unreachable', 'var(--rose)'], !health ? ['database', 'checking…', 'var(--ink-2)'] : health.db ? ['database', 'YugabyteDB · connected', 'var(--cyan)'] : ['database', 'YugabyteDB · unreachable', 'var(--rose)'], ].map(([s, st, c]) => (
{s} ● {st}
))}
MODERATION POLICY

Auto-rules

{[ ['Auto-hide at ≥ 10 flags', true], ['Queue if poster < 24h old', false], ['Strip PII (email, phone) on save', true], ['Require Cloudflare Turnstile on sign-up and sign-in', true], ['Auto-approve verified users', true], ].map(([l, v], i) => ( ))}
ACTIVITY · LAST 7 DAYS
{activity.map((h, i) => (
))}
{dayNames.map(d => {d})}
)} {tab === 'logs' && (
{auditLogs.map((row, i) => (
{row.created_at ? new Date(row.created_at).toLocaleString() : ''} [{row.actor_role || row.actor}] {row.action} {row.target_id || ''} {row.detail || ''}
))} {auditLogs.length === 0 && (
No audit log entries yet.
)}
)}
); } window.AdminScreen = AdminScreen;