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:
parent
82fb9c7d42
commit
58b6dc1d2a
@ -28,10 +28,18 @@ return view.extend({
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
// Also handle direct countries object if present
|
||||
if (data.countries && typeof data.countries === 'object') {
|
||||
// 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;
|
||||
},
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user