From 571236190d916f3413297db04877c74f1643e095 Mon Sep 17 00:00:00 2001 From: Luigi D'Acunto Date: Thu, 24 Sep 2026 12:06:52 +0200 Subject: [PATCH] Fix service color tint on views using "Display name" column Views like "Aruba Service problems" label the service name column "Display name" instead of "Service", so hiding State silently failed to tint the service name and the Service icons toggle found nothing. Both now fall back to "Display name", matching the existing pattern used by the Markdown export feature. --- CHANGELOG.md | 5 +++++ user_script/checkmk_swissknife.user.js | 15 +++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09d5032..5db74f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ 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.3] - 2026-09-24 + +### Fixed +- On views that label the service name column "Display name" instead of "Service" (e.g. "Aruba Service problems"), hiding State didn't tint the service name and the Service icons toggle didn't find its column — both now recognize "Display name" as a fallback. + ## [2.22.2] - 2026-09-23 ### Fixed diff --git a/user_script/checkmk_swissknife.user.js b/user_script/checkmk_swissknife.user.js index fd4ea1e..b4af299 100644 --- a/user_script/checkmk_swissknife.user.js +++ b/user_script/checkmk_swissknife.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Checkmk SwissKnife // @namespace https://luigidacunto.com/ -// @version 2.22.2 +// @version 2.22.3 // @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 @@ -1118,7 +1118,10 @@ // 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, []) }, - { key: 'svcIcons', label: 'Service icons', match: h => h.reduce((acc, t, i) => (t === 'Icons' && h[i - 1] === 'Service') ? 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: '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] : []; } }, @@ -1143,7 +1146,7 @@ // tinted with that row's state color instead, so CRIT/WARN/UNKNOWN stay // visible at a glance without the column. Driven directly by the // hidden-columns set. No-op (and clears prior tint) when State is visible, - // or on views without both a State and a Service column. + // or on views without both a State and a service-name column. function applyStateColorTint(doc) { const stateHidden = getHiddenColumns().has('state'); doc.querySelectorAll('table.data').forEach(table => { @@ -1151,7 +1154,11 @@ if (!headerRow) return; const headerTexts = [...headerRow.children].map(c => c.textContent.trim()); const stateIdx = headerTexts.indexOf('State'); - const svcIdx = headerTexts.indexOf('Service'); + // Some views (e.g. ar_svc_problems) label the service name column + // "Display name" instead of "Service" — same fallback as findServiceColumns. + const svcIdx = headerTexts.indexOf('Display name') !== -1 + ? headerTexts.indexOf('Display name') + : headerTexts.indexOf('Service'); if (stateIdx === -1 || svcIdx === -1) return; table.querySelectorAll('tr.data').forEach(tr => { const cells = [...tr.children];