Migrate inspector and links pages to TDS lt.* APIs
Lint / Python (flake8) (push) Failing after 1m22s
Lint / JS (eslint) (push) Successful in 10s
Security / Python Security (bandit) (push) Failing after 49s
Lint / Notify on failure (push) Has been cancelled
Lint / Deploy (push) Has been cancelled
Test / Python Tests (pytest) (push) Has been cancelled

- Add escHtml alias (lt.escHtml) to both pages so existing template strings work without touching 40+ call sites
- Replace raw fetch() with lt.api.get/post in loadInspector, loadLinks, runDiagnostic, pollDiagnostic
- Replace setInterval(load*, 60000) with lt.autoRefresh.start() for intelligent polling
- Add lt.toast.error() to catch blocks for user-visible error feedback

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-18 23:59:19 -04:00
parent c1c3905179
commit a17b1382bc
2 changed files with 19 additions and 31 deletions
+5 -8
View File
@@ -20,6 +20,8 @@
{% block scripts %}
<script>
const escHtml = s => lt.escHtml(s);
// ── Formatting helpers ────────────────────────────────────────────
function fmtRate(bytesPerSec) {
if (bytesPerSec === null || bytesPerSec === undefined) return '';
@@ -480,13 +482,7 @@ function checkLinksStale(updatedStr) {
// ── Fetch + render ────────────────────────────────────────────────
async function loadLinks() {
try {
const resp = await fetch('/api/links');
if (!resp.ok) {
document.getElementById('links-container').innerHTML =
'<div class="error-state">Failed to load link statistics.</div>';
return;
}
const data = await resp.json();
const data = await lt.api.get('/api/links');
if (!data.hosts && !data.unifi_switches) {
document.getElementById('links-container').innerHTML =
'<div class="link-no-data">No link data yet — monitor has not completed a full cycle.</div>';
@@ -501,10 +497,11 @@ async function loadLinks() {
} catch (e) {
document.getElementById('links-container').innerHTML =
'<div class="error-state">Network error loading link statistics.</div>';
lt.toast.error('Failed to load link statistics');
}
}
loadLinks();
setInterval(loadLinks, 60000);
lt.autoRefresh.start(loadLinks, 60000);
</script>
{% endblock %}