From 9c456967656bdaccc6b37ebaa4452fd5fcb64351 Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Sat, 7 Mar 2026 22:50:23 +0100 Subject: [PATCH] cosnole --- modules/pi_control/assets/console.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/modules/pi_control/assets/console.js b/modules/pi_control/assets/console.js index e361122..a7db0b7 100644 --- a/modules/pi_control/assets/console.js +++ b/modules/pi_control/assets/console.js @@ -353,29 +353,37 @@ } return; } + const activeIframe = getActiveIframe(); + if (!activeIframe) { + if (consoleNotice) { + consoleNotice.textContent = 'Keine aktive Konsole – es wird eine neue Konsole geöffnet.'; + consoleNotice.style.display = 'block'; + } + submitOpen(); + return; + } const formData = new FormData(consoleForm); if (presetSelect) formData.set('terminal_preset_id', ''); const url = new URL(window.location.href); - url.searchParams.set('send_active_json', '1'); + url.searchParams.set('open_console_json', '1'); fetch(url.toString(), { method: 'POST', body: formData, cache: 'no-store' }) .then((res) => res.json()) .then((data) => { - if (data.ok) { + if (!data.ok) { if (consoleNotice) { - consoleNotice.textContent = data.notice || 'Befehl wurde in der bestehenden Konsole ausgeführt.'; + consoleNotice.textContent = data.error || 'Befehl konnte nicht ausgeführt werden.'; consoleNotice.style.display = 'block'; } - if (consoleError) consoleError.style.display = 'none'; return; } - if (consoleNotice) { - consoleNotice.textContent = data.error || 'Befehl konnte nicht in der bestehenden Konsole ausgeführt werden.'; - consoleNotice.style.display = 'block'; + if (data.url) { + activeIframe.src = data.url; } + if (consoleError) consoleError.style.display = 'none'; }) .catch(() => { if (consoleNotice) { - consoleNotice.textContent = 'Befehl konnte nicht in der bestehenden Konsole ausgeführt werden.'; + consoleNotice.textContent = 'Befehl konnte nicht ausgeführt werden.'; consoleNotice.style.display = 'block'; } });