feat(dashboard): add statistics API and enhance homepage dashboard cards

- Add Query and DataResponse interfaces to common API module
- Implement getDashboardStatistics API endpoint for fetching dashboard metrics
- Update TopCardList component to display real dashboard data with dynamic values
- Replace hardcoded dashboard metrics with actual API response data
- Add support for calculating and displaying weekly growth rates for spaces and users
- Update dashboard card labels and descriptions for models, spaces, users, and apps
- Add "Rebuild Graph" button translation to knowledge graph card (en/zh)
- Add appCount and userCount translation keys for dashboard display
- Fix dashboard metric key naming consistency (total_apps_runs → total_running_apps)
- Update dashboard descriptions to reflect weekly comparisons instead of daily
- Improve data binding between API response and UI components for real-time statistics
This commit is contained in:
yujiangping
2026-01-05 16:46:10 +08:00
parent f31341151f
commit 3d4c807a87
8 changed files with 174 additions and 62 deletions

View File

@@ -30,6 +30,7 @@ const CreateModal = forwardRef<CreateModalRef, CreateModalRefProps>(({
const [loading, setLoading] = useState(false);
const [activeTab, setActiveTab] = useState('basic');
const [generatingEntityTypes, setGeneratingEntityTypes] = useState(false);
const [isRebuildMode, setIsRebuildMode] = useState(false);
// 监听 parser_config.graphrag 相关字段的变化
const parserConfig = Form.useWatch('parser_config', form);
@@ -45,6 +46,7 @@ const CreateModal = forwardRef<CreateModalRef, CreateModalRefProps>(({
form.resetFields();
setLoading(false);
setActiveTab('basic');
setIsRebuildMode(false); // 重置重建模式标识
setVisible(false);
};
@@ -224,6 +226,15 @@ const CreateModal = forwardRef<CreateModalRef, CreateModalRefProps>(({
setDatasets(record || null);
const nextType = type || currentType;
setCurrentType(nextType as any);
setIsRebuildMode(type === 'rebuild'); // 设置重建模式标识
// 如果是重建模式,默认切换到知识图谱标签页
if (type === 'rebuild') {
setActiveTab('knowledgeGraph');
} else {
setActiveTab('basic');
}
setBaseFields(record || null, nextType);
getTypeList(record || null);
setVisible(true);
@@ -320,6 +331,9 @@ const CreateModal = forwardRef<CreateModalRef, CreateModalRefProps>(({
// 根据 type 获取标题
const getTitle = () => {
if (isRebuildMode) {
return t('knowledgeBase.rebuildGraph') + ' - ' + (datasets?.name || '');
}
if (datasets?.id) {
return t('knowledgeBase.edit') + ' ' + datasets.name;
}