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);