mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-08 16:46:37 +08:00
feat(dashboard): enhance dashboard overview and world stage components
- Implemented normalization for dashboard overview data to handle null or undefined values. - Added ECharts map integration for visualizing node data on a world map. - Introduced loading and error states for the map component. - Updated UI components to support dark and light themes. - Enhanced testing for dashboard overview to cover empty states and data fetching. - Added type definitions for echarts-maps module. - Updated package dependencies to include echarts-maps.
This commit is contained in:
@@ -160,6 +160,7 @@ func GetDashboardOverview() (*DashboardOverviewView, error) {
|
||||
view := &DashboardOverviewView{
|
||||
GeneratedAt: now,
|
||||
Nodes: make([]DashboardNodeHealth, 0, len(nodes)),
|
||||
ActiveAlerts: make([]DashboardAlert, 0),
|
||||
Distributions: buildTrafficDistributions(reports, 8),
|
||||
Trends: DashboardTrends{
|
||||
Traffic24h: buildTrafficTrendPoints(now, reports),
|
||||
|
||||
@@ -879,3 +879,18 @@ func TestGetDashboardOverview(t *testing.T) {
|
||||
t.Fatalf("unexpected riskiest node: %+v", view.Peaks.RiskiestNode)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetDashboardOverviewReturnsEmptyAlertSlice(t *testing.T) {
|
||||
setupServiceTestDB(t)
|
||||
|
||||
view, err := GetDashboardOverview()
|
||||
if err != nil {
|
||||
t.Fatalf("GetDashboardOverview failed: %v", err)
|
||||
}
|
||||
if view.ActiveAlerts == nil {
|
||||
t.Fatalf("expected active alerts to be an empty slice, got nil")
|
||||
}
|
||||
if len(view.ActiveAlerts) != 0 {
|
||||
t.Fatalf("expected empty active alerts, got %+v", view.ActiveAlerts)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user