Repository navigation
cards: adopt the shared byte-identical card chrome - #412
Conversation
SonarCloud Quality Gate — addressedThe gate failed with Reliability Rating C on new code. All 5 flagged issues were in js/cards.js — the shared, byte-identical card controller this PR adopts from intropage. Rather than diverge the bundle, I fixed them in the canonical source (Cacti/plugin_intropage#473) and re-synced the identical file here (59e1f5b):
No behaviour change. js/cards.js remains md5-identical to the intropage canonical copy. These will close as Fixed on the next analysis. |
Converge the MacTrack dashboard on the shared dashboarding card interface so the chrome can be promoted to Cacti core unchanged: - js/cards.js is now the byte-identical shared CactiCards controller (was an inlined MacTrack-only copy); MacTrack-specific wiring moves to a thin js/mactrack_dashboard.js adapter (fetch/add/layout/maximize endpoints). - css/cards.css is the byte-identical shared chrome; the card markup and CSS now use the shared .cc* contract. MacTrack's --cc-* theme bindings and card-body widgets (tables, key/value lists, bars) live in css/mactrack-dashboard.css. - mactrack_view_dashboard.php renders .ccCard/.ccW*/.ccTool markup with the data-expandable/data-expanded attributes the shared chrome expects. No functional change to the dashboard behaviour. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Re-sync the byte-identical shared card controller with the intropage canonical copy, which now passes SonarCloud's Clean-as-You-Code gate: - use Number.parseInt instead of the global parseInt (javascript:S7773) - give the fire-and-forget fetch/resize/add promise chains a .catch so an adapter rejection can't become an unhandled rejection (javascript:S9383) No behaviour change; js/cards.js remains byte-identical with plugin_intropage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
59e1f5b to
599cab9
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Overlapping layout saves can overwrite the user's latest order or expanded state, with additional unresolved duplicate-card, drag-and-drop, and dark-theme defects.
5 open issues
Serialize layout saves to prevent stale requests overwriting changes · New Apply the active theme palette to the toolbar and dialog · New Use horizontal position when determining row insertion boundaries · New Reset card.draggable on dragend · New Prevent duplicate cards when adding during pending requests · New
What changed in this PR
Migrates the MacTrack dashboard to the shared CactiCards interface, separating reusable card controls and styling from plugin-specific behavior in preparation for adoption by Cacti core.
Changes:
- Replaces the MacTrack-only controller with shared card interactions and a thin endpoint adapter.
- Converts dashboard markup to the
.cc*contract and separates theme bindings and content widgets from shared styles. - Registers the new assets and documents the migration. Live UI validation remains pending.
| File | Description |
|---|---|
setup.php |
Loads the dashboard adapter and plugin-specific stylesheet. |
mactrack_view_dashboard.php |
Uses shared card classes and state attributes. |
js/mactrack_dashboard.js |
Connects shared controls to MacTrack endpoints and dialogs. |
js/cards.js |
Provides the shared card interaction controller. |
css/mactrack-dashboard.css |
Defines MacTrack theme bindings and content styles. |
css/cards.css |
Provides shared card layout and control styling. |
CHANGELOG.md |
Documents the shared-interface migration. |
Review effort: Balanced
Cacti 1.2.32 ships the shared card chrome in core (include/js/cards.js + include/css/cards.css), loaded by the common page header. Guard the plugin's bundled copies behind a version check so they are only enqueued on older cores; on 1.2.32+ the core copy is used. The MacTrack-specific adapter and dashboard CSS still load on every version. The bundled files remain for backward compatibility until the supported floor rises past 1.2.32. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…quire the core file) Only skip the bundled card chrome when Cacti is fully bootstrapped, is 1.2.32+, AND actually ships include/js/cards.js (the version is bumped before the core Card API lands). This keeps the bundled copy loaded - and its include lines covered - until a core that provides the API is installed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Switch the conditional to file_exists(include/js/cards.js) instead of a CACTI_VERSION check. It is more robust: the version is bumped to 1.2.32 before the core Card API lands, and file presence directly answers whether core actually ships the chrome. The bundled copy is loaded only when core does not provide it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adopt the hardened CactiCards controller from the core Card API review (dragReference pointer-row resolution + findCard re-resolution of detached references) and the header-comment typo fix, keeping js/cards.js byte-identical with Cacti core and the other plugin bundles. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Re-syncs js/cards.js byte-identical with the intropage canonical bundle, picking up the guard that skips an "Add" whose card id is already on the grid. This closes the duplicate-card window where selecting the same option twice while the first request was pending appended two cards with the same id (which the server then deduplicated, diverging the displayed layout from the restored one). cards.js stays md5-identical to Cacti/plugin_intropage#473. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Two MacTrack-specific fixes for the shared card dashboard: - Serialize layout saves in the adapter. dash_layout replaces the entire saved layout, and the shared controller only debounces bursts within 250 ms, so two reorders more than 250 ms apart could race and let an older request complete last, overwriting the user's final order/expanded state. Chain each POST after the previous one settles to preserve write order. - Bind the --cc-* palette to the dashboard panel and the maximize dialog, not just the grid. The Add toolbar is a sibling of the grid and the dialog is moved under <body> by jQuery UI, so both previously fell back to the shared chrome's light-theme defaults (dark text, white select) on dark themes. Binding the panel and dialog lets all shared chrome follow the active theme. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Review feedback addressedAll five Copilot review threads are fixed and resolved. CI (CodeQL, SonarCloud, JS analysis, PHP 8.2–8.6) is green/re-running on the new head.
The |
plugin_mactrack #412 merged with an earlier cards.js, leaving it byte-divergent from the canonical CactiCards controller. Re-sync it to the converged baseline (md5 84876af1) that Cacti core (#8684 for 1.2.x, #8683 for develop) and every Card API plugin now carry: the refresh/resize supersede guard, async remove-commit, the duplicate-add guard and expand/collapse keyboard focus. mactrack uses only the card chrome (no chart primitives), so no card-widgets.css is bundled; css/cards.css is already byte-identical to canonical. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
) * Bring the bundled Card API controller up to the converged baseline Replace js/cards.js with the canonical controller (md5 20694b4c), byte-identical with core and the other plugins. mactrack adopted the chrome early (#412), so its bundled controller was an older lineage missing the request-generation guard, confirmed card removal, keyboard refocus and the new swap-time expand/collapse preservation. css/cards.css already matched; the controller API is a backward- compatible superset so the mactrack adapter is unaffected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Sync cards.js: scope refresh toggle preservation to real user toggles 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> --------- Co-authored-by: TheWitness <copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>





Summary
Converges the MacTrack dashboard on the shared, byte-identical dashboarding card interface (the CactiCards chrome from intropage), as part of standardizing the card UI across the Cacti plugins so it can be promoted to core unchanged.
No functional change to the dashboard behaviour (drag/keyboard reorder, per-card tools, Add-card catalogue, layout persistence all unchanged). cards.js and cards.css are verified md5-identical to the intropage canonical bundle.
Validation
Static only: php -l (dashboard + setup),
ode --check (controller + adapter), and class/reference sweeps. Live UI validation pending (maintainer).
Context
Companion to Cacti/plugin_intropage#473 (which relocates the canonical bundle to js/cards.js + css/cards.css). Follow-ups converge hmib, apcupsd, syslog, alarmmanager, monitor and topx, then Phase 2 lands the bundle + PHP helpers in core 1.2.x and develop.
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com