fix: deployment capture coords now reach existing locations

The /deploy classify "Assign to existing location" path dropped the captured
GPS — only "Create new location" applied it — so units assigned to pre-existing
coordless locations left those locations without a pin.

- Classify (promote) now backfills the captured GPS onto an existing location
  that has no coordinates (doesn't clobber operator-set coords).
- Add "Reforward info" button on Assigned deployment cards + endpoint
  POST /pending/{id}/resync-location that re-pushes a capture's GPS onto its
  assigned location (explicit action, overwrites). Fixes already-classified
  locations and guards against this recurring. Logged to unit history.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-22 18:12:56 +00:00
parent ee6062f9fb
commit 93f01be471
2 changed files with 77 additions and 1 deletions
+27 -1
View File
@@ -207,9 +207,19 @@ function _renderPdCard(pd) {
</button>
</div>`;
} else if (pd.status === 'assigned') {
const reforward = pd.coordinates
? `<button onclick="reforwardInfo('${_esc(pd.id)}')"
class="mt-2 inline-flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-lg border border-seismo-orange/40 bg-seismo-orange/10 text-seismo-orange hover:bg-seismo-orange/20 transition-colors"
title="Re-push this capture's GPS coordinates onto its assigned location">
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"></path>
</svg>
Reforward info
</button>`
: '';
footerActions = `<div class="mt-3 text-xs text-green-700 dark:text-green-400">
Promoted ${_fmtDateTime(pd.promoted_at)} → assignment <span class="font-mono">${_esc((pd.resulting_assignment_id || '').slice(0, 8))}…</span>
</div>`;
</div>${reforward}`;
} else if (pd.status === 'cancelled') {
footerActions = `<div class="mt-3 text-xs text-gray-500 dark:text-gray-400">
Cancelled ${_fmtDateTime(pd.cancelled_at)}${pd.cancelled_reason ? `${_esc(pd.cancelled_reason)}` : ''}
@@ -459,6 +469,22 @@ async function cancelPending(pendingId) {
}
}
// Re-push a promoted capture's GPS coordinates onto its assigned location.
async function reforwardInfo(pendingId) {
try {
const r = await fetch(`/api/deployments/pending/${pendingId}/resync-location`, {
method: 'POST',
});
const j = await r.json().catch(() => ({}));
if (!r.ok) throw new Error(j.detail || 'HTTP ' + r.status);
const msg = `Coordinates synced to "${j.location_name}": ${j.coordinates}`;
if (window.showToast) showToast(msg, 'success'); else alert(msg);
} catch (e) {
const msg = 'Reforward failed: ' + e.message;
if (window.showToast) showToast(msg, 'error'); else alert(msg);
}
}
// Kick off the initial load.
loadPdList();
// Refresh awaiting count every 30s for the badge.