From 3d33c4dcb5bb8cfac56339420bd91edf68f27df0 Mon Sep 17 00:00:00 2001
From: jotaen4tinypilot <83721279+jotaen4tinypilot@users.noreply.github.com>
Date: Fri, 26 Jul 2024 18:13:04 +0200
Subject: [PATCH] Add network status dialog (#1829)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Resolves https://github.com/tiny-pilot/tinypilot/issues/1814. Stacked on
https://github.com/tiny-pilot/tinypilot/pull/1828.
This PR adds a new “Status” dialog to the “Network” submenu, which
displays basic network connectivity information in (almost) realtime.
The screen recording below shows two browser windows side by side, and
how the Network Status dialog updates itself automatically when there
are changes.
https://github.com/user-attachments/assets/b11081cc-364a-4816-a8c2-474750d8def4
Notes:
- I’ve set the update frequency to `2,5s`, which seemed like a
reasonable compromise between “realtime enough” and not overloading the
backend on lower-latency connections.
- For the case when the IP address or MAC address are absent, I’ve
debated whether to show `n/a` or whether to hide the row altogether. I’m
not strongly attached to the `n/a` placeholder, but to me it felt better
to show the row consistently, instead of having the UI jump around as
fields are inserted and removed.
---------
Co-authored-by: Jan Heuermann
---
app/static/js/app.js | 7 +
app/templates/custom-elements/menu-bar.html | 7 +
.../network-status-dialog.html | 143 ++++++++++++++++++
.../network-status-interface.html | 124 +++++++++++++++
app/templates/index.html | 5 +
5 files changed, 286 insertions(+)
create mode 100644 app/templates/custom-elements/network-status-dialog.html
create mode 100644 app/templates/custom-elements/network-status-interface.html
diff --git a/app/static/js/app.js b/app/static/js/app.js
index 84667befc..e8e54ef26 100644
--- a/app/static/js/app.js
+++ b/app/static/js/app.js
@@ -327,6 +327,13 @@ menuBar.addEventListener("wifi-dialog-requested", () => {
document.getElementById("wifi-overlay").show();
document.getElementById("wifi-dialog").initialize();
});
+menuBar.addEventListener("network-status-dialog-requested", () => {
+ // Note: we have to call `initialize()` after `show()`, to ensure that the
+ // dialog is able to focus the main input element.
+ // See https://github.com/tiny-pilot/tinypilot/issues/1770
+ document.getElementById("network-status-overlay").show();
+ document.getElementById("network-status-dialog").initialize();
+});
menuBar.addEventListener("fullscreen-requested", () => {
document.getElementById("remote-screen").fullscreen = true;
});
diff --git a/app/templates/custom-elements/menu-bar.html b/app/templates/custom-elements/menu-bar.html
index 85d350089..e2809f087 100644
--- a/app/templates/custom-elements/menu-bar.html
+++ b/app/templates/custom-elements/menu-bar.html
@@ -239,6 +239,13 @@
>Static IP
+