webserver: firmware setup page - non-blocking version check + layout fixes#1428
Open
kezarjg wants to merge 2 commits into
Open
webserver: firmware setup page - non-blocking version check + layout fixes#1428kezarjg wants to merge 2 commits into
kezarjg wants to merge 2 commits into
Conversation
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.
Contributor
|
I’m not evaluating the code itself, but the firmware page loads noticeably faster with the change. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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=updatecheckreturns{version, update, changelog}; page JS fills in the "…available" field, the update-available indicator, and the changelog once it returns. ReusesGetStatus+json_encode; no shell-output parsing.2. Firmware setup page layout alignment (cosmetic)
form-horizontalso their labels right-align and vertically align with their values, matching the tabbed sections (Bootstrap only styles.control-labelthat way inside.form-horizontal; these rows were rendered outside the form).Testing
Built clean (upstream
master+ these two commits only) and flashed to a hw3.1 module:?action=updatecheckreturns valid JSON withContent-Type: application/jsonandCache-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.Note: invalid UTF-8 in a server response passes through
json_encoderaw (the browser substitutes U+FFFD and still parses); pre-existingjson_encodebehavior, and the OTA server content is trusted/ASCII in practice.