Tambah logging di loadLocationsForCamera dan getCameraForLocation
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user