52 Commits

Author SHA1 Message Date
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
d8ec4e7142 fix: tabular row selection visibility - CSS specificity fix for dark/light themes
- Dark theme: .tabular-cell color was overriding .tabular-row-selected color
  due to same specificity and later position. Added !important and combined
  selector .tabular-row-selected .tabular-cell to fix.
- Added background-color change for selected rows (both themes)
- Added cursor:pointer on .tabular-row for better UX
- Light theme: added blue-tinted background + darker text for selected rows
2026-05-29 13:44:46 +08:00
37b648da0e feat: wire Menu collapse/expand to sidebar toggle button + menu-collapsed CSS 2026-05-29 11:12:56 +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
3659533102 fix: responsive layout - sidebar collapse, mobile adaptation, prevent text jumping
- Fix text jumping on right side when screen narrows (min-width:0 on flex item)
- Fix sidebar toggle button not working (retry icon init, proper state sync)
- Mobile adaptation: sidebar as overlay with slide animation
- Auto-collapse sidebar on mobile viewport (<=768px)
- Click outside sidebar to close on mobile
- Responsive padding for stat cards and main content
- Hide brand title on very small screens (<=480px)
- Smooth transitions for sidebar collapse/expand
2026-05-28 16:58:29 +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
9f8e5a6d1c fix: retry theme icon update until bricks button element exists 2026-05-28 14:33:59 +08:00
22a8dc7ceb fix: ensure theme switching works for all containers including sage-shell, topbar, sidebar, and main content area 2026-05-28 14:14:19 +08:00
4170c0b009 fix: remove global_menu_widget id from sageReloadMenu urlwidget 2026-05-28 10:35:10 +08:00
56a9a13db1 refactor: remove shell.ui and global_menu.ui (moved to sage/wwwroot)
dashboard_for_sage now only handles dashboard content when the
dashboard menu item is clicked. Shell layout and global menu are
sage-level concerns managed in sage/wwwroot/index.ui and
sage/wwwroot/global_menu.ui.
2026-05-27 18:43:51 +08:00
741daafdef refactor: rename event sage_login to user_logined 2026-05-27 18:01:53 +08:00
cbe725bcee feat: dynamic menu reload on login/logout
- shell.ui: add id to menu urlwidget, binds for sage_login/sage_logout events
- shell_theme.js: add sageReloadMenu() to rebuild menu urlwidget
- global_menu.ui: complete with all 22 modules and role-based visibility
2026-05-27 17:57:40 +08:00
dfe6c0e14f feat: 完善global_menu.ui,添加所有模块菜单项
新增模块:
- 统一仪表板 (unified_dashboard)
- CRM系统 (integrated_crm_app)
- 客户管理 (customer_management)
- 商机管理 (opportunity_management)
- 合同管理 (contract_management)
- 折扣管理 (discount)
- 财务管理 (financial_management)
- 工作流审批 (workflow_approval)
- 算力中心管理 (cpcc)
- 运维管理 (msp)
- 内容管理 (cms/entcms)
- 钉钉审批 (cms/dingdingflow)

总计22个模块菜单项,覆盖所有业务模块
2026-05-27 17:50:19 +08:00
61a1b2b2fa feat: integrate bricks.Router into shell
- shell_theme.js: call bricks.Router.init() with sage_main_content target
- Remove standalone spa_router.js (now built into bricks)
- Remove spa_router.js from load_path.py RBAC
2026-05-27 15:19:19 +08:00
0032e364b1 feat: add spa_router.js RBAC permission (any) 2026-05-27 14:10:14 +08:00
39fe93438c feat: SPA router for bricks - URL state management
- Intercepts buildUrlwidgetHandler to track navigation to sage_main_content
- Updates browser URL via History API (pushState) on page changes
- Restores page state on browser refresh via ?page= URL parameter
- Supports browser back/forward buttons via popstate event
- Supports deep linking (direct URL access to specific pages)
- URL format: /?page=/module/index.ui
2026-05-27 14:08:39 +08:00
7987c24e26 fix: 完善shell_theme.css深色/浅色主题CRUD组件覆盖(tabular/popup/form/accordion等) 2026-05-26 23:44:14 +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
95d18e7ce0 feat: add product_management and supplychain to global menu 2026-05-26 14:07:48 +08:00
b8ac00ea16 feat: switch all modules to index.ui, add pricing and accounting entries 2026-05-26 13:59:24 +08:00
583f35ad6d feat: switch llmage and rag global menu to index.ui 2026-05-26 12:21:01 +08:00
93a387c9ed Revert "feat: update global_menu.ui - all modules point to index.ui, add pricing and accounting, remove submenu"
This reverts commit 27213ed3c50a221b90ae904eff06ed057826d4aa.
2026-05-26 12:17:34 +08:00
27213ed3c5 feat: update global_menu.ui - all modules point to index.ui, add pricing and accounting, remove submenu 2026-05-26 12:11:21 +08:00
a8eaa4e219 fix: get_new_users_month - use 'created_at' instead of non-existent 'created_date' column in users table 2026-05-26 11:18:53 +08:00
87dc6da0af fix: top_models.dspy return data via 'return' instead of 'print' 2026-05-26 11:14:56 +08:00
f74f8aed8d fix: restore shell_theme.css/js permissions in load_path.py (ahserver still requires RBAC check for auto-served static files) 2026-05-26 08:40:08 +08:00
0f470fca61 fix: remove manual css/js references from shell.ui and load_path.py
- Remove Html widget in shell.ui that manually loaded shell_theme.css/js
  (ahserver auto-serves wwwroot js/css files)
- Remove shell_theme.css/js from load_path.py permission list
  (ahserver handles static resources automatically)
2026-05-26 07:36:52 +08:00
f2b2e5d6e7 fix: set shell_theme.css/js to 'any' role (static resources need public access) 2026-05-25 22:32:06 +08:00
fd8443f445 feat: add scripts/load_path.py for RBAC permission initialization
- Add scripts/load_path.py with all 28 wwwroot paths
- menu.ui set to 'any' role (public nav access)
- All other paths set to 'logined' role (dashboard visible to authenticated users)
- Idempotent: skips already-registered paths
2026-05-25 22:24:48 +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
753887a4e2 bugfix 2026-05-25 11:19:24 +08:00
f565672aa1 bugfix 2026-05-24 23:56:40 +08:00
ac9a0e9fd3 fix: ChartBar data param 'data' -> 'user_data' to match EchartsExt constructor 2026-05-24 23:08:31 +08:00
40648df92a fix: export load_dashboard_for_sage alias in init.py for sage.py import 2026-05-24 19:24:59 +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
b83131146a fix: getBaseUrl() returns correct module prefix for /dashboard_for_sage path 2026-05-24 15:41:57 +08:00
1a3412176d Move JS file to wwwroot root per bricks convention (no subdirectories for JS/CSS) 2026-05-24 14:46:00 +08:00
ae613a1dc2 Update build.sh and README with load_path.py RBAC setup step 2026-05-24 14:34:39 +08:00
89a1e1eb59 Add README, .gitignore, and fix build.sh Sage root detection 2026-05-24 14:10:26 +08:00
3e18ed58b5 Add build.sh symlink fix and README 2026-05-24 14:09:14 +08:00