Skip to content

fix: dashboard fixes (Status column, Refresh without reload, RRD matching, Fleet Power range) and a Run Graph Automation action - #56

Merged
bmfmancini merged 5 commits into
developfrom
fix/fleet-status-column-center
Oct 16, 2026
Merged

bmfmancini merged 5 commits into
developfrom
fix/fleet-status-column-center

Conversation

@TheWitness

@TheWitness TheWitness commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Dashboard fixes found while reviewing the UPS and Fleet dashboards.

  • Status column centred in the Fleet Dashboard UPSes card (header and pills). The rule outranks .apcupsdDashTable th, .apcupsdDashTable td { text-align: left }.
  • Refresh dropdown no longer reloads the page. It saves the preference, then swaps the running refresh timer for the new interval (or stops it for "No Refresh") in place, on both the Cacti 1.3+ refreshFunction path and the Cacti 1.2.x own-timer path. A failed save reverts the dropdown and shows the error. Both grids expose their refresh URL as data-refresh-page.
  • UPS Dashboard bullets and gauges find the Device Package's data sources. They looked for batt_volts / line_volts / output_volts / batt_charge under other names, so Battery, Line and Output Voltage never found an RRD even with graphs present. The RRD profile's consolidation functions are now read first; when an RRD has no MIN or MAX archive the window is bounded by its averages instead of leaving a bound blank. One shared apcupsd_dashboard_rrd_stats() serves the UPS bullets, UPS gauges and the fleet aggregates.
  • Bullet and gauge text: the bullet track ends are labelled with the axis (0 and the full-scale value), the known now/min/avg/max readings are listed above it, and unknown ones are left out instead of printed as N/A. Gauge captions do the same.
  • Fleet Power gauge now has min/max ticks and a min / avg / max caption like the other fleet gauges: each UPS's load RRD is scaled by its (constant) nominal power and summed, and a UPS without history counts at its latest estimate so the range matches the total shown. Min and max are sums of each UPS's own bounds, so they bound the fleet's draw rather than being the exact extremes of the sum.
  • New "Run Graph Automation" action in the UPSes list bulk-action dropdown. It runs Cacti's graph automation (the same as the Devices page's "Apply Automation Rules") for the Cacti Device linked to each selected UPS, so a device that never got its graphs, and therefore has no RRD history for the dashboards, can be given them without leaving the plugin. It is offered only to users with the Sites/Devices/Data realm (the realm core uses for the equivalent device action) and refused server side otherwise, and a UPS with no Cacti Device yet is skipped and reported. Graphs that already exist are left alone.
  • Debug log lines (APCUPSD, debug verbosity) say why a reading has no RRD history.
  • NutWiringTest requires nut.php itself instead of depending on test order.

Note

Min/avg/max come from the device's RRD files and the current value from the database. A device with no graphs has no RRD files, so it has no history to show (the readings then show just the current value). That turned out to be the cause of the blank bounds that prompted part of this work; the data source name matching and the no-MIN fallback are real fixes for devices that do have graphs.

Testing

DashboardRrdStatsTest (data source matching against the package's real names, series and stats including no-MIN and no-MAX archives, fleet power range, bullet and gauge text), plus updated EstimatedWattsTest and DashboardRefreshTest. check-i18n-pot and validate-manifest pass.

… without a page reload

- Centre the Status header and pills in the UPSes card; the rule has to
  outrank .apcupsdDashTable th/td { text-align: left }.
- Changing the Refresh dropdown no longer forces a full page reload. The
  preference is saved, then the running timer is swapped for the new
  interval (or stopped for No Refresh) in place. Both grids expose their
  refresh URL as data-refresh-page so this also works when the page was
  loaded with refresh off. A failed save reverts the dropdown and shows
  the error on the status line.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 18:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Refresh changes can misapply overlapping saves, leave the visible picker stale after failure, and disable browser auto-logout.

3 open findings
What changed in this PR

Improves Fleet Dashboard alignment and lets both dashboards change refresh intervals without reloading.

Changes:

  • Centres Status headers and pills.
  • Applies refresh intervals in place, with save-failure handling.
  • Updates regression checks and the changelog.
File Description
tests/​Unit/​EstimatedWattsTest.php Checks Status alignment markup and CSS.
tests/​Unit/​DashboardRefreshTest.php Checks refresh URLs and timer-update code.
js/​apcupsd_dashboard.js Updates timers and handles preference-save responses.
includes/​dashboard.php Adds refresh URLs and column alignment classes.
css/​apcupsd.css Centres Status cells and headers.
CHANGELOG.md Documents both dashboard changes.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread js/apcupsd_dashboard.js
Comment thread js/apcupsd_dashboard.js Outdated
Comment thread js/apcupsd_dashboard.js Outdated
TheWitness and others added 2 commits October 16, 2026 14:48
…et and gauge text

- Match the Device Package's real data source names (batt_volts, line_volts,
  output_volts, batt_charge) so Battery, Line and Output Voltage find an RRD.
- Read the profile's consolidation functions first and, without a MIN or MAX
  archive (many RRDs have no MIN), bound the window by its averages instead
  of leaving the lower bound blank. One shared apcupsd_dashboard_rrd_stats()
  now serves the UPS bullets, UPS gauges and the fleet aggregates.
- Bullets label the track ends with the axis (0 .. scale) and list the known
  now/min/avg/max readings; unknown ones are left out instead of N/A. Gauge
  captions do the same.
- Fleet Power gets min/max ticks and a min/avg/max caption from each UPS's
  load RRD scaled by its constant nominal power; UPSes without history count
  at their latest estimate so the range matches the total shown.
- Debug log lines say why a reading has no RRD history.
- NutWiringTest requires nut.php itself instead of relying on test order.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@TheWitness TheWitness changed the title fix: centre the Fleet Dashboard Status column; apply Refresh interval without a page reload fix: dashboard Status column, Refresh without reload, RRD data source matching and Fleet Power range Oct 16, 2026
Add a bulk action that runs Cacti's graph automation (the same as the
Devices page's Apply Automation Rules) for the Cacti Device linked to each
selected UPS, so a device that never got its graphs, and so has no RRD
history for the dashboards, can be given them without leaving the plugin.

- Offered only to users with the Sites/Devices/Data realm (core's realm for
  the equivalent device action) and refused server side otherwise.
- Skips and reports a UPS that has no Cacti Device yet; the device id is
  looked up from the UPS id with a prepared query.
- Documented in the README and CHANGELOG, with translatable strings.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@TheWitness TheWitness changed the title fix: dashboard Status column, Refresh without reload, RRD data source matching and Fleet Power range fix: dashboard fixes (Status column, Refresh without reload, RRD matching, Fleet Power range) and a Run Graph Automation action Oct 16, 2026
- Turning Refresh off now puts Cacti's browser auto-logout timer back. The
  original settings are remembered when the script loads, before the
  dashboard overrides them, and restored (and re-armed) for No Refresh; a
  page reload used to do this.
- A failed save rolls the dropdown back through its Select2 / selectmenu
  widget (a namespaced trigger, so the save handler does not run again).
- Saves are serialized: one in flight, a choice made meanwhile is sent when
  it settles, and only a value that was actually saved updates the timer and
  the rollback state.
- Print the dashboard script before the script that starts the refresh, so
  its functions exist when Cacti runs ajax-loaded scripts in order; before,
  the first ajax visit fell back to the full-page timer.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bmfmancini
bmfmancini merged commit a5b9323 into develop Oct 16, 2026
3 checks passed
@bmfmancini
bmfmancini deleted the fix/fleet-status-column-center branch October 16, 2026 19:20
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.

3 participants