feat: add 24-hour traffic and capacity trend charts to dashboard and node detail pages

- Implemented TrendChart component for visualizing traffic and capacity trends.
- Enhanced DashboardOverview and NodeDetailPage components to display 24-hour request and capacity trends.
- Updated types to include traffic and capacity trend data structures.
- Created observability trends service to aggregate traffic and capacity data.
- Added tests for traffic report generation and trend data handling.
- Introduced new dependencies for charting (echarts and echarts-for-react).
This commit is contained in:
ryan
2026-03-14 11:48:05 +08:00
parent e94132a7d9
commit 16bb9e5879
25 changed files with 1063 additions and 109 deletions
+15
View File
@@ -564,6 +564,12 @@ func TestGetNodeObservability(t *testing.T) {
if len(view.HealthEvents) != 1 || view.HealthEvents[0].EventType != "sync_error" {
t.Fatalf("unexpected health events: %+v", view.HealthEvents)
}
if len(view.Trends.Traffic24h) != 24 || len(view.Trends.Capacity24h) != 24 {
t.Fatalf("expected 24-point trends, got %+v", view.Trends)
}
if view.Trends.Traffic24h[len(view.Trends.Traffic24h)-1].RequestCount != 123 {
t.Fatalf("unexpected traffic trend tail: %+v", view.Trends.Traffic24h[len(view.Trends.Traffic24h)-1])
}
}
func TestGetNodeObservabilityAllowsMissingProfile(t *testing.T) {
@@ -589,6 +595,9 @@ func TestGetNodeObservabilityAllowsMissingProfile(t *testing.T) {
if view.Profile != nil {
t.Fatalf("expected nil profile when profile not reported, got %+v", view.Profile)
}
if len(view.Trends.Traffic24h) != 24 || len(view.Trends.Capacity24h) != 24 {
t.Fatalf("expected empty 24-point trends, got %+v", view.Trends)
}
}
func TestGetDashboardOverview(t *testing.T) {
@@ -715,4 +724,10 @@ func TestGetDashboardOverview(t *testing.T) {
if len(view.Nodes) != 2 || len(view.ActiveAlerts) != 1 {
t.Fatalf("unexpected dashboard nodes/alerts: %+v %+v", view.Nodes, view.ActiveAlerts)
}
if len(view.Trends.Traffic24h) != 24 || len(view.Trends.Capacity24h) != 24 {
t.Fatalf("expected 24-point dashboard trends, got %+v", view.Trends)
}
if view.Trends.Traffic24h[len(view.Trends.Traffic24h)-1].RequestCount != 900 {
t.Fatalf("unexpected dashboard traffic trend tail: %+v", view.Trends.Traffic24h[len(view.Trends.Traffic24h)-1])
}
}