From 58b6dc1d2a6ad7a100d1a847243ba5b302a4cfec Mon Sep 17 00:00:00 2001 From: CyberMind-FR Date: Sat, 7 Feb 2026 06:34:27 +0100 Subject: [PATCH] fix(crowdsec-dashboard): Fix Threat Origins displaying [object Object] parseCountries() now correctly handles countries as array of objects [{country: "US", count: 67}, ...] instead of only plain {US: 67} format. Co-Authored-By: Claude Opus 4.5 --- .../resources/view/crowdsec-dashboard/overview.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/package/secubox/luci-app-crowdsec-dashboard/htdocs/luci-static/resources/view/crowdsec-dashboard/overview.js b/package/secubox/luci-app-crowdsec-dashboard/htdocs/luci-static/resources/view/crowdsec-dashboard/overview.js index 5fbc191d..3148699b 100644 --- a/package/secubox/luci-app-crowdsec-dashboard/htdocs/luci-static/resources/view/crowdsec-dashboard/overview.js +++ b/package/secubox/luci-app-crowdsec-dashboard/htdocs/luci-static/resources/view/crowdsec-dashboard/overview.js @@ -28,9 +28,17 @@ return view.extend({ } } catch (e) {} } - // Also handle direct countries object if present - if (data.countries && typeof data.countries === 'object') { - for (var k in data.countries) countries[k] = data.countries[k]; + // Handle countries field - can be array or object + if (data.countries) { + if (Array.isArray(data.countries)) { + // Array of {country, count} objects + data.countries.forEach(function(item) { + if (item.country) countries[item.country] = item.count || 0; + }); + } else if (typeof data.countries === 'object') { + // Plain object {US: 10, FR: 5} + for (var k in data.countries) countries[k] = data.countries[k]; + } } return countries; },