Repository navigation
feature: estimated watts, sortable fleet table, and page-timer refresh - #54
Merged
Merged
Conversation
- Estimate each UPS's power as nominal power x load % for UPSes that do not report real wattage (apcupsd_estimate_watts()). Show it on the Fleet Dashboard as an "Est. Power" tile, a new "Fleet Power" gauge card (total estimated watts against rated capacity) and an "Est. Power" column with a fleet total in the UPSes card, and as a sortable "Est. Power" column in the UPSes list. - Make the Fleet Dashboard UPSes table sortable by UPS, Status, Load, Charge, Time Left, Est. Power and Last Updated. N/A values sort last, ties keep server order, and the choice persists in the browser across refreshes. - Drive the dashboard auto-refresh through Cacti's refreshMSeconds / refreshPage / refreshIsLogout globals (as graph_view.php does) instead of set_page_refresh(), which parked the interval in the session so it could follow the user to another page. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Fleet-table sorting loses the selected order when browser storage is unavailable or writes fail.
1 open finding
What changed in this PR
Adds estimated power reporting and sortable fleet data to the Cacti plugin, and changes dashboard refresh handling.
Changes:
- Adds estimated wattage to fleet cards and UPS tables.
- Adds persistent, accessible fleet-table sorting.
- Uses Cacti’s page timer instead of session-based refresh settings.
| File | Description |
|---|---|
| upses.php | Adds sortable estimated power column. |
| tests/Unit/EstimatedWattsTest.php | Tests wattage calculation and feature wiring. |
| tests/Unit/DashboardRefreshTest.php | Checks refresh integration patterns. |
| locales/po/cacti.pot | Adds translation strings. |
| js/apcupsd_dashboard.js | Implements persistent table sorting. |
| includes/functions.php | Adds wattage estimation helper. |
| includes/dashboard.php | Adds fleet power displays and page-timer refresh. |
| css/apcupsd.css | Styles sorting controls and fleet totals. |
| CHANGELOG.md | Documents features and refresh changes. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
xmacan
previously approved these changes
Oct 16, 2026
apcupsdDashApplySort() re-read localStorage after each click, so when storage was blocked or a write failed the newly selected sort was lost (or an older saved sort was reapplied). Hold the active sort state in memory, seed it once from localStorage, and make persistence best-effort so sorting and direction toggling work without storage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
xmacan
approved these changes
Oct 16, 2026
xmacan
approved these changes
Oct 16, 2026
TheWitness
added a commit
that referenced
this pull request
Oct 16, 2026
… reuse apcupsd_estimate_watts() - Share only the fixed-card arrangement across UPSes; store each UPS's graph cards (local_graph_id keys) in their own row with a graphs_slot marker so saving from one UPS no longer overwrites or hides another UPS's graphs. - Persist a layout migrated from the per-UPS row or the pre-release combined map to the shared row on first read, with the existing 4096-char guard. - Compute the per-UPS Estimated Power card with the shared apcupsd_estimate_watts() added in #54 instead of duplicating the formula. - Add DashboardLayoutTest and a CHANGELOG entry. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
TheWitness
added a commit
that referenced
this pull request
Oct 16, 2026
… Power card (#51) * dashboard: shared layout, hide N/A in info card, combine Cable/Driver, add Estimated Power card * dashboard: keep graph cards per UPS, persist legacy layout migration, reuse apcupsd_estimate_watts() - Share only the fixed-card arrangement across UPSes; store each UPS's graph cards (local_graph_id keys) in their own row with a graphs_slot marker so saving from one UPS no longer overwrites or hides another UPS's graphs. - Persist a layout migrated from the per-UPS row or the pre-release combined map to the shared row on first read, with the existing 4096-char guard. - Compute the per-UPS Estimated Power card with the shared apcupsd_estimate_watts() added in #54 instead of duplicating the formula. - Add DashboardLayoutTest and a CHANGELOG entry. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * dashboard: exclude slave UPSes from fleet estimated power and show N/A A slave's draw is already part of its master's, so leave it out of the fleet power total, capacity and count, and show N/A for its Est. Power in the Fleet Dashboard table. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * dashboard: preserve graph placement per run, keep shared slots for graphless UPSes, migrate each UPS's legacy graphs - Store one graphs_slot marker per run of consecutive graph cards and one graph run per marker, so graphs interleaved with fixed cards keep their placement across a save/reload. - When a UPS with no graphs saves, re-anchor the existing shared slots to the nearest surviving fixed card instead of dropping them. - When the shared row already exists but a UPS has no graph row, migrate and persist that UPS's own legacy graph selection (per-UPS row, then combined map) before defaulting to all graphs; the shared fixed layout is unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

Summary
Adds estimated wattage for UPSes that do not report real output power, makes the Fleet Dashboard UPSes table sortable, and fixes the dashboard auto-refresh following the user to other pages.
1. Estimated watts (
nominal power x load % / 100)New
apcupsd_estimate_watts()inincludes/functions.php(unit-tested) so every view derives the figure the same way. It returns null for missing, non-numeric or negative inputs, or when the nominal power is not a positive rating. Load above 100% is not clamped.upses.php): a sortable "Est. Power" column, computed in SQL and validated as a sort column through the existing header definitions.Only enabled UPSes contribute to totals. A disabled UPS shows N/A because its last reading is no longer polled. The fleet figures come from the latest poll, not an RRD window.
2. Sortable Fleet Dashboard table
Columns UPS, Status, Load, Charge, Time Left, Est. Power and Last Updated are sortable. I read "Charts" in the request as the Charge column; the table has no chart column.
localStorage(keyed by column, not position) and re-applied after card refreshes, added cards and the maximize dialog.<button>s witharia-sort; there are no inline handlers (CSP-safe).3. Auto-refresh no longer follows you to other pages
Both dashboards used
set_page_refresh(), which parks the interval in the PHP session until some page's footer consumes it, so the dashboard's interval andrefreshPagecould be applied to whichever page rendered next. They now set Cacti'srefreshMSeconds,refreshPageandrefreshIsLogoutglobals from a ready callback and callsetupPageTimeout(), the same way core'sgraph_view.phpdoes. Nothing is stored in the session; Cacti already clears its timer when navigating, and the next page's footer re-emits its own values. The callback only applies while the dashboard grid is still on the page. I did not add a plugin-side timer or navigation handler.I could not reproduce the stale-refresh symptom without a live Cacti, so this change follows the cause I identified from core's
global_session.phpandlayout.js; please confirm it on a live install.Notes
includes/dashboard.phpandlocales/po/cacti.pot, which should be easy to resolve.locales/po/cacti.potandCHANGELOG.mdare updated.Validation
EstimatedWattsTestandDashboardRefreshTest.check-i18n-pot.phpgate passes.aria-sort, and server-order ties.