From 788ee1539d874f4eda4c24917b87f29e4271cbf7 Mon Sep 17 00:00:00 2001 From: Otto Date: Sun, 31 May 2026 16:26:37 +0200 Subject: [PATCH] feat(dashboard): richer engram detail overlay --- templates/dashboard.html | 84 +++++++++++++++++++++++++++++++++------- 1 file changed, 69 insertions(+), 15 deletions(-) diff --git a/templates/dashboard.html b/templates/dashboard.html index d7c3c90..8c5141f 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -1007,9 +1007,11 @@ function escapeHtml(t) { } // ─── Actions ──────────────────────────────────────────────────────────────── -async function confirm(id, ev) { +async function confirm(id, ev, ctx = 'card') { ev.stopPropagation(); - const reason = document.getElementById('reason-'+id).value; + const reasonElId = (ctx === 'modal') ? ('reason-modal-' + id) : ('reason-' + id); + const reasonEl = document.getElementById(reasonElId); + const reason = reasonEl ? reasonEl.value : ''; await api(`/api/engrams/${id}/confirm`, { method: 'POST', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, @@ -1020,9 +1022,11 @@ async function confirm(id, ev) { if (state.view === 'status') loadStatus(); } -async function reject(id, ev) { +async function reject(id, ev, ctx = 'card') { ev.stopPropagation(); - const reason = document.getElementById('reason-'+id).value; + const reasonElId = (ctx === 'modal') ? ('reason-modal-' + id) : ('reason-' + id); + const reasonEl = document.getElementById(reasonElId); + const reason = reasonEl ? reasonEl.value : ''; await api(`/api/engrams/${id}/reject`, { method: 'POST', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, @@ -1058,18 +1062,62 @@ async function createEngram() { async function showDetail(id) { const item = await api(`/api/engrams/${id}`); const body = document.getElementById('modalBody'); + const links = (item.links || []); + const suggestions = (item.link_suggestions || []).concat(item.predictive_links || []); + const suggHtml = suggestions.length ? suggestions.map(s => ` +
+ ${s.engram_id.substring(0,8)} + ${escapeHtml(s.preview || s.content_preview || '')} + +
+ `).join('') : 'Keine Vorschläge'; body.innerHTML = ` -

Engramm ${item.id.substring(0,8)}

-

Confidence: ${Math.round(item.confidence*100)}%

-

Confirmed: ${item.confirmed ? '✅' : '❌'}

-

Tags: ${item.tags.map(t => ''+t+'').join(' ')}

-

Content:

-
${escapeHtml(item.content)}
-

History:

- -

Links: ${item.links?.join(', ') || 'none'}

+

Engramm ${item.id.substring(0,8)}

+
verdict
${renderVerdictPill(item)} ${Math.round(item.confidence*100)}%
+
source
${escapeHtml(item.source || '-')}
+
created
${fmtDate(item.created)}
+
modified
${fmtDate(item.modified)}
+
access
${item.access_count ?? 0} • grounding ${item.grounding ?? 0}
+
tags
${(item.tags || []).map(t => ''+escapeHtml(t)+'').join(' ') || '-'}
+ +
Content
+
${escapeHtml(item.content || '')}
+ +
+
Vorschläge
+
${suggHtml}
+
+ +
+
Links
+
+ ${links.length ? links.map(l => `${l.substring(0,8)}`).join(' ') : 'none'} +
+
+ + ${Array.isArray(item.evidence) && item.evidence.length ? ` +
+
Evidence
+ +
` : ''} + +
+
History
+ +
+ + `; document.getElementById('detailModal').classList.add('open'); } @@ -1120,6 +1168,12 @@ setInterval(() => { // ─── Init ─────────────────────────────────────────────────────────────────── loadStats(); loadCards(); +document.getElementById('detailModal').addEventListener('click', (e) => { + if (e.target && e.target.id === 'detailModal') closeModal(); +}); +document.addEventListener('keydown', (e) => { + if (e.key === 'Escape') closeModal(); +}); function renderCardsWithSuggestions() { const el = document.getElementById('cards'); el.innerHTML = state.items.map(item => {