From 06690f0581fab456d84d45fd69c8575e92745b14 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Thu, 13 Aug 2026 14:01:24 +0000 Subject: [PATCH] portal: multi-line topic scope input + 'Add topic' on existing MQTT clients Matches settings' new multi-topic-per-client support: the create form's Topic scope field is now a textarea (one pattern per line), the list shows all of a client's scopes, and a '+ Topic' button lets an admin grant an existing client more topic access without recreating it. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/pages/AdminSettings.tsx | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/pages/AdminSettings.tsx b/src/pages/AdminSettings.tsx index 0391ea7..2d9a46c 100644 --- a/src/pages/AdminSettings.tsx +++ b/src/pages/AdminSettings.tsx @@ -997,6 +997,19 @@ function MqttClientsTab() { if (res.ok) load() } + async function addTopic(c: MqttClient) { + const topic = prompt(`Add a topic scope to "${c.name}" (e.g. hvac/mhi/#) — existing scopes are kept:`) + if (!topic || !topic.trim()) return + const res = await fetch(`/settings/api/mqtt-clients/${c.id}`, { + method: 'PATCH', credentials: 'include', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ add_topic_scope: topic.trim() }), + }) + const data = await res.json() + if (!res.ok) { alert(data.error || 'Failed to add topic'); return } + load() + } + function copyPassword() { if (!created) return navigator.clipboard.writeText(created.password) @@ -1040,9 +1053,12 @@ function MqttClientsTab() { placeholder="e.g. Kitchen Flash Reader" style={inputStyle} />