diff --git a/assets.db.bak.20260531_110825 b/assets.db.bak.20260531_110825 new file mode 100644 index 0000000..77f7527 Binary files /dev/null and b/assets.db.bak.20260531_110825 differ diff --git a/assets.db.bak.20260531_132122 b/assets.db.bak.20260531_132122 new file mode 100644 index 0000000..87cccc9 Binary files /dev/null and b/assets.db.bak.20260531_132122 differ diff --git a/restart_server.sh b/restart_server.sh index fa69d07..ae29047 100755 --- a/restart_server.sh +++ b/restart_server.sh @@ -1,16 +1,10 @@ #!/bin/bash -# Restart canteen-asset-tracker server cd /home/oplabs/projects/canteen-asset-tracker - -# Kill existing server -pkill -f "python.*server.py" 2>/dev/null || true +pkill -f "uvicorn.*server:app.*8901" 2>/dev/null || true sleep 1 - -# Activate venv and start -source .venv/bin/activate -nohup python server.py > /tmp/canteen-server.log 2>&1 & -echo "Server PID: $!" -sleep 3 - -# Check health -curl -s http://localhost:8901/health 2>/dev/null || curl -s http://localhost:8900/health 2>/dev/null || echo "Health check failed" +python -m uvicorn server:app --host 0.0.0.0 --port 8901 \ + --ssl-keyfile key.pem --ssl-certfile cert.pem --log-level info \ + > /tmp/canteen-server.log 2>&1 & +echo "PID=$!" +sleep 2 +curl -sk https://localhost:8901/health 2>/dev/null diff --git a/static/index.html b/static/index.html index eeaa58d..b5c4ebf 100644 --- a/static/index.html +++ b/static/index.html @@ -2438,9 +2438,13 @@ el.classList.toggle('active', el.dataset.tab === tabId); }); - // Tab lifecycle hooks - if (tabId === 'tabAddAsset') startScanning(); - else stopScanning(); + // Tab lifecycle hooks — start the appropriate scanner + if (tabId === 'tabAddAsset') { + if (addAssetMode === 'ocr') startOcrCamera(); + else startScanning(); + } else { + stopScanning(); + } if (tabId === 'tabAssets') { loadAssets(); } @@ -2553,7 +2557,7 @@ // ═══════════════════════════════════════════════════════════════════════ // ADD ASSET TAB — 3 Modes: Barcode, OCR, Manual // ═══════════════════════════════════════════════════════════════════════ - let addAssetMode = 'barcode'; + let addAssetMode = 'ocr'; let stream = null; let ocrStream = null; let codeReader = null; @@ -2582,6 +2586,8 @@ if (mode === 'barcode') { startScanning(); + } else if (mode === 'ocr') { + startOcrCamera(); } } @@ -3133,7 +3139,8 @@