Repository navigation
cards: adopt the shared Card API (chrome + chart widgets) for the UPS dashboards - #68
Merged
Merged
Conversation
… dashboards Converge apcupsd's per-UPS and Fleet dashboards on the shared Card API: - Bundle the canonical js/cards.js + css/cards.css + css/card-widgets.css and load them only when core does not already ship them (file_exists gates), so on Cacti 1.2.32+ the core copies are used. - Replace the plugin's own card controller with a thin adapter over the shared window.CactiCards engine (drag/keyboard reorder, per-card tools, add-card catalogue and debounced layout save now come from core); the adapter keeps apcupsd's extras - the UPS picker, Cacti's timespan selector, the sortable card tables and the maximize dialog. - Re-vocabulary the card chrome to the .cc* contract (data-expandable / data-expanded / data-severity) and draw the card bodies from the shared .cc* chart primitives (ccGauge incl. ticks, ccBullet incl. avg marker, ccPill severities, ccEmpty), which the companion core change #8684 adds. - Standardize auto-refresh on Cacti's set_page_refresh() and reload-on-change, matching the other Card API dashboards. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Fleet-table sort tests asserted the old controller source (hardcoded namespaces, per-card header prep); update them to the thin adapter which parameterises the sort namespace and binds the maximize dialog through apcupsdDashBindSort(dialog, ...). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Update js/cards.js to the converged baseline (md5 84876af1) shared by Cacti core (#8684 for 1.2.x, #8683 for develop) and every Card API plugin: the refresh/resize supersede guard, async remove-commit, the duplicate-add guard and expand/collapse keyboard focus. Byte-identical to core. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sync the shared card-widgets.css so the .ccPill severity backgrounds meet WCAG 4.5:1 contrast (mix each hue 70% with black; give --none a translucent currentColor wash). Use Number.parseFloat and Number.isNaN instead of the global parseFloat/isNaN in the dashboard adapter. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved regressions prevent restoring removed cards, make refreshed sort controls inaccessible to keyboard users, and leave narrow-screen cards too small for their content.
7 open issues
Migrate responsive breakpoints to the new grid classes · New Preserve native column-header semantics for sortable headers · New Restore sort-direction indicators after sorting · New Initialize keyboard sorting on inserted or refreshed cards · New Show layout-save errors in the save-status element · New Bridge Select2 change events to the shared controller · New Preserve the live expansion state when replacing refreshed cards · New
What changed in this PR
Migrates the per-UPS and Fleet dashboards to Cacti’s shared Card API, replacing plugin-specific card interactions and markup while retaining UPS-specific controls.
Changes:
- Bundles shared card scripts and styles as fallbacks when core does not provide them.
- Introduces a dashboard adapter and shared gauge, bullet, status-pill, and card markup.
- Switches auto-refresh to
set_page_refresh()with reload-on-change and updates related tests.
| File | Description |
|---|---|
tests/Unit/EstimatedWattsTest.php |
Updates sortable-table handler assertions. |
tests/Unit/DashboardRrdStatsTest.php |
Checks shared bullet-scale markup. |
tests/Unit/DashboardRefreshTest.php |
Updates expectations for the new refresh model. |
js/cards.js |
Adds the shared card interaction controller. |
js/apcupsd_dashboard.js |
Adapts dashboard endpoints and controls to the shared controller. |
includes/dashboard.php |
Emits shared markup, loads fallback assets, and configures refresh. |
css/cards.css |
Adds shared card layout and toolbar styles. |
css/card-widgets.css |
Adds shared chart primitives and status styles. |
css/apcupsd.css |
Defines dashboard-specific shared-card variables. |
Review effort: Balanced
The .ccToolbar sits above #apcupsd_dashboard as a sibling, not a child, so it never inherited --cc-text. .ccToolbarLabel/.ccAdd therefore fell back to the shared chrome's light-theme #23362f default and rendered dark green on dark themes. Bind the card palette to .ccToolbar as well so the toolbar follows the theme foreground like the grid and dialog already do. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bmfmancini
previously approved these changes
Nov 11, 2026
…resh race - Migrate the responsive breakpoints from the retired .apcupsdDashGrid/ .apcupsdDashSpan* classes to #apcupsd_dashboard.ccGrid + .ccW*, clamping wide spans so narrow screens stack instead of creating implicit columns. - Drop role=button from sortable <th> so the native columnheader role and aria-sort announcement are preserved; direction arrows now key off aria-sort instead of the no-longer-set apcupsdDashSortAsc/Desc classes. - Re-enhance sort headers after every swap (via the controller's applyTheme post-swap hook) so refreshed/re-added cards stay keyboard-operable. - Surface a server-rejected layout save in the .apcupsdDashSaveStatus live region instead of silently reverting on reload. - Bridge Select2's jQuery change on the Add card select to a native event (guarding re-entry) so it works on Cacti 1.2.x and core controllers. - Sync cards.js with the shared fix that preserves the live expand/collapse state at swap time (refresh race), byte-identical with core. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sync cards.js with the corrected shared controller (review on core #8700): replaceCard() carries the live expand/collapse state only when the user toggled during the request and the fresh card is still expandable, leaving host markup authoritative otherwise. Pass the captured expanded state through the direct refresh swap so it uses that mechanism. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
xmacan
approved these changes
Nov 11, 2026
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.




Converges apcupsd's per-UPS and Fleet dashboards on the shared Card API, matching mactrack/hmib/intropage/syslog/topx.
What
js/cards.js+css/cards.css+css/card-widgets.css, loaded only when core does not already ship them (file_existsgates), so on Cacti 1.2.32+ the core copies are used.window.CactiCards: drag/keyboard reorder, per-card tools, the add-card catalogue and the debounced layout save now come from core. The adapter keeps apcupsd's extras — the UPS picker, Cacti's timespan selector, the sortable card tables and the maximize dialog..cc*chrome contract (data-expandable/data-expanded/data-severity) with card bodies drawn from the shared.cc*chart primitives:ccGauge(incl. min/max ticks),ccBullet(incl. the average marker),ccPillseverities andccEmpty.Review fixes (addressing the Copilot comments on this PR)
.apcupsdDashGrid/.apcupsdDashSpan*classes to#apcupsd_dashboard.ccGrid+.ccW*, clamping wide spans so narrow screens stack instead of creating implicit columns.role="button"from the<th>headers so the native columnheader role (andaria-sortannouncement) is preserved.aria-sort="ascending|descending"instead of the no-longer-setapcupsdDashSortAsc/Descclasses..apcupsdDashSaveStatuslive region instead of silently reverting.changeto a native event (guarding re-entry) so choosing a card restores it on both bundled and core controllers.cards.jsnow preserves the live card's expand/collapse state at swap time, so toggling a card while its refresh is in flight is no longer undone (synced byte-identical with core and the other plugins).Depends on
.ccGaugeTick,.ccBulletAvgMarkerand.ccPill--*to the sharedcard-widgets.css. The bundled copy here is byte-identical to those PRs, so the richer primitives render on older cores too.Notes
cards.js/cards.css/card-widgets.cssare byte-identical to the core PRs and the other plugin PRs.includes/dashboard.phpandupses.phpremain in the patch-coverage allowlist (UI render modules); no measured PHP changed. Dashboard unit tests cover the new markup and refresh model.