From 22ef5b2f8037c1f78b656636bc07db7a1b7fa311 Mon Sep 17 00:00:00 2001 From: CaIon Date: Tue, 28 Apr 2026 19:16:18 +0800 Subject: [PATCH] feat(dashboard): update model analytics section and enhance user charts functionality - Renamed "Models" to "Model Call Analytics" and updated descriptions for clarity. - Introduced a new state for top user limits in user charts, allowing users to select the number of top users displayed. - Enhanced user charts to include total call count display and improved data processing for better analytics. - Added new translations for updated terms in multiple languages to support internationalization. --- .../components/models/model-charts.tsx | 7 ++++- .../components/users/user-charts.tsx | 30 +++++++++++++++++-- web/default/src/features/dashboard/index.tsx | 4 +-- .../src/features/dashboard/lib/charts.ts | 22 ++++++++++---- .../features/dashboard/section-registry.tsx | 4 +-- web/default/src/features/dashboard/types.ts | 1 + web/default/src/i18n/locales/en.json | 4 +++ web/default/src/i18n/locales/fr.json | 4 +++ web/default/src/i18n/locales/ja.json | 4 +++ web/default/src/i18n/locales/ru.json | 4 +++ web/default/src/i18n/locales/vi.json | 4 +++ web/default/src/i18n/locales/zh.json | 16 ++++++---- 12 files changed, 85 insertions(+), 19 deletions(-) diff --git a/web/default/src/features/dashboard/components/models/model-charts.tsx b/web/default/src/features/dashboard/components/models/model-charts.tsx index 1d79d6cf..cdfb1ad0 100644 --- a/web/default/src/features/dashboard/components/models/model-charts.tsx +++ b/web/default/src/features/dashboard/components/models/model-charts.tsx @@ -78,7 +78,12 @@ export function ModelCharts(props: ModelChartsProps) {
-
{t('Model Analytics')}
+
+ {t('Model Call Analytics')} +
+ + {t('Total:')} {chartData.totalCountDisplay} +
diff --git a/web/default/src/features/dashboard/components/users/user-charts.tsx b/web/default/src/features/dashboard/components/users/user-charts.tsx index 8108f8bd..d5d2d573 100644 --- a/web/default/src/features/dashboard/components/users/user-charts.tsx +++ b/web/default/src/features/dashboard/components/users/user-charts.tsx @@ -41,6 +41,8 @@ const USER_CHARTS: { }, ] +const TOP_USER_LIMIT_OPTIONS = [5, 10, 20, 50] + export function UserCharts() { const { t } = useTranslation() const { resolvedTheme } = useTheme() @@ -55,6 +57,7 @@ export function UserCharts() { const [selectedRange, setSelectedRange] = useState(() => getDefaultDays(timeGranularity) ) + const [topUserLimit, setTopUserLimit] = useState(10) const [timeRange, setTimeRange] = useState(() => { const days = getDefaultDays(timeGranularity) const { start, end } = getNormalizedDateRange(days) @@ -113,9 +116,10 @@ export function UserCharts() { processUserChartData( isLoading ? [] : (userData ?? []), timeGranularity, - t + t, + topUserLimit ), - [userData, isLoading, timeGranularity, t] + [userData, isLoading, timeGranularity, t, topUserLimit] ) return ( @@ -158,6 +162,26 @@ export function UserCharts() { ))}
+
+ + {t('Top Users')} + + {TOP_USER_LIMIT_OPTIONS.map((limit) => ( + + ))} +
+ {isLoading && ( )} @@ -184,7 +208,7 @@ export function UserCharts() { themeReady && spec && ( + }> + ) => { + for (let i = 0; i < array.length; i++) { + const rawQuota = array[i].datum?.rawQuota + const value = + rawQuota === undefined ? array[i].value : Number(rawQuota) + array[i].value = formatVal(Number(value) || 0) + } + return array + }, }, }, color: { specified: userColorMap }, diff --git a/web/default/src/features/dashboard/section-registry.tsx b/web/default/src/features/dashboard/section-registry.tsx index 8178fb1f..2b1be5ee 100644 --- a/web/default/src/features/dashboard/section-registry.tsx +++ b/web/default/src/features/dashboard/section-registry.tsx @@ -13,8 +13,8 @@ const DASHBOARD_SECTIONS = [ }, { id: 'models', - titleKey: 'Models', - descriptionKey: 'View model statistics and charts', + titleKey: 'Model Call Analytics', + descriptionKey: 'View model call count analytics and charts', build: () => null, }, { diff --git a/web/default/src/features/dashboard/types.ts b/web/default/src/features/dashboard/types.ts index 32f5f117..d046e5dc 100644 --- a/web/default/src/features/dashboard/types.ts +++ b/web/default/src/features/dashboard/types.ts @@ -75,6 +75,7 @@ export interface ProcessedChartData { spec_model_line: VChartSpec spec_rank_bar: VChartSpec totalQuotaDisplay: string + totalCountDisplay: string } export interface ProcessedUserChartData { diff --git a/web/default/src/i18n/locales/en.json b/web/default/src/i18n/locales/en.json index 25d1153d..0c5fc96b 100644 --- a/web/default/src/i18n/locales/en.json +++ b/web/default/src/i18n/locales/en.json @@ -1957,6 +1957,7 @@ "Model": "Model", "Model Access": "Model Access", "Model Analytics": "Model Analytics", + "Model Call Analytics": "Model Call Analytics", "Model context usage": "Model context usage", "Model deleted": "Model deleted", "Model deleted successfully": "Model deleted successfully", @@ -3303,7 +3304,9 @@ "Tool identifier": "Tool identifier", "Tool price settings": "Tool price settings", "Tool prices": "Tool prices", + "Top {{count}}": "Top {{count}}", "Top Models": "Top Models", + "Top Users": "Top Users", "Top up balance and view billing history.": "Top up balance and view billing history.", "Top-up": "Top-up", "Top-up amount options": "Top-up amount options", @@ -3548,6 +3551,7 @@ "View document": "View document", "View logs": "View logs", "View mode": "View mode", + "View model call count analytics and charts": "View model call count analytics and charts", "View model statistics and charts": "View model statistics and charts", "View Pricing": "View Pricing", "View the complete details for this": "View the complete details for this", diff --git a/web/default/src/i18n/locales/fr.json b/web/default/src/i18n/locales/fr.json index 1a919f36..d0f78d4e 100644 --- a/web/default/src/i18n/locales/fr.json +++ b/web/default/src/i18n/locales/fr.json @@ -1957,6 +1957,7 @@ "Model": "Modèle", "Model Access": "Accès au modèle", "Model Analytics": "Analyse des modèles", + "Model Call Analytics": "Analyse des appels de modèles", "Model context usage": "Utilisation du contexte du modèle", "Model deleted": "Modèle supprimé", "Model deleted successfully": "Modèle supprimé avec succès", @@ -3303,7 +3304,9 @@ "Tool identifier": "Identifiant d’outil", "Tool price settings": "Paramètres de prix des outils", "Tool prices": "Prix des outils", + "Top {{count}}": "Top {{count}}", "Top Models": "Top Modèles", + "Top Users": "Top utilisateurs", "Top up balance and view billing history.": "Recharger le solde et consulter l'historique de facturation.", "Top-up": "Recharge", "Top-up amount options": "Options de montant de recharge", @@ -3548,6 +3551,7 @@ "View document": "Afficher le document", "View logs": "Voir les logs", "View mode": "Mode d'affichage", + "View model call count analytics and charts": "Afficher les analyses et graphiques du nombre d'appels par modèle", "View model statistics and charts": "Afficher les statistiques et graphiques des modèles", "View Pricing": "Voir les tarifs", "View the complete details for this": "Voir les détails complets de ce", diff --git a/web/default/src/i18n/locales/ja.json b/web/default/src/i18n/locales/ja.json index 600c7dab..0027340c 100644 --- a/web/default/src/i18n/locales/ja.json +++ b/web/default/src/i18n/locales/ja.json @@ -1957,6 +1957,7 @@ "Model": "モデル", "Model Access": "モデルアクセス", "Model Analytics": "モデル分析", + "Model Call Analytics": "モデル呼び出し分析", "Model context usage": "モデルのコンテキスト使用量", "Model deleted": "モデルが削除されました", "Model deleted successfully": "モデルが正常に削除されました", @@ -3303,7 +3304,9 @@ "Tool identifier": "ツールID", "Tool price settings": "ツール価格設定", "Tool prices": "ツール価格", + "Top {{count}}": "上位 {{count}}", "Top Models": "トップモデル", + "Top Users": "上位ユーザー", "Top up balance and view billing history.": "残高をチャージし、請求履歴を確認。", "Top-up": "チャージ", "Top-up amount options": "トップアップ金額オプション", @@ -3548,6 +3551,7 @@ "View document": "ドキュメントを表示", "View logs": "ログを表示", "View mode": "表示モード", + "View model call count analytics and charts": "モデル呼び出し回数の分析とグラフを表示", "View model statistics and charts": "モデルの統計とグラフを表示", "View Pricing": "価格を見る", "View the complete details for this": "この", diff --git a/web/default/src/i18n/locales/ru.json b/web/default/src/i18n/locales/ru.json index 54de3867..6affe7e7 100644 --- a/web/default/src/i18n/locales/ru.json +++ b/web/default/src/i18n/locales/ru.json @@ -1957,6 +1957,7 @@ "Model": "Модель", "Model Access": "Доступ к моделям", "Model Analytics": "Аналитика моделей", + "Model Call Analytics": "Аналитика вызовов моделей", "Model context usage": "Использование контекста модели", "Model deleted": "Модель удалена", "Model deleted successfully": "Модель успешно удалена", @@ -3303,7 +3304,9 @@ "Tool identifier": "Идентификатор инструмента", "Tool price settings": "Настройки цен на инструменты", "Tool prices": "Цены инструментов", + "Top {{count}}": "Топ {{count}}", "Top Models": "Лучшие модели", + "Top Users": "Лучшие пользователи", "Top up balance and view billing history.": "Пополнить баланс и просмотреть историю платежей.", "Top-up": "Пополнение", "Top-up amount options": "Варианты суммы пополнения", @@ -3548,6 +3551,7 @@ "View document": "Просмотреть документ", "View logs": "Просмотреть логи", "View mode": "Режим отображения", + "View model call count analytics and charts": "Просмотр аналитики и графиков количества вызовов моделей", "View model statistics and charts": "Просмотр статистики и графиков моделей", "View Pricing": "Посмотреть цены", "View the complete details for this": "Просмотр полных деталей этой", diff --git a/web/default/src/i18n/locales/vi.json b/web/default/src/i18n/locales/vi.json index 79248138..ce27d36b 100644 --- a/web/default/src/i18n/locales/vi.json +++ b/web/default/src/i18n/locales/vi.json @@ -1957,6 +1957,7 @@ "Model": "Mô hình", "Model Access": "Truy cập mô hình", "Model Analytics": "Phân tích mô hình", + "Model Call Analytics": "Phân tích lượt gọi mô hình", "Model context usage": "Sử dụng ngữ cảnh mô hình", "Model deleted": "Đã xóa mô hình", "Model deleted successfully": "Model đã được xóa thành công", @@ -3303,7 +3304,9 @@ "Tool identifier": "Định danh công cụ", "Tool price settings": "Cài đặt giá công cụ", "Tool prices": "Giá công cụ", + "Top {{count}}": "Top {{count}}", "Top Models": "Người mẫu hàng đầu", + "Top Users": "Người dùng hàng đầu", "Top up balance and view billing history.": "Nạp tiền vào tài khoản và xem lịch sử thanh toán.", "Top-up": "Nạp tiền", "Top-up amount options": "Tùy chọn số tiền nạp", @@ -3548,6 +3551,7 @@ "View document": "Xem tài liệu", "View logs": "Xem nhật ký", "View mode": "Chế độ xem", + "View model call count analytics and charts": "Xem phân tích và biểu đồ số lượt gọi mô hình", "View model statistics and charts": "Xem thống kê và biểu đồ mô hình", "View Pricing": "View price", "View the complete details for this": "Xem chi tiết đầy đủ của", diff --git a/web/default/src/i18n/locales/zh.json b/web/default/src/i18n/locales/zh.json index 56c74722..5b87cc57 100644 --- a/web/default/src/i18n/locales/zh.json +++ b/web/default/src/i18n/locales/zh.json @@ -351,7 +351,7 @@ "Audio playback failed": "音频无法播放", "Audio Preview": "音乐预览", "Audio ratio": "音频倍率", - "Audio Tokens": "语音令牌", + "Audio Tokens": "语音 Token", "Auth Style": "认证方式", "Authentication": "身份验证", "Authenticator code": "身份验证器代码", @@ -911,7 +911,7 @@ "Default API Version *": "默认 API 版本 *", "Default API version for this channel": "此渠道的默认 API 版本", "Default Collapse Sidebar": "默认折叠侧边栏", - "Default Max Tokens": "默认最大令牌数", + "Default Max Tokens": "默认最大 Token 数", "Default Responses API version, if empty, will use the API version above": "默认响应 API 版本,如果为空,将使用上面的 API 版本", "Default system prompt for this channel": "此渠道的默认系统提示", "Default time granularity": "默认时间粒度", @@ -1030,7 +1030,7 @@ "Display name for this payment method.": "此支付方式的显示名称。", "Display name shown to users.": "显示给用户的名称。", "Display Options": "显示选项", - "Display Token Statistics": "显示令牌统计信息", + "Display Token Statistics": "显示 Token 统计信息", "Displays the mobile sidebar.": "显示移动侧边栏。", "Do not over-trust this feature. IP may be spoofed. Please use with nginx, CDN and other gateways.": "请勿过度信任此功能,IP 可能被伪造,请配合 nginx 和 cdn 等网关使用", "Do not repeat check-in; only once per day": "请勿重复签到;每天仅一次", @@ -1957,6 +1957,7 @@ "Model": "模型", "Model Access": "模型访问", "Model Analytics": "模型数据分析", + "Model Call Analytics": "模型调用分析", "Model context usage": "模型上下文用量", "Model deleted": "模型已删除", "Model deleted successfully": "模型删除成功", @@ -3053,7 +3054,7 @@ "Static page describing the platform.": "描述平台的静态页面。", "Statistical count": "统计计数", "Statistical quota": "统计配额", - "Statistical tokens": "统计令牌", + "Statistical tokens": "统计 Token 数", "Statistics reset": "统计已重置", "Status": "状态", "Status & Sync": "状态与同步", @@ -3297,13 +3298,15 @@ "tokens": "令牌", "Tokens": "令牌", "Tokens Only": "仅限 Token", - "Tokens per minute": "每分钟令牌数", + "Tokens per minute": "每分钟 Token 数", "Tokens-only mode will show raw quota values regardless of this toggle.": "Tokens-only 模式将无视此开关显示原始配额值。", "Too many files. Some were not added.": "文件过多。部分未添加。", "Tool identifier": "工具标识", "Tool price settings": "工具价格设置", "Tool prices": "工具价格", + "Top {{count}}": "前 {{count}}", "Top Models": "热门模型", + "Top Users": "热门用户", "Top up balance and view billing history.": "充值余额并查看账单历史。", "Top-up": "充值", "Top-up amount options": "充值金额选项", @@ -3328,7 +3331,7 @@ "Total Quota": "总额度", "Total requests allowed per period. 0 = unlimited.": "每周期允许的总请求数。0 = 无限制。", "Total requests made": "总请求数", - "Total Tokens": "总令牌数", + "Total Tokens": "总 Token 数", "Total Usage": "总用量", "Total:": "总计:", "TPM": "TPM", @@ -3548,6 +3551,7 @@ "View document": "查看文档", "View logs": "查看日志", "View mode": "视图模式", + "View model call count analytics and charts": "查看模型调用次数统计和图表", "View model statistics and charts": "查看模型统计和图表", "View Pricing": "查看定价", "View the complete details for this": "查看此条",