Policies: Vergleich als zweispaltige Gegenüberstellung (A | B)

Statt gestapelter JSON-Blöcke jetzt eine Tabelle: pro settingDefinitionId eine
Zeile mit Wert A neben Wert B. Kompakter, lesbarer Kurzwert (Get-SettingDisplayValue:
Choice/Simple/Collections) im Vordergrund, volles kanonisches JSON als Tooltip.
Status-Einfärbung (unterschiedlich/nur A/nur B/gleich) + Filter "nur Unterschiede".
Endpoint liefert dafür vereinheitlichte rows (Union der Keys) mit short/full je Seite.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
marcoandClaude Opus 4.8 committed 2026-10-19 13:31:25 +02:00
1 parent e35005e489
commit 19e479a08d
3 files changed
+116 -64

No files matched your search

+34 -28
View File
@@ -6619,6 +6619,7 @@ document.getElementById('polConsConfirm')?.addEventListener('click', polDoConsol
// Policies vergleichen (zwei Settings-Catalog-Policies -> Diff)
// =============================================================
let _polCmpResult = null;
let _polCmpOnlyDiff = false;
async function openPolCompare() {
const keys = [...PolState.selected].filter(k => k.startsWith('settingscatalog::'));
@@ -6645,48 +6646,53 @@ function polCmpShortId(id) {
return `<span class="pol-cmp-id" title="${escapeHtml(s)}"><b>${escapeHtml(tail)}</b> <span class="muted">${escapeHtml(s)}</span></span>`;
}
function polCmpVal(v) {
return `<code class="pol-cmp-val">${escapeHtml(String(v ?? ''))}</code>`;
// Eine Wert-Zelle (Kurzwert sichtbar, volles JSON als Tooltip). Leer = „—".
function polCmpCell(short, full, extraCls) {
if (short == null && full == null) return '<div class="pol-cmp-c empty">—</div>';
const s = (short === '' || short == null) ? '∅' : short;
return `<div class="pol-cmp-c ${extraCls || ''}" title="${escapeHtml(full || '')}">${escapeHtml(s)}</div>`;
}
function renderPolCompare(res) {
_polCmpResult = res;
const c = res.counts || {};
const aName = res.a?.name || 'A', bName = res.b?.name || 'B';
document.getElementById('polCmpSummary').innerHTML =
`<div class="pol-cmp-head">`
+ `<div><b>A:</b> ${escapeHtml(res.a?.name || '—')} <span class="muted">(${res.a?.count ?? 0} Settings · ${escapeHtml(res.a?.platform || '')})</span></div>`
+ `<div><b>B:</b> ${escapeHtml(res.b?.name || '—')} <span class="muted">(${res.b?.count ?? 0} Settings · ${escapeHtml(res.b?.platform || '')})</span></div>`
+ `</div>`
+ `<div class="pol-cmp-counts">`
`<div class="pol-cmp-counts">`
+ `<span class="pol-cmp-badge diff">${c.different || 0} unterschiedlich</span>`
+ `<span class="pol-cmp-badge a">${c.onlyA || 0} nur in A</span>`
+ `<span class="pol-cmp-badge b">${c.onlyB || 0} nur in B</span>`
+ `<span class="pol-cmp-badge same">${c.same || 0} gleich</span>`
+ `<label class="pol-cmp-filter"><input type="checkbox" id="polCmpOnlyDiff" ${_polCmpOnlyDiff ? 'checked' : ''}> Nur Unterschiede</label>`
+ `</div>`;
const cb = document.getElementById('polCmpOnlyDiff');
if (cb) cb.onchange = () => { _polCmpOnlyDiff = cb.checked; renderPolCompare(_polCmpResult); };
const rows = (res.rows || []).filter(r => _polCmpOnlyDiff ? r.status !== 'same' : true);
const header =
`<div class="pol-cmp-trow head">`
+ `<div class="pol-cmp-setting">Einstellung (${(res.rows || []).length})</div>`
+ `<div class="pol-cmp-c col-a" title="${escapeHtml(aName)}">A · ${escapeHtml(aName)}</div>`
+ `<div class="pol-cmp-c col-b" title="${escapeHtml(bName)}">B · ${escapeHtml(bName)}</div>`
+ `</div>`;
const sect = (title, cls, rows) => rows.length
? `<div class="pol-cmp-sect"><div class="pol-cmp-sect-h ${cls}">${title} (${rows.length})</div>${rows.join('')}</div>`
: '';
const bodyRows = rows.map(r => {
const diffCls = r.status === 'different' ? 'diff' : '';
return `<div class="pol-cmp-trow ${r.status}">`
+ `<div class="pol-cmp-setting">${polCmpShortId(r.id)}</div>`
+ polCmpCell(r.shortA, r.fullA, diffCls)
+ polCmpCell(r.shortB, r.fullB, diffCls)
+ `</div>`;
}).join('');
const diffRows = (res.different || []).map(r =>
`<div class="pol-cmp-row diff">${polCmpShortId(r.settingDefinitionId)}`
+ `<div class="pol-cmp-ab"><span class="pol-cmp-side"><b>A</b> ${polCmpVal(r.valueA)}</span>`
+ `<span class="pol-cmp-side"><b>B</b> ${polCmpVal(r.valueB)}</span></div></div>`);
const onlyARows = (res.onlyA || []).map(r =>
`<div class="pol-cmp-row">${polCmpShortId(r.settingDefinitionId)} ${polCmpVal(r.value)}</div>`);
const onlyBRows = (res.onlyB || []).map(r =>
`<div class="pol-cmp-row">${polCmpShortId(r.settingDefinitionId)} ${polCmpVal(r.value)}</div>`);
const sameRows = (res.same || []).map(r =>
`<div class="pol-cmp-row">${polCmpShortId(r.settingDefinitionId)} ${polCmpVal(r.value)}</div>`);
document.getElementById('polCmpBody').innerHTML =
sect('Unterschiedlich', 'diff', diffRows)
+ sect('Nur in A', 'a', onlyARows)
+ sect('Nur in B', 'b', onlyBRows)
+ sect('Gleich', 'same', sameRows)
|| '<div class="muted">Keine Einstellungen zum Vergleichen.</div>';
document.getElementById('polCmpBody').innerHTML = rows.length
? `<div class="pol-cmp-table">${header}${bodyRows}</div>`
: '<div class="muted" style="padding:8px;">Keine Einstellungen (mit aktivem Filter).</div>';
document.getElementById('polCmpInfo').textContent =
`${(res.a?.count ?? 0)} ↔ ${(res.b?.count ?? 0)} Settings`;
`A: ${res.a?.count ?? 0} · B: ${res.b?.count ?? 0} Settings`;
}
document.getElementById('btnPolCompare')?.addEventListener('click', openPolCompare);
+18 -13
View File
@@ -5499,20 +5499,25 @@ body.read-only .app-row {
.pol-cmp-badge.a { background: rgba(96,165,250,.15); color: #60a5fa; }
.pol-cmp-badge.b { background: rgba(167,139,250,.15); color: #a78bfa; }
.pol-cmp-badge.same { background: rgba(74,222,128,.15); color: #4ade80; }
.pol-cmp-sect { margin-top: 12px; }
.pol-cmp-sect-h { font-weight: 600; font-size: 12.5px; padding: 4px 8px; border-radius: 6px; margin-bottom: 4px; background: var(--hairline-soft); }
.pol-cmp-sect-h.diff { background: rgba(251,191,36,.12); color: #fbbf24; }
.pol-cmp-sect-h.a { background: rgba(96,165,250,.12); color: #60a5fa; }
.pol-cmp-sect-h.b { background: rgba(167,139,250,.12); color: #a78bfa; }
.pol-cmp-sect-h.same { background: rgba(74,222,128,.12); color: #4ade80; }
.pol-cmp-row { padding: 5px 8px; border-bottom: 1px solid var(--hairline-soft, rgba(255,255,255,.06)); font-size: 12.5px; }
.pol-cmp-row:last-child { border-bottom: 0; }
.pol-cmp-filter { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; }
.pol-cmp-id { display: inline-block; }
.pol-cmp-id .muted { font-size: 11px; word-break: break-all; }
.pol-cmp-val { display: inline-block; font-size: 11.5px; background: var(--bg3, var(--hover)); padding: 1px 6px; border-radius: 4px; word-break: break-all; }
.pol-cmp-ab { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 3px; }
.pol-cmp-side { flex: 1 1 240px; }
.pol-cmp-side b { color: var(--text-dim, #888); margin-right: 4px; }
.pol-cmp-id .muted { font-size: 10.5px; word-break: break-all; }
/* Zweispaltige Gegenueberstellung A | B */
.pol-cmp-table { display: grid; grid-template-columns: minmax(200px, 1.5fr) 1fr 1fr; border: 1px solid var(--hairline, #333); border-radius: 8px; overflow: hidden; font-size: 12px; }
.pol-cmp-trow { display: contents; }
.pol-cmp-trow > div { padding: 6px 8px; border-bottom: 1px solid var(--hairline-soft, rgba(255,255,255,.06)); min-width: 0; }
.pol-cmp-trow.head > div { position: sticky; top: 0; background: var(--bg3, var(--hover)); font-weight: 600; z-index: 1; }
.pol-cmp-trow.head .col-a { color: #60a5fa; }
.pol-cmp-trow.head .col-b { color: #a78bfa; }
.pol-cmp-setting { background: var(--canvas); }
.pol-cmp-c { word-break: break-all; }
.pol-cmp-c.empty { color: var(--muted, #777); text-align: center; }
.pol-cmp-c.diff { background: rgba(251,191,36,.12); color: #fbbf24; font-weight: 600; }
/* Zeilen-Einfaerbung nach Status (dezent) */
.pol-cmp-trow.onlyA .pol-cmp-setting { box-shadow: inset 3px 0 0 #60a5fa; }
.pol-cmp-trow.onlyB .pol-cmp-setting { box-shadow: inset 3px 0 0 #a78bfa; }
.pol-cmp-trow.different .pol-cmp-setting { box-shadow: inset 3px 0 0 #fbbf24; }
.pol-cmp-trow.same .pol-cmp-c { color: var(--text-dim, #999); }
.pol-cons-src { margin: 6px 0 0; padding-left: 18px; font-size: 12px; }
.pol-cons-src li { margin: 1px 0; }
.pol-cons-conf-head { margin: 14px 0 6px; font-weight: 600; font-size: 13px; }