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 <noreply@anthropic.com>
This commit is contained in:
CyberMind-FR 2026-02-07 06:34:27 +01:00
parent 82fb9c7d42
commit 58b6dc1d2a

View File

@ -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;
},