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 && (