From 5a7893b11a18b7b4481a9fec9164479e9cd74c9c Mon Sep 17 00:00:00 2001 From: Chuck <33324927+ChuckBuilds@users.noreply.github.com> Date: Sun, 4 Oct 2026 23:18:02 -0400 Subject: [PATCH] feat(web): Schedule and General become ES-module pages (stage 3) (#767) * feat(web): Schedule and General become ES-module pages (stage 3) Schedule and General follow stage 2 (#727): no inline scripts or inline handlers in either partial. Their code moves to static/v3/js/pages/schedule.js and pages/general.js, started per swap-in by the page registry. - Schedule: both pickers are drawn from the saved config carried as JSON in data-* attributes. The forms' hx-on save handlers become one htmx:afterRequest listener on the page; the forms are marked data-reports-result, which app.js now treats like an hx-on after-request handler, so a save still shows one notification. - General: the timezone picker reads data-timezone. The Security section's forms and buttons are delegated data-actions; requests go through core/api.js, so the login redirect is quiet, and a change made just before a swap is still reported. - handleScheduleResponse, handleDimScheduleResponse and webLogin stay as deprecated aliases through window.LEDMatrix. - New DOM suites test_schedule_page.js and test_general_page.js; the web login unit suite imports the module; test_es_modules.py pins the pages, the aliases, and the schedule config's round trip through its attribute. Co-Authored-By: Claude Opus 5.5 * refactor(web): no unused catch bindings or computed writes in the stage 3 modules Codacy flagged two unused catch variables and dynamic-key writes in pages/schedule.js and boot.js. The schedule config is read with getAttribute, and the default days and the webLogin alias object are built with Object.fromEntries. No behaviour change. Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 --- CHANGELOG.md | 28 ++ docs/WEB_FRONTEND_ARCHITECTURE.md | 14 +- test/js/README.md | 4 +- test/js/dom/test_general_page.js | 272 ++++++++++++++++++ test/js/dom/test_schedule_page.js | 167 +++++++++++ test/js/run_all.js | 3 +- test/js/unit/test_general_web_login_token.js | 75 ++--- test/js/unit/test_restart_banner.js | 27 +- test/web_interface/test_es_modules.py | 40 ++- web_interface/static/v3/app.js | 6 +- web_interface/static/v3/js/core/boot.js | 32 ++- web_interface/static/v3/js/pages/general.js | 262 +++++++++++++++++ web_interface/static/v3/js/pages/schedule.js | 176 ++++++++++++ .../templates/v3/partials/general.html | 172 +---------- .../templates/v3/partials/schedule.html | 212 +------------- 15 files changed, 1069 insertions(+), 421 deletions(-) create mode 100644 test/js/dom/test_general_page.js create mode 100644 test/js/dom/test_schedule_page.js create mode 100644 web_interface/static/v3/js/pages/general.js create mode 100644 web_interface/static/v3/js/pages/schedule.js diff --git a/CHANGELOG.md b/CHANGELOG.md index c027e85c..4c94c537 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,34 @@ accepts both, but the store flags the old spelling as deprecated ## Unreleased +### Web UI: Schedule and General are ES-module pages (stage 3) + +- The Schedule and General tabs follow stage 2 (#727): their inline + `
@@ -216,7 +195,7 @@ the password inputs keep their own labels. #} -
+ {% if web_login.enabled %}
@@ -251,7 +230,7 @@ {% if web_login.enabled %}

Turn login off

- +
created {{ (token.created_at or '')[:10] }}
@@ -289,7 +267,7 @@

No tokens yet.

{% endfor %}
- +
@@ -312,131 +290,5 @@
- {% endif %} + diff --git a/web_interface/templates/v3/partials/schedule.html b/web_interface/templates/v3/partials/schedule.html index 8b376983..5ed53ea6 100644 --- a/web_interface/templates/v3/partials/schedule.html +++ b/web_interface/templates/v3/partials/schedule.html @@ -1,4 +1,13 @@ {% import 'v3/partials/_macros.html' as ui %} +{# No inline script: static/v3/js/pages/schedule.js draws both schedule + pickers from the data-*-config attributes, reports each form's save and + keeps the dim brightness label current. The page registry + (static/v3/js/core/registry.js) starts it when this root appears and stops + it when the partial is swapped away. The forms carry data-reports-result so + app.js leaves the save notification to the page. #} +

Schedule Settings

@@ -12,7 +21,7 @@ hx-ext="json-enc" hx-headers='{"Content-Type": "application/json"}' hx-swap="none" - hx-on:htmx:after-request="handleScheduleResponse(event)" + data-reports-result class="space-y-6"> @@ -41,7 +50,7 @@ hx-ext="json-enc" hx-headers='{"Content-Type": "application/json"}' hx-swap="none" - hx-on:htmx:after-request="handleDimScheduleResponse(event)" + data-reports-result class="space-y-6"> @@ -56,8 +65,7 @@ min="0" max="100" value="{{ dim_schedule_config.dim_brightness | default(30) }}" - class="flex-1 h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-blue-600" - oninput="document.getElementById('dim_brightness_display').textContent = this.value + '%'"> + class="flex-1 h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-blue-600"> {{ dim_schedule_config.dim_brightness | default(30) }}% @@ -77,198 +85,4 @@
- - +