From 7ec78cb76e80d62ca5d6e355b51f807453902ea9 Mon Sep 17 00:00:00 2001 From: beroth Date: Wed, 20 May 2026 10:56:36 -0600 Subject: [PATCH] new feats can delte session --- dashboard.html | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/dashboard.html b/dashboard.html index f3c3cdf..2b6216c 100644 --- a/dashboard.html +++ b/dashboard.html @@ -603,9 +603,16 @@
-
Phone: ${s.phone || "unknown"}
-
- ${statusText} +
+ ${s.name ? `${s.name} (${s.phone || 'unknown'})` : `Phone: ${s.phone || "unknown"}`} +
+
+
+ ${statusText} +
+
Summary: ${s.summary || "No summary yet."}
@@ -621,6 +628,42 @@ list.appendChild(card); }); + + list.querySelectorAll(".deleteSessionBtn").forEach(btn => { + btn.addEventListener("click", () => { + const phone = btn.dataset.phone; + const id = btn.dataset.id; + if (id && phone && phone !== 'unknown') { + deleteSession(id, phone); + } + }); + }); + } + + async function deleteSession(id, phone) { + if (!confirm(`Delete session for ${phone} and all its chat history?`)) return; + + const { error: historyError } = await supabaseClient + .from('n8n_chat_histories') + .delete() + .eq('session_id', id); + + if (historyError) { + alert('Error deleting chat history: ' + historyError.message); + return; + } + + const { error: sessionError } = await supabaseClient + .from('sessions') + .delete() + .eq('id', id); + + if (sessionError) { + alert('Error deleting session: ' + sessionError.message); + return; + } + + await loadSessions(); } // =============================