Add Site/Reperibilità columns and fix icons ownership detection
Adds "Site" (distinct from "Site alias") and "Reperibilità" to the columns the Columns dropdown can hide/show, when present. Also fixes Host icons/Service icons detection on views that render the Icons column before Host instead of after (e.g. "Aruba Service problems"): ownership is now determined by checking both neighbors of "Icons", skipping over our own injected Extra column when it sits in between.
This commit is contained in:
parent
571236190d
commit
d3beeb887c
3 changed files with 39 additions and 11 deletions
|
|
@ -5,6 +5,14 @@ All notable changes to **Checkmk SwissKnife** are documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [2.22.4] - 2026-09-24
|
||||
|
||||
### Added
|
||||
- "Site" (distinct from "Site alias") and "Reperibilità" added to the list of native columns the "Columns" dropdown can hide/show, when present on the current view.
|
||||
|
||||
### Fixed
|
||||
- On views that render the host Icons column before the Host column instead of after (e.g. "Aruba Service problems"), the Host icons/Service icons toggles didn't find their columns — the Icons-to-Host/Service association now checks both sides regardless of order, and skips over the Extra column when it sits in between.
|
||||
|
||||
## [2.22.3] - 2026-09-24
|
||||
|
||||
### Fixed
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ A [Tampermonkey](https://www.tampermonkey.net/) userscript that enhances the Che
|
|||
| **Copy Host List (JSON)** | Adds a button to the menu bar that copies hostname, alias, IPv4 address and monitored site for every host in the list to the clipboard as JSON | `addHostListCopyButton` |
|
||||
| **Service Export to Markdown** | On any view.py services table (Host + Display name/Service columns), adds an "Export ▾" menu entry that exports a Markdown table with whichever of Site/Host/IP/Display name/Summary/Details are present, to the clipboard and as a downloaded `.md` file | `addServiceExportButton` |
|
||||
| **Copy Hosts (JSON/TSV)** | Adds "Copy hosts (JSON)"/"Copy hosts (TSV)" entries to the same "Export ▾" menu on any view.py host list, copying hostname (FQDN) and IP for every host on the page to the clipboard | `addHostExportButtons` |
|
||||
| **Column Visibility Toggle** | Adds a "Columns" dropdown with a per-column ON/OFF button plus "Show all"/"Hide all", to hide/show bulky native columns (State, Site alias, Host/Service icons, Age, Checked, Check command, Groups); only columns present on the current view are listed, and the choice is remembered across reloads. Hiding State tints the service name with its state's color instead | `addColumnVisibilityToggle` |
|
||||
| **Column Visibility Toggle** | Adds a "Columns" dropdown with a per-column ON/OFF button plus "Show all"/"Hide all", to hide/show bulky native columns (State, Site, Site alias, Host/Service icons, Age, Checked, Check command, Groups); only columns present on the current view are listed, and the choice is remembered across reloads. Hiding State tints the service name with its state's color instead | `addColumnVisibilityToggle` |
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -188,7 +188,7 @@ Applies to: any `view.py` page listing hosts (with or without sidebar).
|
|||
---
|
||||
|
||||
### Column Visibility Toggle
|
||||
Adds a **"Columns"** dropdown to the menu bar on any monitoring view table. Each entry hides/shows one native Checkmk column — State, Site alias, Host icons, Service icons, Age, Checked, Check command, Groups (service + host) — found by its header text, so it works on any view without being tied to one specific one. Only the columns actually present on the current view are listed, each with its own **ON/OFF** button so it's always clear at a glance what's currently shown, plus **"Show all"**/**"Hide all"** shortcuts at the top of the panel to reset everything in one click. Purely visual (CSS only, never touches form/checkbox state), and the choice is saved so it applies the same way to every monitoring view you open afterwards.
|
||||
Adds a **"Columns"** dropdown to the menu bar on any monitoring view table. Each entry hides/shows one native Checkmk column — State, Site, Site alias, Host icons, Service icons, Age, Checked, Check command, Groups (service + host) — found by its header text, so it works on any view without being tied to one specific one. Only the columns actually present on the current view are listed, each with its own **ON/OFF** button so it's always clear at a glance what's currently shown, plus **"Show all"**/**"Hide all"** shortcuts at the top of the panel to reset everything in one click. Purely visual (CSS only, never touches form/checkbox state), and the choice is saved so it applies the same way to every monitoring view you open afterwards.
|
||||
|
||||
Hiding the **State** column also tints the service name itself with that row's state color (Checkmk's own colors: green OK, yellow WARN, red CRIT, orange UNKNOWN), so problems stay identifiable at a glance without the column taking up space.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// ==UserScript==
|
||||
// @name Checkmk SwissKnife
|
||||
// @namespace https://luigidacunto.com/
|
||||
// @version 2.22.3
|
||||
// @version 2.22.4
|
||||
// @checkmk 2.3.x - 2.4.x
|
||||
// @description Collection of UI improvements for Checkmk WATO. Each fix or enhancement is added here as an independent feature.
|
||||
// @author Luigi D'Acunto
|
||||
|
|
@ -1107,21 +1107,41 @@
|
|||
|
||||
const COLUMN_VIS_STORAGE_KEY = 'cmkSkHiddenColumns';
|
||||
|
||||
// "Icons" appears twice on service views (once for the host, once for the
|
||||
// service), and its position relative to Host/Service isn't consistent
|
||||
// across views: most views render Host, then its Icons; "ar_svc_problems"
|
||||
// instead renders Icons, then Host. Our own injected Extra column (see
|
||||
// addInventoryButtons) also sits between the two on views where Icons
|
||||
// comes first, since it's always inserted right before Host. So: check the
|
||||
// header on both sides of "Icons", stepping past "Extra" if that's what's
|
||||
// there, and let whichever side actually names Host/Service/Display name
|
||||
// decide ownership — never assume a fixed direction.
|
||||
function iconsOwner(h, i) {
|
||||
const left = h[i - 1] === 'Extra' ? h[i - 2] : h[i - 1];
|
||||
if (left === 'Host') return 'host';
|
||||
if (left === 'Service' || left === 'Display name') return 'svc';
|
||||
const right = h[i + 1] === 'Extra' ? h[i + 2] : h[i + 1];
|
||||
if (right === 'Host') return 'host';
|
||||
if (right === 'Service' || right === 'Display name') return 'svc';
|
||||
return null;
|
||||
}
|
||||
|
||||
// Each def locates its column(s) by header text + position, not a fixed
|
||||
// index: column order varies per view. "Icons" appears twice on service
|
||||
// views (host icons right after Host, service icons right after Service),
|
||||
// so those two are matched by their preceding header, not by text alone.
|
||||
// index: column order varies per view.
|
||||
const COLUMN_DEFS = [
|
||||
{ key: 'state', label: 'State', match: h => { const i = h.indexOf('State'); return i !== -1 ? [i] : []; } },
|
||||
{ key: 'siteAlias', label: 'Site alias', match: h => { const i = h.indexOf('Site alias'); return i !== -1 ? [i] : []; } },
|
||||
// Distinct from "Site alias": some views (e.g. ar_svc_problems) label
|
||||
// this column just "Site" instead, showing the site id rather than its alias.
|
||||
{ key: 'site', label: 'Site', match: h => { const i = h.indexOf('Site'); return i !== -1 ? [i] : []; } },
|
||||
// Custom host-tag column shown as a native table column on some views
|
||||
// (e.g. ar_svc_problems); matched by its literal displayed header text.
|
||||
{ key: 'onCall', label: 'Reperibilità', match: h => { const i = h.indexOf('Reperibilità'); return i !== -1 ? [i] : []; } },
|
||||
// Scans every position, not just the first "Host"/"Service": views that render
|
||||
// 2 hosts per physical row (e.g. searchhost) repeat the whole header set, so
|
||||
// indexOf() alone would only catch the first pair and silently miss the rest.
|
||||
{ key: 'hostIcons', label: 'Host icons', match: h => h.reduce((acc, t, i) => (t === 'Icons' && h[i - 1] === 'Host') ? acc.concat(i) : acc, []) },
|
||||
// "Service" is the header on most views, but some (e.g. ar_svc_problems)
|
||||
// label it "Display name" instead — same fallback used everywhere else
|
||||
// this codebase reads the service-name column.
|
||||
{ key: 'svcIcons', label: 'Service icons', match: h => h.reduce((acc, t, i) => (t === 'Icons' && (h[i - 1] === 'Service' || h[i - 1] === 'Display name')) ? acc.concat(i) : acc, []) },
|
||||
{ key: 'hostIcons', label: 'Host icons', match: h => h.reduce((acc, t, i) => (t === 'Icons' && iconsOwner(h, i) === 'host') ? acc.concat(i) : acc, []) },
|
||||
{ key: 'svcIcons', label: 'Service icons', match: h => h.reduce((acc, t, i) => (t === 'Icons' && iconsOwner(h, i) === 'svc') ? acc.concat(i) : acc, []) },
|
||||
{ key: 'age', label: 'Age', match: h => { const i = h.indexOf('Age'); return i !== -1 ? [i] : []; } },
|
||||
{ key: 'checked', label: 'Checked', match: h => { const i = h.indexOf('Checked'); return i !== -1 ? [i] : []; } },
|
||||
{ key: 'checkCommand', label: 'Check command', match: h => { const i = h.indexOf('Check command'); return i !== -1 ? [i] : []; } },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue