Skip to content

cards: adopt the shared Card API (chrome + chart widgets) for both dashboards - #87

Merged
TheWitness merged 13 commits into
developfrom
feature/standard-cards-bundle
Nov 11, 2026
Merged

TheWitness merged 13 commits into
developfrom
feature/standard-cards-bundle

Conversation

@TheWitness

Copy link
Copy Markdown
Member

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.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 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.
  • Card markup uses the shared .cc* chrome contract; card header severity uses the shared data-severity wash.

Chart widgets

  • The card-body charts (gauge, usage/distribution bars, min/avg/max bullet, stacked proportion bar, stat tiles) now use the shared .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

  • On Cacti 1.2.32+ the chrome and widgets are provided by core and loaded by the common header. On older cores hmib bundles its own byte-identical cards.js / cards.css / card-widgets.css, gated by file_exists.
  • css/hmib.css keeps 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.js is md5-identical to the canonical core copy; php -l and node --check clean 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

TheWitness and others added 7 commits November 9, 2026 13:44
…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>
@TheWitness
TheWitness marked this pull request as ready for review November 9, 2026 20:43
Copilot AI balanced review requested due to automatic review settings November 9, 2026 20:43

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

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
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

Comment thread css/hmib.css Resolved
Comment thread css/hmib.css Resolved
Comment thread hmib.php Resolved
Comment thread js/cards.js Resolved
Comment thread js/hmib_dashboard.js Resolved
Comment thread js/hmib_dashboard.js Resolved
Comment thread js/hmib_dashboard.js Resolved
Comment thread js/hmib_dashboard.js Resolved
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>
@TheWitness

Copy link
Copy Markdown
Member Author

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 — js/cards.js, css/cards.css and css/card-widgets.css remain md5-identical to the Cacti 1.2.x core copies):

  • css/hmib.css — the --cc-* palette is applied to the toolbars and maximize dialogs as well as the grids (so the dialog keeps the theme after jQuery UI reparents it under <body>); the 1200px/760px breakpoints are retargeted from the removed .hmibDash* rules to the shared .ccGrid/.ccW* classes.
  • hmib.php — new hmib_dashboard_severity_class() maps recovering/rec → warn and dis → none for bars, bullets, tiles and status segments/chips; both toolbars gained stable ids.
  • js/hmib_dashboard.js — per-card refresh now runs through the onRefresh adapter hook to restore keyboard focus and preserve the live expanded state (also on refresh-all); applyTheme prepares the grid's sortable headers on init/add/replace; onAddCard guards against duplicate additions; and onLayoutChange serializes the layout POSTs.

php -l, node --check and the bundled-copy md5 check are clean locally.

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>
@TheWitness
TheWitness marked this pull request as draft November 9, 2026 22:05
TheWitness and others added 2 commits November 10, 2026 07:39
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>
@TheWitness
TheWitness marked this pull request as ready for review November 11, 2026 00:23
bmfmancini
bmfmancini previously approved these changes Nov 11, 2026
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>
@sonarqubecloud

Copy link
Copy Markdown

@TheWitness
TheWitness merged commit 81d6e14 into develop Nov 11, 2026
2 of 7 checks passed
@TheWitness
TheWitness deleted the feature/standard-cards-bundle branch November 11, 2026 16:53
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.

4 participants