Compare commits

..

No commits in common. "f97ea33ba863178f0b7023658d6c2eca2c0ba24e" and "9cf6d8af97d9d9bef6d57d2a1a5605cf1764e1a7" have entirely different histories.

View file

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name Checkmk SwissKnife // @name Checkmk SwissKnife
// @namespace https://luigidacunto.com/ // @namespace https://luigidacunto.com/
// @version 2.9.9 // @version 2.9.5
// @description Raccolta di miglioramenti all'interfaccia di Checkmk WATO. Ogni fix o enhancement viene aggiunto qui come feature indipendente. // @description Raccolta di miglioramenti all'interfaccia di Checkmk WATO. Ogni fix o enhancement viene aggiunto qui come feature indipendente.
// @author Luigi D'Acunto // @author Luigi D'Acunto
// @homepageURL https://git.luigidacunto.com/tools/checkmk-swissknife // @homepageURL https://git.luigidacunto.com/tools/checkmk-swissknife
@ -827,39 +827,34 @@
vertical-align: middle; vertical-align: middle;
} }
.cmk-sk-inv-btn, .cmk-sk-copy-btn, .cmk-sk-copy-short-btn { .cmk-sk-inv-btn, .cmk-sk-copy-btn, .cmk-sk-copy-short-btn {
display: inline-flex !important; display: inline-flex;
align-items: center !important; align-items: center;
justify-content: center !important; justify-content: center;
width: 16px !important; width: 16px;
height: 16px !important; height: 16px;
border-radius: 3px !important; border-radius: 3px;
cursor: pointer !important; cursor: pointer;
opacity: 0.8; opacity: 0.8;
flex-shrink: 0; flex-shrink: 0;
padding: 0 !important; padding: 0;
margin: 1px !important;
box-sizing: border-box !important;
text-decoration: none !important; text-decoration: none !important;
font-size: 0 !important;
line-height: 0 !important;
vertical-align: middle !important;
} }
.cmk-sk-inv-btn { .cmk-sk-inv-btn, .cmk-sk-inv-btn:visited {
background: rgba(229,165,0,0.08) !important; background: rgba(229,165,0,0.08);
color: #e5a500 !important; color: #e5a500 !important;
border: 1px solid #e5a500 !important; border: 1px solid #e5a500;
} }
.cmk-sk-inv-btn:hover { opacity: 1 !important; background: rgba(229,165,0,0.18) !important; } .cmk-sk-inv-btn:hover { opacity: 1; background: rgba(229,165,0,0.18) !important; }
.cmk-sk-copy-btn { .cmk-sk-copy-btn {
background: rgba(90,180,214,0.08) !important; background: rgba(90,180,214,0.08);
color: #5ab4d6 !important; color: #5ab4d6 !important;
border: 1px solid #5ab4d6 !important; border: 1px solid #5ab4d6;
} }
.cmk-sk-copy-btn:hover { opacity: 1; background: rgba(90,180,214,0.18) !important; } .cmk-sk-copy-btn:hover { opacity: 1; background: rgba(90,180,214,0.18) !important; }
.cmk-sk-copy-short-btn { .cmk-sk-copy-short-btn {
background: rgba(160,120,200,0.08) !important; background: rgba(160,120,200,0.08);
color: #a078c8 !important; color: #a078c8 !important;
border: 1px solid #a078c8 !important; border: 1px solid #a078c8;
} }
.cmk-sk-copy-short-btn:hover { opacity: 1; background: rgba(160,120,200,0.18) !important; } .cmk-sk-copy-short-btn:hover { opacity: 1; background: rgba(160,120,200,0.18) !important; }
.cmk-sk-copy-btn.copied, .cmk-sk-copy-short-btn.copied { .cmk-sk-copy-btn.copied, .cmk-sk-copy-short-btn.copied {
@ -874,23 +869,23 @@
const CLIP_SVG = '<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>'; const CLIP_SVG = '<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>';
hostCells.forEach(td => { hostCells.forEach(td => {
let hostname = null; const link = td.querySelector('a[href*="view_name=hoststatus"]');
for (const a of td.querySelectorAll('a[href*="host="]')) { if (!link) return;
const h = new URLSearchParams(a.getAttribute('href').split('?')[1] || '').get('host'); const params = new URLSearchParams(link.getAttribute('href').split('?')[1] || '');
if (h) { hostname = h; break; } const hostname = params.get('host');
}
if (!hostname) return; if (!hostname) return;
const shortname = hostname.split('.')[0]; const shortname = hostname.split('.')[0];
const group = doc.createElement('span'); const group = doc.createElement('span');
group.className = 'cmk-sk-btn-group'; group.className = 'cmk-sk-btn-group';
const btn = doc.createElement('button'); const btn = doc.createElement('a');
btn.className = 'cmk-sk-inv-btn'; btn.className = 'cmk-sk-inv-btn';
btn.type = 'button'; btn.href = `wato.py?host=${encodeURIComponent(hostname)}&mode=inventory`;
btn.target = '_blank';
btn.rel = 'noopener';
btn.title = `Service Discovery: ${hostname}`; btn.title = `Service Discovery: ${hostname}`;
btn.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><rect x="2" y="3" width="20" height="14" rx="2"/><line x1="8" y1="21" x2="16" y2="21"/><line x1="12" y1="17" x2="12" y2="21"/><polyline points="6 9 9 12 14 7" stroke-width="2"/></svg>'; btn.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><rect x="2" y="3" width="20" height="14" rx="2"/><line x1="8" y1="21" x2="16" y2="21"/><line x1="12" y1="17" x2="12" y2="21"/><polyline points="6 9 9 12 14 7" stroke-width="2"/></svg>';
btn.addEventListener('click', () => { window.open(`wato.py?host=${encodeURIComponent(hostname)}&mode=inventory`, '_blank', 'noopener'); });
const copyBtn = doc.createElement('button'); const copyBtn = doc.createElement('button');
copyBtn.className = 'cmk-sk-copy-btn'; copyBtn.className = 'cmk-sk-copy-btn';