35 Commits

Author SHA1 Message Date
Hermes Agent
2fcf32c863 dashboard: 去除热门模型刷新按钮 2026-06-18 10:48:15 +08:00
398e90fa17 fix: dashboard布局重构 - 修复遮挡/热门模型金额/今日指标缺失
1. 热门模型: valueFields改为[total_amount, cnt],与用户/供应商一致
2. 布局重构:
   - 第一行: 今日调用总量+今日交易金额(2个50%宽卡片)
   - 第二行: 用户总数+活跃用户+在线用户+记账异常(4个25%宽卡片)
   - 第三行: 热门模型+用户排行+供应商排行(3个33%宽图表)
3. 图表高度统一250px,间距16px
4. 移除ResponsableBox改用HBox,避免卡片溢出遮挡
5. 移除stat_new_users_month和stat_total_orgs,精简指标
2026-06-02 00:25:12 +08:00
401c7a15bb fix: restore load_dashboard.py (truncated), use CSS vars for dark mode, improve card spacing 2026-06-01 16:39:57 +08:00
759d629bb3 fix: fullscreen background color and stat card layout 2026-06-01 16:14:56 +08:00
bf5cf2b1b2 fix: fullscreen targets dashboard container instead of entire page 2026-06-01 16:09:05 +08:00
966c89080b fix: reduce margins, padding, chart heights to eliminate scrollbar 2026-06-01 16:08:14 +08:00
c89c0d89de refactor: arrange model/user/provider charts in single row 2026-06-01 15:56:14 +08:00
855f376671 refactor: consolidate rankings into combined charts
- Change top models from Top 3 to Top 5
- Simplify titles: remove 'Top X' and parenthetical details
- Replace separate user tables (by amount/by count) with single ChartBar
- Replace separate provider tables with single ChartBar
- Add get_top_users_combined and get_top_providers_combined functions
2026-06-01 15:41:40 +08:00
c9e860c691 remove quick-links panel, chart takes full width 2026-06-01 15:34:18 +08:00
8bed983919 fix: hide '我的今日模型使用' card for non-customer roles
Remove duplicate unprotected card that was always rendered regardless
of role, causing 403 for non-customer users. Keep only the customer-
only version wrapped in {% if 'customer.*' in roles %}.
2026-06-01 15:32:16 +08:00
66f588cd80 add reseller.* role support alongside owner.* 2026-06-01 15:28:36 +08:00
69264b6ec6 restrict my-today-models and customer-monitor to customer.* role only 2026-06-01 15:25:29 +08:00
3cbb0a4719 fix: double comma causing blank page for owner role 2026-06-01 15:06:06 +08:00
14881f83f2 fix: remove stray endif that caused 500 error 2026-06-01 15:01:36 +08:00
40706c4c72 hide customer monitoring from non-customer users 2026-06-01 14:57:27 +08:00
97ca142092 feat: add fullscreen toggle button to dashboard
Added a fullscreen button (⛶) next to the last-update timestamp.
Clicking it toggles browser fullscreen mode using the Fullscreen API.
2026-05-31 13:02:10 +08:00
b648717339 feat: role-based dashboard visibility - customer users see only customer monitoring 2026-05-31 10:22:10 +08:00
98a28d9770 feat: 添加全局今日模型使用图表,替换用户级监控为全量监控
- 新增 get_all_today_models() 函数查询所有用户今日模型使用
- 新增 all_today_models_chart.ui 和 api/all_today_models.dspy
- index.ui 标题改为「今日模型使用(全部)」,数据源改为全量
- load_path.py 注册新路径权限
- 保留原有 user_today_models 供后续个性化需求使用
2026-05-31 10:01:28 +08:00
929ee0e319 feat: 添加客户专属监控 - 组织级每日/每月模型调用统计
- 新增5个后端函数: customer_daily/monthly_models, daily/monthly_summary, daily_trend
- 新增customer_usage.ui主页面: 4个汇总卡片 + 日趋势折线图 + 日/月模型柱状图
- 新增3个API端点(.dspy)和3个图表UI组件
- index.ui添加客户专属监控入口卡片
- RBAC权限配置已更新(load_path.py)
2026-05-31 08:07:25 +08:00
69b7ec5cd0 feat: add user-level model usage chart (我的今日模型使用)
- Add get_user_today_models() function to load_dashboard.py
  Shows current user's today model call counts and amounts
- Create api/user_today_models.dspy endpoint
- Create user_today_models_chart.ui ChartBar widget (30s auto-refresh)
- Add '我的今日模型使用' card section to index.ui with refresh button
- Register new paths in load_path.py (logined permission)
2026-05-31 08:00:22 +08:00
c36ada56b1 fix: sidebar collapse width, CRUD height overflow, dashboard VScrollPanel 2026-05-30 21:20:29 +08:00
e2687054df fix dashboard UI: quick-link css class, stat-card theming, remove hardcoded colors, light theme overrides 2026-05-28 18:10:59 +08:00
79a04be92b fix: remove hardcoded dark theme colors from all .ui files for light theme support 2026-05-28 16:14:01 +08:00
cdd812f935 i18n: convert dashboard text fields to otext+i18n:true for translation
All Chinese text strings converted to use otext with i18n:true so
bricks framework can look up translations. Template strings with
{{...}} left as text (correct - dynamic content).

Affected files:
- index.ui: 数据概览, 快捷入口, 模型管理, 用户管理, 知识库, 异常记录,
  用户消费排行, 用户调用排行, 供应商交易排行, 供应商调用排行, Top 3 模型
- stat_*.ui: 今日活跃用户, 在线用户, 记账异常, 本月新增用户, 今日消费金额,
  今日调用笔数, 组织机构数, 用户总数
- today_amount.ui, today_usage.ui: 今日交易金额, 今日调用笔数
- accounting_errors.ui, concurrent_users.ui, total_users.ui
- table_top_*.ui: 暂无数据
- top_users_amount.ui: 用户金额TOP5, 排名, 用户, 金额, 调用次数
2026-05-28 14:53:20 +08:00
548dc4d15b fix: 快捷入口模型管理和用户管理按钮底色改为#1E293B+白字加粗提升对比度 2026-05-26 23:28:12 +08:00
8ceb769356 fix dashboard: clickable quick entries, full-data ranking tables, dark bg
1. Quick entry shortcuts: Replace VBox (no native click) with Button
   widgets for reliable click event handling. Each entry wraps its
   icon+text in a VBox inside the Button for layout.

2. Ranking tables: Changed get_top_users/ providers queries from
   today-only (WHERE use_date=today) to all-time data so transaction
   counts and amounts always display meaningful results.

3. Background color: Added bgcolor=#0B1120 to top-level index.ui VBox
   so the page background matches the shell theme, eliminating the
   white-vs-dark-blue contrast.
2026-05-26 16:06:54 +08:00
e7fc646372 feat: add user call count top5 and provider transaction top5 monitoring cards
- Add table_top_users_count.ui: user call count ranking (Top 5)
- Add table_top_providers_amount.ui: provider transaction amount ranking (Top 5)
- Add table_top_providers_count.ui: provider call count ranking (Top 5)
- Update index.ui: integrate three new monitoring cards
  - User call ranking full-width card
  - Provider amount + count rankings side-by-side in HBox layout
2026-05-25 21:48:59 +08:00
be1ac95ac7 feat: add user statistics cards to dashboard
- Add get_active_users_today(), get_new_users_month(), get_total_orgs() to load_dashboard.py
- Create stat_active_users.ui, stat_new_users_month.ui, stat_total_orgs.ui widgets
- Add active users card to main stats row
- Add new row with new users this month and total organizations cards
2026-05-25 18:49:25 +08:00
ffdc7fc983 feat: modern UI redesign - shell layout, theme switching, dashboard revamp
Phase 1-2 deliverables:
- shell.ui: Global layout framework (topbar + collapsible sidebar + main content)
- shell_theme.css: Dark/light theme CSS custom properties system
- shell_theme.js: Theme toggle + sidebar collapse with localStorage persistence
- global_menu.ui: Unified module navigation menu with RBAC visibility
- index.ui: Redesigned dashboard homepage with modern stat cards + quick links
- Stat card widgets: today_usage, today_amount, total_users, concurrent, errors
- chart_top_models.ui + api/top_models.dspy: ChartBar with data_url pattern
- table_top_users_amount.ui: Jinja2-rendered user ranking table
- build.sh: Added .css file linking support

Design system:
- Dark theme (default): slate color palette (#0B1120, #111827, #1E293B)
- Light theme: clean white palette with matching structure
- Theme persisted in localStorage, toggled via topbar button
- Sidebar collapsible with icon-only mode, state persisted in localStorage
- Responsive stat cards with hover effects and trend indicators
- Quick link cards for model management, users, knowledge base, errors
2026-05-25 16:53:36 +08:00
fabd127e6f add accounting errors monitoring card (accounting_status='failed') 2026-05-24 17:27:23 +08:00
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
d2210a2996 refactor: use RefreshWidget for stat cards + fix .dspy import violations
Architecture:
- index.ui: title + RefreshWidget(cards) + ChartBar with refresh_period
- RefreshWidget wraps dashboard_cards.dspy → returns full card widget tree
  with live data (cnt, amount, total_users, concurrent_users)
- ChartBar handles its own auto-refresh via refresh_period: 10
- No more JS polling file needed

.dspy import fixes:
- get_today_usage.dspy: remove import json, from datetime import date
- get_user_stats.dspy: remove from datetime import datetime, timedelta
- get_top_models.dspy: remove from datetime import date
- All use pre-loaded datetime module (datetime.date.today(), etc.)
- dashboard_cards.dspy: same pattern, no imports

Permission:
- load_path.py: add dashboard_cards.dspy logined
2026-05-24 16:45:45 +08:00
99e6fed5ef refactor: replace JS polling with RefreshWidget
- Delete dashboard_refresh.js (no longer needed)
- Add api/dashboard_content.dspy returns dynamic UI with live data
  (queries llmusage + users tables server-side, returns full widget tree)
- Simplify index.ui to use RefreshWidget with period_seconds=10
- ChartBar in dashboard_content.dspy auto-fetches top models via data_url
- load_path.py updated separately in sage repo
2026-05-24 16:31:29 +08:00
c7180bda77 fix: rewrite dashboard_refresh.js with correct bricks API
- Replace non-existent bricks.app.find_widget_by_id() with bricks.getWidgetById(id, bricks.app)
- Replace widget.el.textContent with widget.set_text() method
- Fix getBaseUrl() to handle /modulename paths (no .ui suffix) returning /undefined
- Remove chart refresh from JS — use ChartBar's built-in refresh_period: 10
- Update index.ui ChartBar widget with refresh_period: 10
- Also fixed all find_widget_by_id references across skills:
  * bricks-framework SKILL.md (2 occurrences)
  * bricks-framework references: auto-refresh-dashboard.md, auto-refresh-pattern.md, bar.md, line.md, websocket.md
  * module-development-spec references: read-only-module-pattern.md
  * harnessed-module-development SKILL.md (2 occurrences)
  * harnessed-module-development references: reasoning-visualization.md, bricks-ui-pitfalls.md
  * rbac-permission-initialization-pattern references: websocket-debugging.md
2026-05-24 16:05:56 +08:00
6ae20954f3 Initial commit: dashboard module for Sage with auto-refresh statistics 2026-05-24 14:06:38 +08:00