feat(zigbee): import as background scan run
Mirrors IP scan flow: POST /zigbee/import-pending now creates a ScanRun(kind=zigbee, status=running) and returns immediately. Networkmap fetch + pending upsert run in the background, status transitions to done/error when finished. Frontend: import modal closes on submit, scan history shows the run with a ZIG/IP kind chip and toasts on completion. Pending modal auto-refreshes when run finishes. scan_runs.kind column added (default 'ip', idempotent migration). Existing zigbee tests refactored to exercise _persist_pending_import directly (background tasks don't see the test session); route test verifies the run is created with kind=zigbee.
This commit is contained in:
@@ -138,19 +138,9 @@ export function ZigbeeImportModal({ open, onClose, onAddToCanvas, onPendingImpor
|
||||
setLoading(true)
|
||||
try {
|
||||
if (importMode === 'pending') {
|
||||
const res = await zigbeeApi.importToPending(buildPayload())
|
||||
const { pending_created, pending_updated, coordinator, coordinator_already_existed, device_count } = res.data
|
||||
if (device_count === 0) {
|
||||
toast.info('No Zigbee devices found in the network map')
|
||||
} else {
|
||||
const coordMsg = coordinator_already_existed
|
||||
? 'coordinator already on canvas'
|
||||
: 'coordinator added to canvas'
|
||||
toast.success(
|
||||
`Imported ${pending_created} new, updated ${pending_updated} (${coordMsg})`,
|
||||
)
|
||||
}
|
||||
onPendingImported?.(coordinator)
|
||||
await zigbeeApi.importToPending(buildPayload())
|
||||
toast.success('Zigbee import started — track progress in Scan History')
|
||||
onPendingImported?.(null)
|
||||
handleClose()
|
||||
} else {
|
||||
const res = await zigbeeApi.importNetwork(buildPayload())
|
||||
|
||||
Reference in New Issue
Block a user