Skip to content

fix/feat(hmib): status guards, centered/pilled statuses, theme-aware glyphs, Hardware status legend+filter - #65

Merged
TheWitness merged 3 commits into
developfrom
fix/hmib-status-pills-glyph-theming
Oct 9, 2026
Merged

TheWitness merged 3 commits into
developfrom
fix/hmib-status-pills-glyph-theming

Conversation

@TheWitness

@TheWitness TheWitness commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Description

Addresses a set of issues and adds a Status feature on the Host MIB (hmib) views:

Bug fixes & polish

  • PHP Undefined array key warnings (hmib.php:893 via hmib_running(), and the same pattern in hmib_hardware()): status-code lookups indexed the label arrays directly, so any code outside the known set (e.g. 0) raised a warning on every row. Both now use the isset(...) ? ... : __('Unknown') guard already used for the adjacent type column.
  • Devices tab Status pills were not centered: the host_status column header and the get_colored_device_status() cell are now center aligned.
  • Glyph colors were not theme-aware: the action glyphs (Hardware/microchip, Processes/cog, Graphs/chart-line) used hardcoded inline style='color:...'. These are replaced with CSS classes (.hmibHardware, .hmibProcess, .hmibGraph) backed by a new css/ directory (base css/hmib.css for light themes plus per-theme overrides for the dark themes), loaded via get_md5_include_css() on the active theme.
  • Fixed a malformed fas fa-archive glyph on the Summary tab (missing closing quote).

New: Hardware tab device-status pills + legend + filter

The Hardware tab's Status column reflects the Host Resources MIB hrDeviceStatus object (RFC 2790, OID 1.3.6.1.2.1.25.3.2.1.5): unknown(1), running(2), warning(3), testing(4), down(5) — plus this plugin's non-standard 0 => Present default.

  • Each status now renders as a title-case colored pill instead of plain text. Colors follow Cacti's device-status (deviceXXX) family: Running = green, Down = red, Warning = amber, Testing = orange, Unknown = grey, Present = muted blue. Solid pills carry their own background + white text, so one palette reads correctly on every theme (no per-theme override needed).
  • A clickable status legend (one pill per status) is shown above the table.
  • A Status filter dropdown was added to the filter box, wired through applyFilter() and session-stored like the other filters.
  • Clicking any pill (legend or table cell) sets the Status dropdown and reapplies the filter (hmibSetStatus()).

Motivation and Context

Stops the recurring PHP warnings, corrects the Devices tab layout, makes action-glyph colors theme-aware, and makes the Hardware Status column readable and filterable.

How Has This Been Tested?

  • php -l clean on all changed PHP.
  • tests/bin/validate-manifest.php passes (new css/ dir recorded in manifest.json).
  • tests/bin/check-i18n-pot.php passes — the one new translatable string (Click to filter by this status) is reflected in a regenerated locales/po/cacti.pot (only the template committed; per-language .po/.mo reverted).
  • CSS brace balance verified; all CSS files are LF-only with no BOM.
  • hmib.php is in the tests/bin/patch-coverage.php unmeasured allowlist (top-level web controller, not unit-loadable — same rationale as hmib_types.php).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation repository accordingly.

…lign glyphs

Guard hrSWRunStatus/hrDeviceStatus lookups to stop Undefined array key warnings; center the Devices tab Status pills; replace hardcoded inline glyph colors with per-theme CSS classes (new css/ dir); fix a malformed fa-archive glyph.
@TheWitness
TheWitness requested review from bmfmancini and xmacan and a balanced review from Copilot October 8, 2026 23:03

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

The active theme must be allowlisted before constructing filesystem and stylesheet paths.

1 open finding
What changed in this PR

Fixes HMIB status warnings, UI alignment, malformed markup, and theme-specific glyph styling.

Changes:

  • Guards unknown process/device status lookups.
  • Centers device status pills and fixes glyph markup.
  • Adds base and dark-theme glyph CSS.
File Description
hmib.php Updates status handling and UI rendering.
css/​hmib.css Adds base glyph colors.
css/​dark.css Adds dark-theme overrides.
css/​deepness.css Adds Deepness overrides.
css/​midwinter.css Adds Midwinter overrides.
css/​paper-plane.css Adds Paper Plane overrides.
css/​sunrise.css Adds Sunrise overrides.
manifest.json Registers the CSS directory.
tests/​bin/​patch-coverage.php Allowlists the web controller.
CHANGELOG.md Documents the fixes.

🧠 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 hmib.php Outdated
Render hrDeviceStatus as title-case colored pills (deviceXXX palette), add a clickable status legend and a Status filter dropdown; clicking any pill sets the dropdown and filters. Regenerated cacti.pot.
@TheWitness TheWitness changed the title fix(hmib): guard status lookups, center Devices status pills, theme-align glyphs fix/feat(hmib): status guards, centered/pilled statuses, theme-aware glyphs, Hardware status legend+filter Oct 8, 2026
- Validate get_selected_theme() against the five shipped override names before
  using it in the css filesystem/URL path, closing the traversal the reviewer
  flagged (older Cacti can return an unvalidated session theme).
- Remove hmib.php from phpunit.xml <source>: being in <source> forced php-code-
  coverage to measure it at count=0, so its allowlist entry in patch-coverage.php
  was ignored and all 59 changed lines failed the 100% gate. Dropping it makes
  the file absent from Clover so the existing allowlist entry applies (same as
  hmib_types.php).
@TheWitness
TheWitness merged commit 6cd0617 into develop Oct 9, 2026
3 checks passed
@TheWitness
TheWitness deleted the fix/hmib-status-pills-glyph-theming branch October 9, 2026 00:07
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