From d76c49fb9e113fdb06fe769dc4514bb23dacd81a Mon Sep 17 00:00:00 2001 From: AI Assistant Date: Mon, 30 Mar 2026 22:59:04 +0300 Subject: [PATCH] feat(monitor): add delta sync test button for Cluj-Napoca Quick test button on /monitor page to trigger smart delta sync (magic mode) on Cluj-Napoca and track progress via polling. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/app/(modules)/monitor/page.tsx | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/app/(modules)/monitor/page.tsx b/src/app/(modules)/monitor/page.tsx index 487d9b6..681bd3f 100644 --- a/src/app/(modules)/monitor/page.tsx +++ b/src/app/(modules)/monitor/page.tsx @@ -235,6 +235,44 @@ export default function MonitorPage() { loading={actionLoading === "warm-cache"} onClick={triggerWarmCache} /> + { + setActionLoading("delta-test"); + addLog("info", "Pornire delta sync test pe Cluj-Napoca (54975)..."); + try { + const res = await fetch("/api/eterra/sync-background", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ siruta: "54975", mode: "magic", includeNoGeometry: false }), + }); + const d = await res.json() as { jobId?: string; error?: string }; + if (!res.ok) { addLog("error", d.error ?? "Eroare start"); setActionLoading(""); return; } + addLog("ok", `Job pornit: ${d.jobId}`); + // Poll progress + const jid = d.jobId; + if (pollRef.current) clearInterval(pollRef.current); + pollRef.current = setInterval(async () => { + try { + const pr = await fetch(`/api/eterra/progress?jobId=${jid}`); + const pg = await pr.json() as { status?: string; phase?: string; downloaded?: number; total?: number; note?: string; message?: string }; + const pct = pg.total ? Math.round(((pg.downloaded ?? 0) / pg.total) * 100) : 0; + addLog("wait", `${pg.phase ?? "..."} (${pct}%)${pg.note ? " — " + pg.note : ""}`); + if (pg.status === "done" || pg.status === "error") { + addLog(pg.status === "done" ? "ok" : "error", pg.message ?? pg.phase ?? "Finalizat"); + if (pollRef.current) { clearInterval(pollRef.current); pollRef.current = null; } + setActionLoading(""); + } + } catch { /* continue */ } + }, 5000); + setTimeout(() => { + if (pollRef.current) { clearInterval(pollRef.current); pollRef.current = null; addLog("error", "Timeout 30min"); setActionLoading(""); } + }, 30 * 60_000); + } catch { addLog("error", "Eroare retea"); setActionLoading(""); } + }} + /> {logs.length > 0 && (