@blueharford/scrypted-spatial-awareness 0.5.0-beta → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueharford/scrypted-spatial-awareness",
3
- "version": "0.5.0-beta",
3
+ "version": "0.5.0",
4
4
  "description": "Cross-camera object tracking for Scrypted NVR with spatial awareness",
5
5
  "author": "Joshua Seidel <blueharford>",
6
6
  "license": "Apache-2.0",
package/src/main.ts CHANGED
@@ -695,7 +695,10 @@ export class SpatialAwarenessPlugin extends ScryptedDeviceBase
695
695
  // ==================== 6. AI & Spatial Reasoning ====================
696
696
  addGroup('AI & Spatial Reasoning');
697
697
 
698
- // ==================== 7. Alerts ====================
698
+ // ==================== 7. Auto-Topology Discovery ====================
699
+ addGroup('Auto-Topology Discovery');
700
+
701
+ // ==================== 8. Alerts ====================
699
702
  addGroup('Alerts');
700
703
 
701
704
  // Add alert rules configuration UI
@@ -709,7 +712,7 @@ export class SpatialAwarenessPlugin extends ScryptedDeviceBase
709
712
  group: 'Alerts',
710
713
  });
711
714
 
712
- // ==================== 8. MQTT Integration ====================
715
+ // ==================== 9. MQTT Integration ====================
713
716
  addGroup('MQTT Integration');
714
717
 
715
718
  return settings;
@@ -659,12 +659,34 @@ export const EDITOR_HTML = `<!DOCTYPE html>
659
659
  }).join('');
660
660
  }
661
661
 
662
+ let scanPollingInterval = null;
663
+
662
664
  async function runDiscoveryScan() {
663
665
  const scanBtn = document.getElementById('scan-now-btn');
666
+ const statusText = document.getElementById('discovery-status-text');
664
667
  scanBtn.disabled = true;
665
668
  scanBtn.textContent = 'Scanning...';
666
669
  setStatus('Starting discovery scan...', 'warning');
667
670
 
671
+ // Start polling for live status updates
672
+ let camerasDone = 0;
673
+ scanPollingInterval = setInterval(async () => {
674
+ try {
675
+ const statusResp = await fetch('../api/discovery/status');
676
+ if (statusResp.ok) {
677
+ const status = await statusResp.json();
678
+ if (status.isScanning) {
679
+ statusText.textContent = 'Scanning: ' + status.camerasAnalyzed + ' cameras analyzed...';
680
+ // Check for new suggestions during scan
681
+ if (status.pendingSuggestions > camerasDone) {
682
+ camerasDone = status.pendingSuggestions;
683
+ await loadDiscoverySuggestions();
684
+ }
685
+ }
686
+ }
687
+ } catch (e) { /* ignore polling errors */ }
688
+ }, 1000);
689
+
668
690
  try {
669
691
  const response = await fetch('../api/discovery/scan', { method: 'POST' });
670
692
  if (response.ok) {
@@ -687,6 +709,11 @@ export const EDITOR_HTML = `<!DOCTYPE html>
687
709
  console.error('Discovery scan failed:', e);
688
710
  setStatus('Discovery scan failed', 'error');
689
711
  } finally {
712
+ // Stop polling
713
+ if (scanPollingInterval) {
714
+ clearInterval(scanPollingInterval);
715
+ scanPollingInterval = null;
716
+ }
690
717
  scanBtn.disabled = false;
691
718
  scanBtn.textContent = 'Scan Now';
692
719
  }