Truncate long hostnames in monitoring view Host column
Hostnames longer than 32 characters are now truncated with an ellipsis in view.py tables, with the full name shown as a tooltip on hover. The copy buttons in the Extra column keep copying the full, untruncated hostname regardless of the displayed text.
This commit is contained in:
parent
95f8a899a7
commit
45d6187150
3 changed files with 24 additions and 1 deletions
|
|
@ -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.16.2] - 2026-07-29
|
||||
|
||||
### Changed
|
||||
- Long hostnames in the Host column of monitoring views (`view.py`) are now truncated to 32 characters with an ellipsis, showing the full name in a tooltip on hover. The copy buttons in the Extra column still copy the full, untruncated hostname.
|
||||
|
||||
## [2.16.1] - 2026-07-13
|
||||
|
||||
### Fixed
|
||||
|
|
|
|||
|
|
@ -88,6 +88,8 @@ Adds a dedicated **Extra** column before the Host column in all monitoring view
|
|||
|
||||
The IP address is read from the tooltip Checkmk places on the hostname cell. Clicking any clipboard button briefly turns it green to confirm the copy.
|
||||
|
||||
Hostnames longer than 32 characters are truncated with an ellipsis in the Host column; hover to see the full name in a tooltip. The copy buttons above always copy the full, untruncated hostname regardless of what's displayed.
|
||||
|
||||
Applies to: `view.py` host and service views.
|
||||
|
||||
---
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// ==UserScript==
|
||||
// @name Checkmk SwissKnife
|
||||
// @namespace https://luigidacunto.com/
|
||||
// @version 2.16.1
|
||||
// @version 2.16.2
|
||||
// @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
|
||||
|
|
@ -821,8 +821,16 @@
|
|||
// In view.py pages (monitoring views), adds a small button next to each
|
||||
// hostname in the Host column to directly open the host's Service Discovery
|
||||
// page in a new tab.
|
||||
//
|
||||
// The hostname shown in the Host column link is truncated to
|
||||
// HOST_DISPLAY_MAX_LEN characters (with a title tooltip holding the full
|
||||
// name) when it exceeds the threshold. The copy buttons (Extra column)
|
||||
// always use `hostname`, taken from the `host` href parameter, never the
|
||||
// truncated text.
|
||||
// =========================================================================
|
||||
|
||||
const HOST_DISPLAY_MAX_LEN = 32; // ~15 char typical hostname + ".ad.aruba.it" + margin
|
||||
|
||||
function addInventoryButtons(doc) {
|
||||
if (doc.body.dataset.cmkInventoryBtns === '1') return;
|
||||
|
||||
|
|
@ -931,6 +939,14 @@
|
|||
const h = new URLSearchParams(a.getAttribute('href').split('?')[1] || '').get('host');
|
||||
if (h) {
|
||||
const hostname = h, shortname = h.split('.')[0];
|
||||
|
||||
// Truncate the displayed name (copy buttons below always use the full `hostname`/`shortname`)
|
||||
const displayName = a.textContent.trim();
|
||||
if (displayName.length > HOST_DISPLAY_MAX_LEN) {
|
||||
a.title = displayName;
|
||||
a.textContent = displayName.slice(0, HOST_DISPLAY_MAX_LEN - 1) + '…';
|
||||
}
|
||||
|
||||
const group = doc.createElement('span');
|
||||
group.className = 'cmk-sk-btn-group';
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue