Fix Configure in WATO menu not appearing on views without a Host column

Falls back to any per-row link carrying a host= parameter when the
classic td.nobr Host column isn't present, e.g. on the Service search
view grouped by service across hosts.
This commit is contained in:
Luigi D'Acunto 2026-08-20 17:49:56 +02:00
parent 3990656407
commit 3629447279
3 changed files with 14 additions and 2 deletions

View file

@ -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.20.1] - 2026-08-20
### Fixed
- "Configure in WATO" menu (host select + "Apri" button) did not appear on views without a dedicated Host column (e.g. "Service search" / `searchsvc`, grouped by service across hosts). Hostnames are now also recovered from any per-row link carrying a `host=` parameter when the classic Host column isn't present.
## [2.20.0] - 2026-07-31
### Added

View file

@ -112,6 +112,7 @@ Adds a **Select hosts (N)** dropdown and an **Open** button to the monitoring vi
- Up to 50 hosts per page (keeps URLs within safe length limits)
- Deduplicates hostnames automatically (useful on service views where hosts repeat)
- Works even on views without a dedicated Host column (e.g. "Service search"), by recovering hostnames from any per-row link
- **Open** button is disabled (gray) until a page is selected; turns blue when active; resets after opening
- Only visible for users with WATO configuration access

View file

@ -1,7 +1,7 @@
// ==UserScript==
// @name Checkmk SwissKnife
// @namespace https://luigidacunto.com/
// @version 2.20.0
// @version 2.20.1
// @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
@ -1174,8 +1174,14 @@
const menues = doc.querySelector('#page_menu_bar td.menues');
if (!menues) return;
// Views with a dedicated Host column expose it as td.nobr. Views without one
// (e.g. searchsvc "Service search", grouped by service across hosts) still
// carry host= on other per-row links (Service, Icons, Perf-O-Meter...), so
// fall back to any link in the row when the classic column isn't there.
let hostLinks = [...doc.querySelectorAll('tr.data td.nobr a[href*="host="]')];
if (!hostLinks.length) hostLinks = [...doc.querySelectorAll('tr.data a[href*="host="]')];
const hosts = [...new Set(
[...doc.querySelectorAll('tr.data td.nobr a[href*="host="]')]
hostLinks
.map(a => { const m = a.href.match(/[?&]host=([^&]+)/); return m ? decodeURIComponent(m[1]) : null; })
.filter(Boolean)
)];