mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-05 23:26:38 +08:00
[功能] 优化仪表板概览数据结构,添加压缩和规范化功能
This commit is contained in:
@@ -88,87 +88,87 @@ describe('DashboardOverview', () => {
|
||||
},
|
||||
distributions: {
|
||||
source_countries: [
|
||||
{ key: 'CN', value: 440 },
|
||||
{ key: 'US', value: 320 },
|
||||
{ key: 'SG', value: 140 },
|
||||
['CN', 440],
|
||||
['US', 320],
|
||||
['SG', 140],
|
||||
],
|
||||
status_codes: [
|
||||
{ key: '200', value: 820 },
|
||||
{ key: '502', value: 24 },
|
||||
{ key: '500', value: 12 },
|
||||
['200', 820],
|
||||
['502', 24],
|
||||
['500', 12],
|
||||
],
|
||||
top_domains: [
|
||||
{ key: 'app.example.com', value: 580 },
|
||||
{ key: 'api.example.com', value: 220 },
|
||||
['app.example.com', 580],
|
||||
['api.example.com', 220],
|
||||
],
|
||||
},
|
||||
trends: {
|
||||
traffic_24h: Array.from({ length: 24 }, (_, index) => ({
|
||||
bucket_started_at: `2026-03-13T${String(index).padStart(2, '0')}:00:00Z`,
|
||||
request_count: index * 10,
|
||||
error_count: index,
|
||||
unique_visitor_count: index * 3,
|
||||
})),
|
||||
capacity_24h: Array.from({ length: 24 }, (_, index) => ({
|
||||
bucket_started_at: `2026-03-13T${String(index).padStart(2, '0')}:00:00Z`,
|
||||
average_cpu_usage_percent: index,
|
||||
average_memory_usage_percent: index + 10,
|
||||
reported_nodes: 2,
|
||||
})),
|
||||
network_24h: Array.from({ length: 24 }, (_, index) => ({
|
||||
bucket_started_at: `2026-03-13T${String(index).padStart(2, '0')}:00:00Z`,
|
||||
network_rx_bytes: index * 100,
|
||||
network_tx_bytes: index * 120,
|
||||
openresty_rx_bytes: index * 140,
|
||||
openresty_tx_bytes: index * 160,
|
||||
reported_nodes: 2,
|
||||
})),
|
||||
disk_io_24h: Array.from({ length: 24 }, (_, index) => ({
|
||||
bucket_started_at: `2026-03-13T${String(index).padStart(2, '0')}:00:00Z`,
|
||||
disk_read_bytes: index * 50,
|
||||
disk_write_bytes: index * 70,
|
||||
reported_nodes: 2,
|
||||
})),
|
||||
traffic_24h: Array.from({ length: 24 }, (_, index) => [
|
||||
`2026-03-13T${String(index).padStart(2, '0')}:00:00Z`,
|
||||
index * 10,
|
||||
index,
|
||||
index * 3,
|
||||
]),
|
||||
capacity_24h: Array.from({ length: 24 }, (_, index) => [
|
||||
`2026-03-13T${String(index).padStart(2, '0')}:00:00Z`,
|
||||
index,
|
||||
index + 10,
|
||||
2,
|
||||
]),
|
||||
network_24h: Array.from({ length: 24 }, (_, index) => [
|
||||
`2026-03-13T${String(index).padStart(2, '0')}:00:00Z`,
|
||||
index * 100,
|
||||
index * 120,
|
||||
index * 140,
|
||||
index * 160,
|
||||
2,
|
||||
]),
|
||||
disk_io_24h: Array.from({ length: 24 }, (_, index) => [
|
||||
`2026-03-13T${String(index).padStart(2, '0')}:00:00Z`,
|
||||
index * 50,
|
||||
index * 70,
|
||||
2,
|
||||
]),
|
||||
},
|
||||
nodes: [
|
||||
{
|
||||
id: 1,
|
||||
node_id: 'node-a',
|
||||
name: 'edge-a',
|
||||
geo_name: 'Shanghai',
|
||||
geo_latitude: 31.2304,
|
||||
geo_longitude: 121.4737,
|
||||
status: 'online',
|
||||
openresty_status: 'healthy',
|
||||
current_version: '20260314-001',
|
||||
last_seen_at: '2026-03-14T08:00:00Z',
|
||||
active_event_count: 0,
|
||||
cpu_usage_percent: 45,
|
||||
memory_usage_percent: 50,
|
||||
storage_usage_percent: 60,
|
||||
request_count: 600,
|
||||
error_count: 6,
|
||||
unique_visitor_count: 120,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
node_id: 'node-b',
|
||||
name: 'edge-b',
|
||||
geo_name: 'San Francisco',
|
||||
geo_latitude: 37.7749,
|
||||
geo_longitude: -122.4194,
|
||||
status: 'online',
|
||||
openresty_status: 'unhealthy',
|
||||
current_version: '20260313-001',
|
||||
last_seen_at: '2026-03-14T08:00:00Z',
|
||||
active_event_count: 2,
|
||||
cpu_usage_percent: 92,
|
||||
memory_usage_percent: 88,
|
||||
storage_usage_percent: 95,
|
||||
request_count: 300,
|
||||
error_count: 30,
|
||||
unique_visitor_count: 80,
|
||||
},
|
||||
[
|
||||
1,
|
||||
'node-a',
|
||||
'edge-a',
|
||||
'Shanghai',
|
||||
31.2304,
|
||||
121.4737,
|
||||
'online',
|
||||
'healthy',
|
||||
'20260314-001',
|
||||
'2026-03-14T08:00:00Z',
|
||||
0,
|
||||
45,
|
||||
50,
|
||||
60,
|
||||
600,
|
||||
6,
|
||||
120,
|
||||
],
|
||||
[
|
||||
2,
|
||||
'node-b',
|
||||
'edge-b',
|
||||
'San Francisco',
|
||||
37.7749,
|
||||
-122.4194,
|
||||
'online',
|
||||
'unhealthy',
|
||||
'20260313-001',
|
||||
'2026-03-14T08:00:00Z',
|
||||
2,
|
||||
92,
|
||||
88,
|
||||
95,
|
||||
300,
|
||||
30,
|
||||
80,
|
||||
],
|
||||
],
|
||||
},
|
||||
}),
|
||||
@@ -183,7 +183,6 @@ describe('DashboardOverview', () => {
|
||||
renderDashboardOverview();
|
||||
|
||||
expect(await screen.findByText('全球态势板')).toBeInTheDocument();
|
||||
expect(await screen.findByText('系统健康摘要')).toBeInTheDocument();
|
||||
expect(await screen.findByText('24 小时请求趋势')).toBeInTheDocument();
|
||||
expect(await screen.findByText('来源分布')).toBeInTheDocument();
|
||||
expect(await screen.findByText('Top Domain')).toBeInTheDocument();
|
||||
|
||||
Reference in New Issue
Block a user