From 3ddd2a2b1e08d4513bfc1df222d7e7fc0a32515a Mon Sep 17 00:00:00 2001 From: Andrei Smaliak Date: Tue, 8 Sep 2026 08:48:34 +0200 Subject: [PATCH] Fix fullscreen launch and embedded Edge Console navigation --- stage_itscreen/stage_itscreen_install.sh | 2 +- stage_itscreen/test_fullscreen_contract.py | 17 ++++++++++ ...st_embedded_console_navigation_contract.py | 31 +++++++++++++++++++ stage_ui/console_core/frontend/console.js | 15 ++++++--- 4 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 stage_itscreen/test_fullscreen_contract.py create mode 100644 stage_ui/console_core/backend/test_embedded_console_navigation_contract.py diff --git a/stage_itscreen/stage_itscreen_install.sh b/stage_itscreen/stage_itscreen_install.sh index faf7d32..2739d61 100755 --- a/stage_itscreen/stage_itscreen_install.sh +++ b/stage_itscreen/stage_itscreen_install.sh @@ -524,7 +524,7 @@ LOCK="${LOCK_FILE}" export XDG_CONFIG_HOME=/var/lib/itscreen/config export XDG_DATA_HOME=/var/lib/itscreen/data export ITSCREEN_LOG_DIR=/var/lib/itscreen/logs -exec flock -n "\$LOCK" /opt/itscreen/bin/itscreen fullscreen "\$@" +exec flock -n "\$LOCK" /opt/itscreen/bin/itscreen --fullscreen "\$@" EOF } diff --git a/stage_itscreen/test_fullscreen_contract.py b/stage_itscreen/test_fullscreen_contract.py new file mode 100644 index 0000000..d313849 --- /dev/null +++ b/stage_itscreen/test_fullscreen_contract.py @@ -0,0 +1,17 @@ +import pathlib +import unittest + + +INSTALLER = pathlib.Path(__file__).with_name("stage_itscreen_install.sh") + + +class FullscreenContractTest(unittest.TestCase): + def test_wrapper_passes_declared_command_line_option(self): + installer = INSTALLER.read_text(encoding="utf-8") + + self.assertIn("/opt/itscreen/bin/itscreen --fullscreen", installer) + self.assertNotIn("/opt/itscreen/bin/itscreen fullscreen", installer) + + +if __name__ == "__main__": + unittest.main() diff --git a/stage_ui/console_core/backend/test_embedded_console_navigation_contract.py b/stage_ui/console_core/backend/test_embedded_console_navigation_contract.py new file mode 100644 index 0000000..8fddff7 --- /dev/null +++ b/stage_ui/console_core/backend/test_embedded_console_navigation_contract.py @@ -0,0 +1,31 @@ +import pathlib +import unittest + + +FRONTEND = pathlib.Path(__file__).resolve().parents[1] / "frontend" + + +class EmbeddedConsoleNavigationContractTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.source = (FRONTEND / "console.js").read_text(encoding="utf-8") + + def test_local_service_links_can_navigate_in_embedded_webview(self): + self.assertNotIn('target="_blank"', self.source) + self.assertIn('browserHost === "127.0.0.1"', self.source) + self.assertIn('browserHost === "localhost"', self.source) + + def test_registration_reset_uses_console_dialog(self): + reset_start = self.source.index("window.__itscreenReset = async function") + reset_end = self.source.index("window.__setItscreenLogSearch", reset_start) + reset_source = self.source[reset_start:reset_end] + self.assertIn("await confirmAction(", reset_source) + self.assertNotIn("window.confirm", reset_source) + + def test_webui_service_is_named_edge_console(self): + self.assertIn('label: "Edge Console"', self.source) + self.assertNotIn('label: "Edge WEB UI"', self.source) + + +if __name__ == "__main__": + unittest.main() diff --git a/stage_ui/console_core/frontend/console.js b/stage_ui/console_core/frontend/console.js index 42ccc2e..524af4d 100644 --- a/stage_ui/console_core/frontend/console.js +++ b/stage_ui/console_core/frontend/console.js @@ -1314,7 +1314,7 @@ const tunnelLinks = [ { name: "cockpit", label: "Cockpit", href: `https://${host}:9090` }, { name: "z2m", label: "Zigbee2MQTT", href: `http://${host}:8081` }, - { name: "webui", label: "Edge WEB UI", href: `http://${host}:8099` } + { name: "webui", label: "Edge Console", href: `http://${host}:8099` } ]; const restartBusy = !!state.serviceActions.busyById[card.id]; @@ -1386,7 +1386,7 @@ ${tunnelLinks.map((link) => { const tunnel = tunnels.find((item) => item.name === link.name); return tunnel && tunnel.active - ? `${esc(t(link.label))}` + ? `${esc(t(link.label))}` : ``; }).join("")} @@ -2089,6 +2089,8 @@ } function currentAccessHost() { + const browserHost = textValue(window.location.hostname, "").toLowerCase(); + if (browserHost === "127.0.0.1" || browserHost === "localhost") return browserHost; const identity = state.identity || {}; return textValue(identity && identity.endpoint_host, textValue(identity && identity.primary_ipv4, textValue(identity && identity.hostname, window.location.hostname || "localhost"))); } @@ -2132,7 +2134,7 @@
${action ? (action.disabled ? `` - : `${esc(action.label)}` + : `${esc(action.label)}` ) : ""} ${restartable ? `` @@ -5467,7 +5469,12 @@ }; window.__itscreenReset = async function () { - if (!window.confirm(t("Reset current cloud registration?\n\nThe device will forget its current cloud binding and can be registered again."))) return; + const confirmed = await confirmAction( + t("Reset current cloud registration?"), + t("The device will forget its current cloud binding and can be registered again."), + t("Reset") + ); + if (!confirmed) return; state.itscreen.error = ""; state.itscreen.busyAction = "reset"; if (state.activeTab === "tscreen") renderActiveTab();