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) <noreply@anthropic.com>
This commit is contained in:
@@ -235,6 +235,44 @@ export default function MonitorPage() {
|
|||||||
loading={actionLoading === "warm-cache"}
|
loading={actionLoading === "warm-cache"}
|
||||||
onClick={triggerWarmCache}
|
onClick={triggerWarmCache}
|
||||||
/>
|
/>
|
||||||
|
<ActionButton
|
||||||
|
label="Test Delta Sync — Cluj-Napoca"
|
||||||
|
description="Testeaza smart delta sync (quick-count + VALID_FROM + rolling doc)"
|
||||||
|
loading={actionLoading === "delta-test"}
|
||||||
|
onClick={async () => {
|
||||||
|
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(""); }
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
{logs.length > 0 && (
|
{logs.length > 0 && (
|
||||||
<div className="border border-border rounded-lg overflow-hidden">
|
<div className="border border-border rounded-lg overflow-hidden">
|
||||||
|
|||||||
Reference in New Issue
Block a user