yumoqing a2a6e9a2d5 refactor: use individual RefreshWidget per stat card with Jinja2 .ui templates
Architecture:
- load_dashboard.py: async data functions registered via load_dashboard()
- init.py: calls load_dashboard() to expose on ServerEnv
- Individual .ui files (Jinja2 templates):
  - today_usage.ui: calls get_today_usage(request)
  - today_amount.ui: calls get_today_amount(request)
  - total_users.ui: calls get_total_users(request)
  - concurrent_users.ui: calls get_concurrent_users(request)
  - top_models_chart.ui: calls get_top_models(request) for ChartBar
- index.ui: each stat card wrapped in own RefreshWidget (10s period)
- Removed deprecated .dspy files (dashboard_cards, get_today_usage,
  get_user_stats, get_top_models)
2026-05-24 17:20:22 +08:00

94 lines
2.9 KiB
XML

{
"widgettype": "VBox",
"options": {
"width": "100%",
"height": "100%",
"padding": "20px",
"bgcolor": "#f0f2f5"
},
"subwidgets": [
{
"widgettype": "Text",
"options": {
"text": "Dashboard",
"fontSize": "24px",
"fontWeight": "bold",
"color": "#333",
"marginBottom": "20px"
}
},
{
"widgettype": "ResponsableBox",
"options": {
"gap": "16px",
"minWidth": "250px"
},
"subwidgets": [
{
"widgettype": "RefreshWidget",
"id": "refresh_today_usage",
"options": {
"period_seconds": 10,
"url": "{{entire_url('today_usage.ui')}}"
}
},
{
"widgettype": "RefreshWidget",
"id": "refresh_today_amount",
"options": {
"period_seconds": 10,
"url": "{{entire_url('today_amount.ui')}}"
}
},
{
"widgettype": "RefreshWidget",
"id": "refresh_total_users",
"options": {
"period_seconds": 10,
"url": "{{entire_url('total_users.ui')}}"
}
},
{
"widgettype": "RefreshWidget",
"id": "refresh_concurrent_users",
"options": {
"period_seconds": 10,
"url": "{{entire_url('concurrent_users.ui')}}"
}
}
]
},
{
"widgettype": "VBox",
"options": {
"bgcolor": "#FFFFFF",
"padding": "24px",
"borderRadius": "8px",
"marginTop": "20px",
"minHeight": "350px",
"boxShadow": "0 2px 8px rgba(0,0,0,0.1)"
},
"subwidgets": [
{
"widgettype": "Text",
"options": {
"text": "Top 3 模型(今日)",
"fontSize": "18px",
"fontWeight": "bold",
"color": "#333",
"marginBottom": "16px"
}
},
{
"widgettype": "RefreshWidget",
"id": "refresh_top_models_chart",
"options": {
"period_seconds": 10,
"url": "{{entire_url('top_models_chart.ui')}}"
}
}
]
}
]
}