diff options
| author | dax <me@dax.ist> | 2026-08-05 15:24:33 +0100 |
|---|---|---|
| committer | dax <me@dax.ist> | 2026-08-05 15:24:33 +0100 |
| commit | 03dcc91c96ac45ff005a1c3e14a71a5733037447 (patch) | |
| tree | 48cbb120853132e299dd79559321265a5a8fdd42 /public/app.js | |
| parent | ea71584d1fc54d4d6f5799914632328f1327dc08 (diff) | |
admin panel for walk-graph management; /api/import gated behind admin login
Diffstat (limited to 'public/app.js')
| -rw-r--r-- | public/app.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/public/app.js b/public/app.js index 0959509..311faa9 100644 --- a/public/app.js +++ b/public/app.js @@ -14,6 +14,16 @@ const progressText = $("#progress-text") const splash = $("#splash") const startBtn = $("#start") +function adminToken() { + for (const store of [localStorage, sessionStorage]) { + try { + const raw = store.getItem("pathways_admin") + if (raw) { const t = JSON.parse(raw).token; if (t) return t } + } catch { /* ignore */ } + } + return null +} + addEventListener("error", (e) => { toast(`error: ${e.message || "script failed"}`, true) }) @@ -306,7 +316,7 @@ function choosePlacement(id, dir) { scored.sort((a, b) => a.cost - b.cost) const best = scored[0] const next = ex.next && !rectOf.has(ex.next.id) ? scored.find((s) => s.id === ex.next.id) : null - const chosen = next && next.cost - best.cost <= FIT_TOLERANCE ? next : best + const chosen = (ex.forced && next) || (next && next.cost - best.cost <= FIT_TOLERANCE) ? next : best const out = { id: chosen.id, info: chosen.info, rect: chosen.rect } placementCache.set(key, out) return out @@ -843,6 +853,8 @@ function uploadWithProgress(form, onPct, onUploaded) { return new Promise((resolve, reject) => { const xhr = new XMLHttpRequest() xhr.open("POST", "/api/import") + const tok = adminToken() + if (tok) xhr.setRequestHeader("Authorization", "Bearer " + tok) xhr.upload.addEventListener("progress", (e) => { if (e.lengthComputable) onPct(Math.min(100, Math.round((e.loaded / e.total) * 100))) }) |
