Repository navigation
cards: adopt the shared Card API (chrome + chart widgets) for both dashboards - #87
Conversation
…shboards Converge the per-device Host Dashboard and the Fleet (Summary) Dashboard on the shared Cacti dashboarding Card API so the chrome and chart primitives are no longer vendored per plugin: - js/cards.js is the byte-identical shared CactiCards controller; the two inlined controllers become thin adapters (js/hmib_dashboard.js, js/hmib_summary_dashboard.js) that map drag/reorder/tools to hmib's endpoints and keep hmib's extras (sortable card tables, device/OS-type pickers, auto-refresh interval, refresh-all). - Card markup uses the shared .cc* chrome contract; card-body charts (gauge, usage/distribution bars, min/avg/max bullet, stacked bar, stat tiles) use the shared .cc* chart-widget primitives (css/card-widgets.css). Card header severity now uses the shared data-severity wash. - On Cacti 1.2.32+ the chrome and widgets come from core; on older cores hmib bundles its own byte-identical cards.js/cards.css/card-widgets.css, gated by file_exists. hmib.css keeps only hmib-specific content styling and binds the shared --cc-* theme variables. No functional change to either dashboard. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ctory Fold js/hmib_summary_dashboard.js into js/hmib_dashboard.js: a single hmibDashInit(opts) factory wires either dashboard (the per-device Host Dashboard or the OS-type-scoped Fleet Dashboard) from a small per-scope config, removing the near-duplicate second adapter that tripped the SonarCloud new-code duplication gate. The summary page now loads js/hmib_dashboard.js and calls initHmibSummaryDashboard(). No behaviour change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…backs Add a DashboardPageTest end-to-end suite that renders every per-device and Fleet dashboard card against a scope that both has data and lacks it, plus the single-card AJAX endpoints for the expanded state and the per-scope empty branches the full page cannot reach. New fixture builders seed the storage, processor, hardware, software and process-history tables. Teach tests/bin/patch-coverage.php to honour the standard PHPUnit @codeCoverageIgnoreStart/End markers (the end-to-end Clover is raw Xdebug, so no driver applies them for us), and mark the bundled-asset fallbacks in hmib.php with them: those branches only run on a Cacti older than the one the end-to-end run installs, so CI can never exercise them now that the core Card API is merged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve the source path for the @codeCoverageIgnore scan from this script's own location rather than the current working directory, so the markers are honoured in the integration job (the previous run still counted the bundled asset fallbacks). Mark the unreachable 'no OS types' Fleet branch too: a scope with devices always has at least one OS-type group. Collapse the two 'expanded over AJAX' dashboard tests into one dataset so the new test file stays under the SonarCloud new-code duplication gate. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
An earlier line-ending normalization in this branch truncated the last character from a run of lines that ended in 'r', turning 'hrswr' into 'hrsw' and '\' into '\' in the Summary SQL. That broke the Summary page and the Fleet top-process cards at runtime (Unknown column 'hrswr.name') and tripped the source guards. Restore the dropped characters; no behavioural change beyond undoing the corruption. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
merge-coverage.php is the script that actually fails the job on an uncovered changed line, so teach it the same @codeCoverageIgnoreStart/End handling that patch-coverage.php already has. This exempts the bundled-asset fallbacks and the unreachable 'no OS types' branch, which CI cannot exercise now that the core Card API is merged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Collapse the four near-identical page-render tests into a single data-driven test so the new test file stays under the SonarCloud new-code duplication gate. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved migration regressions disrupt severity styling, responsive layouts, theming, and keyboard accessibility, while refresh, card-addition, and save races can lose user state or create duplicate cards.
8 open issues
Extend palette scope to toolbar and maximized dialog · New Retarget responsive breakpoints to the new grid classes · New Map legacy severity suffixes to shared CSS values · New Restore focus to the replacement card tool · New Preserve live expanded state when replacing cards · New Prepare grid headers for keyboard sorting · New Prevent duplicate pending or existing card additions · New Serialize layout saves to prevent stale overwrites · New
What changed in this PR
Migrates the Host and Fleet dashboards to Cacti’s shared Card API, consolidating their interaction code and standardizing card markup and chart widgets.
Changes:
- Replaces separate dashboard controllers with one shared hmib adapter using
CactiCards. - Adopts
.cc*markup and styles, with bundled fallback assets for older Cacti installations. - Adds dashboard rendering tests and fixtures, plus coverage-ignore support for compatibility branches.
Live UI validation remains pending, as noted in the PR description.
| File | Description |
|---|---|
tests/support/fixtures.php |
Adds dashboard data fixtures. |
tests/E2E/DashboardPageTest.php |
Tests dashboard markup, expanded cards, and empty states. |
tests/bin/patch-coverage.php |
Honors coverage-ignore blocks in patch coverage. |
tests/bin/merge-coverage.php |
Excludes annotated lines from changed-line coverage reporting. |
js/hmib_summary_dashboard.js |
Removes the separate Fleet controller. |
js/hmib_dashboard.js |
Provides one shared adapter for both dashboards. |
js/cards.js |
Bundles the shared card interaction controller. |
hmib.php |
Migrates dashboard markup and loads fallback assets. |
css/hmib.css |
Sets shared card theme variables and grid width. |
css/cards.css |
Bundles shared card layout and control styles. |
css/card-widgets.css |
Bundles shared chart-widget styles. |
CHANGELOG.md |
Documents the Card API migration. |
Review effort: Balanced
Resolve the review findings on the shared Card API adoption without touching the byte-identical bundled copies of cards.js, cards.css or card-widgets.css (they must stay md5-identical to Cacti core); every fix lands in the hmib-specific files. css/hmib.css * Apply the --cc-* palette to the toolbar and the maximize dialog as well as the grid. Both live outside the grid (jQuery UI reparents the dialog under <body> when maximized), so they previously fell back to the shared stylesheet's light-theme defaults instead of following the Cacti theme. * Retarget the 1200px/760px breakpoints from the removed .hmibDashGrid / .hmibDashSpan* rules to the shared .ccGrid and .ccW* width classes so cards stack again on narrow screens. hmib.php * Add hmib_dashboard_severity_class() and map the legacy severity suffixes to the suffixes the shared card-widgets.css expects (recovering/rec -> warn, dis -> none) for bars, bullets, tiles and status segments/chips, restoring the warning colour and the disabled band. * Give both toolbars stable ids so the palette can target them. js/hmib_dashboard.js * Own the per-card Refresh swap via the adapter onRefresh hook so keyboard focus is restored to the equivalent tool and the live expanded state is preserved; apply the same reconcile on refresh-all. * Prepare the grid's sortable table headers (tabindex/aria-sort) through the applyTheme adapter callback, which runs on init, add and replace. * Reserve pending add ids and reject already-present cards so choosing the same absent card twice cannot append a duplicate. * Serialize layout saves so a slower earlier POST cannot overwrite a newer layout snapshot. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Pushed f17508f addressing all eight review comments. Each inline thread has a reply and is resolved. Summary of fixes (all confined to the hmib-specific files —
|
Match the byte-identical card-widgets.css shipped by core #8684/#8683 (adds .ccGaugeTick, .ccBulletAvgMarker and .ccPill--* severities). hmib does not use these new primitives, but the bundled copy stays byte-identical to core. 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>
Pull the shared card-widgets.css fix so the .ccPill--up/--warn/--down backgrounds meet the 4.5:1 WCAG AA threshold for their 11px label and .ccPill--none inherits the theme foreground instead of rendering white. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Carry the shared Card API controller fix so a card refresh that lands while the user expanded/collapsed it no longer reverts that toggle (replaceCard preserves the live data-expanded at swap time). Byte-identical with core and the other plugins. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Corrected shared controller (review on core #8700): replaceCard() carries the live expand/collapse state onto refreshed markup only when the user toggled during the request and the fresh card is still expandable; host markup stays authoritative otherwise. Byte-identical with core and the other plugins. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|




Summary
Converges the Host MIB dashboards on the shared Cacti dashboarding Card API (merged in Cacti/cacti#8680) — both the per-device Host Dashboard and the Fleet (Summary) Dashboard — for card + chart scope.
Chrome
js/cards.jsis the byte-identical sharedCactiCardscontroller. The two inlined controllers become thin adapters (js/hmib_dashboard.js,js/hmib_summary_dashboard.js) that delegate drag/keyboard reorder and the per-card tools to the shared controller and map the fetch/add/layout/maximize hooks to hmib's endpoints — while keeping hmib's extras: sortable card tables, the device / OS-type pickers, the auto-refresh interval and manual refresh-all..cc*chrome contract; card header severity uses the shareddata-severitywash.Chart widgets
.cc*chart-widget primitives (css/card-widgets.css) instead of hmib-prefixed copies. This is what lets an hmib card render correctly if it is ever surfaced in another host (e.g. Intropage's panel registration).Loading / fallback
cards.js/cards.css/card-widgets.css, gated byfile_exists.css/hmib.csskeeps only hmib-specific content styling (tables, status pills, graphs, the device picker) and binds the shared--cc-*theme variables; its now-superseded.hmib*chrome/primitive rules are inert.No functional change to either dashboard.
js/cards.jsis md5-identical to the canonical core copy;php -landnode --checkclean on all changed files.Validation
Static only (php -l, node --check, class/reference sweeps). Live UI validation pending (maintainer).
Context
Part of the cross-plugin standardization: companion to intropage (#473) and mactrack (Cacti/plugin_mactrack#412), on top of the merged core Card API (Cacti/cacti#8680) and the controller comment fix (Cacti/cacti#8682).
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com