Skip to content

webserver: firmware setup page - non-blocking version check + layout fixes#1428

Open
kezarjg wants to merge 2 commits into
openvehicles:masterfrom
kezarjg:feature/firmware-page-improvements
Open

webserver: firmware setup page - non-blocking version check + layout fixes#1428
kezarjg wants to merge 2 commits into
openvehicles:masterfrom
kezarjg:feature/firmware-page-improvements

Conversation

@kezarjg

@kezarjg kezarjg commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Two related improvements to the firmware setup page (/cfg/firmware), in two commits.

1. Load the page instantly; check the server version in the background

Previously the page blocked on a synchronous MyOTA.GetStatus(info) that makes a blocking HTTP request to the OTA update server for the available version + changelog; adding time to page load when the module is online and the server is slow.

Now the page renders with GetStatus(info, false) (local-only, instant) and the server version is fetched asynchronously via a small JSON endpoint on the same handler: GET /cfg/firmware?action=updatecheck returns {version, update, changelog}; page JS fills in the "…available" field, the update-available indicator, and the changelog once it returns. Reuses GetStatus + json_encode; no shell-output parsing.

2. Firmware setup page layout alignment (cosmetic)

  • Wrap the "Firmware version" / "…available" status rows in a form-horizontal so their labels right-align and vertically align with their values, matching the tabbed sections (Bootstrap only styles .control-label that way inside .form-horizontal; these rows were rendered outside the form).
  • The "…available" row's value contains buttons (taller than the version text), so that row's label gets extra top padding to line up with the version number.
  • Left-align the "Auto flash" numbered list with the column's other text.

Testing

Built clean (upstream master + these two commits only) and flashed to a hw3.1 module:

  • ?action=updatecheck returns valid JSON with Content-Type: application/json and Cache-Control: no-cache; gated by the page's existing cookie/apikey auth (unauthenticated and wrong-key requests are denied; valid works); it is GET-only (a POST with the query param falls through to normal form handling) and returns before any form side effects.
  • JSON escaping verified for quotes, backslashes, control chars, and UTF-8.
  • Failure modes (offline / server unreachable / non-200 / empty body) → empty version → "no response from update server"; AJAX error or timeout → "update check failed".
  • Layout alignment verified visually in-browser.

Note: invalid UTF-8 in a server response passes through json_encode raw (the browser substitutes U+FFFD and still parses); pre-existing json_encode behavior, and the OTA server content is trusted/ASCII in practice.

kezarjg added 2 commits June 6, 2026 19:24
The firmware setup page blocked on MyOTA.GetStatus(), which makes a synchronous
HTTP request to the OTA update server for the 'available version' (and changelog)
on every render — adding up to ~a minute whenever the module is online and the
server is slow to answer.

Render the page with GetStatus(info, false) (local-only, instant) and fetch the
server version asynchronously: a small JSON endpoint on the same handler
(GET /cfg/firmware?action=updatecheck) performs the blocking check and returns
{version, update, changelog}; page JS fills in the '…available' field, the
update-available indicator, and the Version info changelog once it returns.
Reuses GetStatus + json_encode; no shell-output parsing.
Pre-existing cosmetic fixes on the /cfg/firmware page (no behaviour change):
- Wrap the 'Firmware version' / '...available' status rows in a form-horizontal
  div so their labels are right-aligned and vertically aligned with their values,
  matching the tabbed sections (Bootstrap only styles .control-label that way
  inside .form-horizontal; these rows were rendered outside the form).
- The '...available' row's value has buttons (taller than the version text) that
  push the version number to mid-row, so that row is emitted directly (not via
  input_info) with the label given extra top padding to line up with the version.
- Left-align the 'Auto flash' numbered list with the column's other text by
  dropping the default <ol> left indent.
@zorgms

zorgms commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

I’m not evaluating the code itself, but the firmware page loads noticeably faster with the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants