Repository navigation
update the dashboard in place instead of blanking it every 30 seconds - #11
Merged
Merged
Conversation
Every 30 seconds the poll timer replaced what was on screen with a "loading" line before the new data arrived: the chart effect cleared its history, and the diagnostics view cleared its tables, on every run rather than only when the query changed. The chart then re-entered with its 500 ms animation. Taken together that reads as the page reloading itself twice a minute. Both views now keep what they show while the next payload is fetched, and only empty themselves when the range, inverter or period actually changes — where stale data would be wrong rather than merely old. The chart series animate on their first payload and swap values silently afterwards. A failed poll no longer empties anything either. The status cards keep the last reading and the header gains an offline badge, so a network hiccup costs a badge rather than the whole page.
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.
The dashboard looked like it reloaded itself twice a minute. It never did —
there is no
location.reloadanywhere — but the effect was the same, becausethe periodic poll emptied the views before refilling them.
Three causes, all on the 30-second timer:
HistoryChartcalledsetHistory(null)at the top of its fetch effect, sothe chart was replaced by the "loading" line for the length of the request
and then re-entered with its 500 ms animation.
DiagnosticsViewdid the same withsetDiagnostics(null), and its effectruns on
refreshKey, which the status poll bumps every 30 seconds.setStatus(null), so one missed request emptiedthe cards and the header.
What changes
Both views keep what is on screen while the next payload is fetched. They empty
themselves only when the query identity changes — range, inverter, day/week/
month/year — where showing the previous period's numbers under the new heading
would be wrong rather than merely stale. Each tracks the query its current data
belongs to and compares before clearing.
The chart series animate on the first payload of a chart and swap values
silently afterwards (
isAnimationActivefollows that flag), so a refreshupdates the curve without replaying the entry animation.
A failed poll keeps the last reading.
ServiceStatusgains anofflinepropand shows a badge beside the version, so a network hiccup costs a badge instead
of the whole page. The cards still say "connecting" until the very first
response arrives.
SystemViewalready merged pages into its ring and needed no change; it clearsonly when a filter changes, which is a query change and correct.
Testing
pnpm testandpnpm run buildpass, and the dashboard type-checks.Not verified against a running instance — this machine has no smalog database
to serve the dashboard from, so the change is reasoned from the render path
rather than observed. What to look for on the Pi: the chart and the diagnostics
tables should now change values without going blank, and pulling the network
should leave the numbers standing with an offline badge in the header.