From 39e90d4de6b84244214d729f7a2136b84db0f39d Mon Sep 17 00:00:00 2001 From: mwpn Date: Fri, 19 Dec 2025 05:09:09 +0700 Subject: [PATCH] Tambah logging di loadLocationsForCamera dan getCameraForLocation --- public/dashboard/js/dashboard.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/public/dashboard/js/dashboard.js b/public/dashboard/js/dashboard.js index de583e1..565f122 100644 --- a/public/dashboard/js/dashboard.js +++ b/public/dashboard/js/dashboard.js @@ -541,7 +541,12 @@ async function loadGatesForCamera() { async function loadLocationsForCamera() { try { const response = await apiGetLocations({ limit: 1000 }); - let locations = Array.isArray(response) ? response : (response && Array.isArray(response.data) ? response.data : []); + let locations = []; + if (Array.isArray(response)) { + locations = response; + } else if (response && Array.isArray(response.data)) { + locations = response.data; + } locationsCache = {}; locations.forEach(loc => { @@ -550,14 +555,21 @@ async function loadLocationsForCamera() { name: loc.name || loc.label || code }; }); + + console.log('[Dashboard] Locations loaded for camera:', Object.keys(locationsCache).length, locationsCache); } catch (err) { console.error('[Dashboard] Error loading locations for camera:', err); } } function getCameraForLocation(locationCode) { - if (!locationCode) return null; - return gatesCache[locationCode] || null; + if (!locationCode) { + console.log('[Dashboard] getCameraForLocation: no locationCode'); + return null; + } + const camera = gatesCache[locationCode] || null; + console.log('[Dashboard] getCameraForLocation:', { locationCode, found: !!camera, gatesCacheKeys: Object.keys(gatesCache) }); + return camera; } function showVideoPanel(locationCode) {