scrypted-detection-trainer 0.1.4 → 0.1.6

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/out/plugin.zip CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scrypted-detection-trainer",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Collect and label detections to fine-tune the Scrypted NVR object detection model.",
5
5
  "keywords": [
6
6
  "scrypted-plugin"
package/src/main.ts CHANGED
@@ -502,7 +502,7 @@ class DetectionTrainer extends ScryptedDeviceBase implements Settings, HttpReque
502
502
  <div class="toast" id="toast"></div>
503
503
 
504
504
  <script>
505
- const BASE = location.pathname.replace(/\/$/, '');
505
+ const BASE = location.pathname.endsWith('/') ? location.pathname.slice(0, -1) : location.pathname;
506
506
  let pending = [];
507
507
  let labeledCount = 0;
508
508
 
@@ -530,20 +530,21 @@ function toast(msg, color='#1a3') {
530
530
  }
531
531
 
532
532
  async function loadPending() {
533
- const res = await fetch(BASE + '/api/pending');
534
- pending = await res.json();
535
-
536
- const statsRes = await fetch(BASE + '/api/stats');
537
- const stats = await statsRes.json();
538
- document.getElementById('stat-pending').textContent = stats.pending;
539
- document.getElementById('stat-labeled').textContent = stats.labeled;
540
- document.getElementById('stat-total').textContent = stats.total;
541
-
542
- const list = document.getElementById('detections-list');
543
- if (!pending.length) {
544
- list.innerHTML = '<div class="empty"><div class="icon">✅</div><div>No pending detections to review.<br><span style="font-size:12px;color:#444">Captures will appear here as cameras detect objects.</span></div></div>';
545
- return;
546
- }
533
+ try {
534
+ const res = await fetch(BASE + '/api/pending');
535
+ pending = await res.json();
536
+
537
+ const statsRes = await fetch(BASE + '/api/stats');
538
+ const stats = await statsRes.json();
539
+ document.getElementById('stat-pending').textContent = stats.pending;
540
+ document.getElementById('stat-labeled').textContent = stats.labeled;
541
+ document.getElementById('stat-total').textContent = stats.total;
542
+
543
+ const list = document.getElementById('detections-list');
544
+ if (!pending.length) {
545
+ list.innerHTML = '<div class="empty"><div class="icon">✅</div><div>No pending detections to review.<br><span style="font-size:12px;color:#444">Captures will appear here as cameras detect objects.</span></div></div>';
546
+ return;
547
+ }
547
548
 
548
549
  list.innerHTML = pending.map(r => {
549
550
  const date = new Date(r.timestamp).toLocaleString();
@@ -573,6 +574,11 @@ async function loadPending() {
573
574
  </div>
574
575
  </div>\`;
575
576
  }).join('');
577
+ } catch(e) {
578
+ console.error('loadPending error', e);
579
+ const list = document.getElementById('detections-list');
580
+ if (list) list.innerHTML = '<div class="empty"><div style="color:#a44">Error loading captures: ' + e.message + '</div></div>';
581
+ }
576
582
  }
577
583
 
578
584
  async function label(id, labelVal) {