From 5496ca1f3abcbc5bfbf86acdcc59c1492aad66a8 Mon Sep 17 00:00:00 2001 From: CyberMind-FR Date: Sun, 1 Feb 2026 09:01:30 +0100 Subject: [PATCH] fix(crowdsec-dashboard): Fix overview nav path and countries parsing - Fix nav links to use correct path (security instead of services) - Add parseCountries() to convert top_countries_raw JSON to object - Fix geo data display in overview Co-Authored-By: Claude Opus 4.5 --- .../view/crowdsec-dashboard/overview.js | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) 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 c9bd993d..29cfccb9 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 @@ -13,9 +13,32 @@ return view.extend({ return api.getOverview().catch(function() { return {}; }); }, + parseCountries: function(data) { + var countries = {}; + // Handle top_countries_raw (JSON string array) + if (data.top_countries_raw) { + try { + var arr = typeof data.top_countries_raw === 'string' + ? JSON.parse(data.top_countries_raw) + : data.top_countries_raw; + if (Array.isArray(arr)) { + arr.forEach(function(item) { + if (item.country) countries[item.country] = item.count || 0; + }); + } + } catch (e) {} + } + // Also handle direct countries object if present + if (data.countries && typeof data.countries === 'object') { + Object.assign(countries, data.countries); + } + return countries; + }, + render: function(data) { var self = this; var s = data || {}; + s.countries = this.parseCountries(s); var view = E('div', { 'class': 'cs-view' }, [ // Header @@ -68,7 +91,7 @@ return view.extend({ ]; return E('div', { 'class': 'cs-nav' }, tabs.map(function(t) { return E('a', { - 'href': L.url('admin/secubox/services/crowdsec/' + t.id), + 'href': L.url('admin/secubox/security/crowdsec/' + t.id), 'class': active === t.id ? 'active' : '' }, t.label); })); @@ -154,6 +177,7 @@ return view.extend({ pollData: function() { var self = this; return api.getOverview().then(function(s) { + s.countries = self.parseCountries(s); var el = document.getElementById('cs-stats'); if (el) dom.content(el, self.renderStats(s)); el = document.getElementById('cs-alerts');