()
| 700 | void syncVerboseState(); |
| 701 | |
| 702 | async function refreshTrafficLog(): Promise<void> { |
| 703 | if (!trafficLogEl) return; |
| 704 | try { |
| 705 | const res = await diagFetch('/api/local-traffic-log'); |
| 706 | const data = await res.json(); |
| 707 | const entries: Array<{ timestamp: string; method: string; path: string; status: number; durationMs: number }> = data.entries || []; |
| 708 | if (trafficCount) trafficCount.textContent = `(${entries.length})`; |
| 709 | |
| 710 | if (entries.length === 0) { |
| 711 | trafficLogEl.innerHTML = `<p class="diag-empty">${t('modals.settingsWindow.noTraffic')}</p>`; |
| 712 | return; |
| 713 | } |
| 714 | |
| 715 | const rows = entries.slice().reverse().map((e) => { |
| 716 | const ts = e.timestamp.split('T')[1]?.replace('Z', '') || e.timestamp; |
| 717 | const cls = e.status < 300 ? 'ok' : e.status < 500 ? 'warn' : 'err'; |
| 718 | return `<tr class="diag-${cls}"><td>${escapeHtml(ts)}</td><td>${e.method}</td><td title="${escapeHtml(e.path)}">${escapeHtml(e.path)}</td><td>${e.status}</td><td>${e.durationMs}ms</td></tr>`; |
| 719 | }).join(''); |
| 720 | |
| 721 | trafficLogEl.innerHTML = `<table class="diag-table"><thead><tr><th>${t('modals.settingsWindow.table.time')}</th><th>${t('modals.settingsWindow.table.method')}</th><th>${t('modals.settingsWindow.table.path')}</th><th>${t('modals.settingsWindow.table.status')}</th><th>${t('modals.settingsWindow.table.duration')}</th></tr></thead><tbody>${rows}</tbody></table>`; |
| 722 | } catch { |
| 723 | trafficLogEl.innerHTML = `<p class="diag-empty">${t('modals.settingsWindow.sidecarUnreachable')}</p>`; |
| 724 | } |
| 725 | } |
| 726 | |
| 727 | refreshBtn?.addEventListener('click', () => void refreshTrafficLog()); |
| 728 |
no test coverage detected