Skip to content

Commit be023d8

Browse files
authored
enhance system config page (#61)
* feat: Update site name to DataMate and refine text for AI data processing * feat: Refactor settings page and implement model access functionality - Created a new ModelAccess component for managing model configurations. - Removed the old Settings component and replaced it with a new SettingsPage component that integrates ModelAccess, SystemConfig, and WebhookConfig. - Added SystemConfig component for managing system settings. - Implemented WebhookConfig component for managing webhook configurations. - Updated API functions for model management in settings.apis.ts. - Adjusted routing to point to the new SettingsPage component. * feat: Implement Data Collection Page with Task Management and Execution Log - Created DataCollectionPage component to manage data collection tasks. - Added TaskManagement and ExecutionLog components for task handling and logging. - Integrated task operations including start, stop, edit, and delete functionalities. - Implemented filtering and searching capabilities in task management. - Introduced SimpleCronScheduler for scheduling tasks with cron expressions. - Updated CreateTask component to utilize new scheduling and template features. - Enhanced BasicInformation component to conditionally render fields based on visibility settings. - Refactored ImportConfiguration component to remove NAS import section. * feat: Update task creation API endpoint and enhance task creation form with new fields and validation * Refactor file upload and operator management components - Removed unnecessary console logs from file download and export functions. - Added size property to TaskItem interface for better task management. - Simplified TaskUpload component by utilizing useFileSliceUpload hook for file upload logic. - Enhanced OperatorPluginCreate component to handle file uploads and parsing more efficiently. - Updated ConfigureStep component to use Ant Design Form for better data handling and validation. - Improved PreviewStep component to navigate back to the operator market. - Added support for additional file types in UploadStep component. - Implemented delete operator functionality in OperatorMarketPage with confirmation prompts. - Cleaned up unused API functions in operator.api.ts to streamline the codebase. - Fixed number formatting utility to handle zero values correctly. * Refactor Knowledge Generation to Knowledge Base - Created new API service for Knowledge Base operations including querying, creating, updating, and deleting knowledge bases and files. - Added constants for Knowledge Base status and type mappings. - Defined models for Knowledge Base and related files. - Removed obsolete Knowledge Base creation and home components, replacing them with new implementations under the Knowledge Base structure. - Updated routing to reflect the new Knowledge Base paths. - Adjusted menu items to align with the new Knowledge Base terminology. - Modified ModelAccess interface to include modelName and type properties. * feat: Implement Knowledge Base Page with CRUD operations and data management - Added KnowledgeBasePage component for displaying and managing knowledge bases. - Integrated search and filter functionalities with SearchControls component. - Implemented CreateKnowledgeBase component for creating and editing knowledge bases. - Enhanced AddDataDialog for file uploads and dataset selections. - Introduced TableTransfer component for managing data transfers between tables. - Updated API functions for knowledge base operations, including file management. - Refactored knowledge base model to include file status and metadata. - Adjusted routing to point to the new KnowledgeBasePage. * feat: enhance OperatorPluginCreate and ConfigureStep for better upload handling and UI updates * refactor: remove unused components and clean up API logging in KnowledgeBase * feat: update icons in various components and improve styling for better UI consistency * fix: adjust upload step handling and improve error display in configuration step * feat: Add RatioTransfer component for dataset selection and configuration - Implemented RatioTransfer component to manage dataset selection and ratio configuration. - Integrated dataset fetching with search and filter capabilities. - Added RatioConfig component for displaying and updating selected datasets' configurations. - Enhanced SelectDataset component with improved UI and functionality for dataset selection. - Updated RatioTasksPage to utilize new ratio task status mapping and improved error handling for task deletion. - Refactored ratio model and constants for better type safety and clarity. - Changed Vite configuration to use local backend service for development. * feat: Add .editorconfig and enhance SystemConfig with table for settings display
1 parent f78475e commit be023d8

File tree

4 files changed

+196
-53
lines changed

4 files changed

+196
-53
lines changed

frontend/.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.{md}]
12+
trim_trailing_whitespace = false
13+

frontend/src/pages/Home/Home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export default function WelcomePage() {
134134
{menuItems.map((item) => (
135135
<Card
136136
key={item.id}
137-
onClick={() => navigate(`/data/${item.id}`)}
137+
onClick={() => navigate(item.children ? `/data/${item.children[0].id}`: `/data/${item.id}`)}
138138
className="cursor-pointer hover:shadow-lg transition-all duration-200 border-0 shadow-md relative overflow-hidden group"
139139
>
140140
<div className="text-center relative">

frontend/src/pages/RatioTask/ratio.const.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { formatDate } from "@/utils/unit";
22
import { RatioTaskItem, RatioStatus } from "./ratio.model";
3+
import { BarChart3 } from "lucide-react";
4+
import { Link } from "react-router";
35

46
export const ratioTaskStatusMap: Record<
57
string,
@@ -42,5 +44,29 @@ export function mapRatioTask(task: Partial<RatioTaskItem>): RatioTaskItem {
4244
status: ratioTaskStatusMap[task.status || RatioStatus.PENDING]?.value,
4345
createdAt: formatDate(task.created_at),
4446
updatedAt: formatDate(task.updated_at),
47+
description:
48+
task.ratio_method === "DATASET" ? "按数据集配比" : "按标签配比",
49+
icon: <BarChart3 className="w-6 h-6" />,
50+
iconColor: task.ratio_method === "DATASET" ? "bg-blue-100" : "bg-green-100",
51+
statistics: [
52+
{
53+
label: "目标数量",
54+
value: (task.totals ?? 0).toLocaleString(),
55+
},
56+
{
57+
label: "目标数据集",
58+
value: task.target_dataset_name ? (
59+
<Link to={`/data/management/detail/${task.target_dataset_id}`}>
60+
{task.target_dataset_name}
61+
</Link>
62+
) : (
63+
"无"
64+
),
65+
},
66+
{
67+
label: "创建时间",
68+
value: task.created_at || "-",
69+
},
70+
],
4571
};
4672
}
Lines changed: 156 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Card, Divider, Input, Select, Switch, Button, Form, App } from "antd";
1+
import { Divider, Input, Select, Switch, Button, Form, App, Table } from "antd";
2+
import { PlusOutlined } from "@ant-design/icons";
23
import { useState } from "react";
34

45
export default function SystemConfig() {
@@ -12,6 +13,38 @@ export default function SystemConfig() {
1213
sessionTimeout: "30",
1314
enableNotifications: true,
1415
});
16+
const configData = [
17+
{
18+
key: "1",
19+
parameter: "站点名称",
20+
value: systemConfig.siteName,
21+
description: "系统的显示名称",
22+
},
23+
{
24+
key: "2",
25+
parameter: "最大文件大小 (MB)",
26+
value: systemConfig.maxFileSize,
27+
description: "允许上传的最大文件大小",
28+
},
29+
{
30+
key: "3",
31+
parameter: "自动备份",
32+
value: systemConfig.autoBackup ? "启用" : "禁用",
33+
description: "定期自动备份系统数据",
34+
},
35+
{
36+
key: "4",
37+
parameter: "日志级别",
38+
value: systemConfig.logLevel,
39+
description: "系统日志的详细程度",
40+
},
41+
{
42+
key: "5",
43+
parameter: "会话超时 (分钟)",
44+
value: systemConfig.sessionTimeout,
45+
description: "用户会话的超时时间",
46+
},
47+
];
1548

1649
const logLevelOptions = [
1750
{ value: "debug", label: "Debug" },
@@ -26,61 +59,132 @@ export default function SystemConfig() {
2659
message.success("系统设置已保存");
2760
};
2861

62+
const columns = [
63+
{
64+
title: "参数",
65+
dataIndex: "parameter",
66+
key: "parameter",
67+
},
68+
{
69+
title: "值",
70+
dataIndex: "value",
71+
key: "value",
72+
},
73+
{
74+
title: "描述",
75+
dataIndex: "description",
76+
key: "description",
77+
},
78+
{
79+
title: "是否启用",
80+
dataIndex: "enabled",
81+
key: "enabled",
82+
render: (_: any, record: any) => (
83+
<Switch
84+
checked={
85+
record.key === "3"
86+
? systemConfig.autoBackup
87+
: record.key === "5"
88+
? systemConfig.enableNotifications
89+
: false
90+
}
91+
onChange={(checked) => {
92+
if (record.key === "3") {
93+
setSystemConfig((prevConfig) => ({
94+
...prevConfig,
95+
autoBackup: checked,
96+
}));
97+
} else if (record.key === "5") {
98+
setSystemConfig((prevConfig) => ({
99+
...prevConfig,
100+
enableNotifications: checked,
101+
}));
102+
}
103+
}}
104+
/>
105+
),
106+
}
107+
];
108+
29109
return (
30-
<Card>
31-
<Form
32-
onValuesChange={(changedValues) => {
33-
setSystemConfig((prevConfig) => ({
34-
...prevConfig,
35-
...changedValues,
36-
}));
37-
}}
38-
layout="vertical"
39-
>
40-
<div className="grid grid-cols-2 gap-6">
41-
<Form.Item name="siteName" label="站点名称">
42-
<Input />
43-
</Form.Item>
44-
<Form.Item name="maxFileSize" label="最大文件大小 (MB)">
45-
<Input type="number" />
46-
</Form.Item>
47-
<Form.Item name="logLevel" label="日志级别">
48-
<Select options={logLevelOptions}></Select>
49-
</Form.Item>
50-
<Form.Item name="sessionTimeout" label="会话超时 (分钟)">
51-
<Input type="number" />
52-
</Form.Item>
53-
</div>
54-
<Divider />
55-
<div className="space-y-4">
56-
<h4 className="font-medium">功能开关</h4>
57-
<div className="space-y-3">
58-
<div className="flex items-center justify-between">
59-
<div>
60-
<span>自动备份</span>
61-
<p className="text-sm text-gray-500">定期自动备份系统数据</p>
110+
<div className="h-full flex flex-col">
111+
<div className="flex items-top justify-between">
112+
<h2 className="text-lg font-medium mb-4">参数配置</h2>
113+
<Button
114+
type="primary"
115+
icon={<PlusOutlined />}
116+
onClick={() => {
117+
setIsEditMode(false);
118+
form.resetFields();
119+
setNewModel({
120+
name: "",
121+
provider: "",
122+
model: "",
123+
apiKey: "",
124+
endpoint: "",
125+
});
126+
setShowModelDialog(true);
127+
}}
128+
>
129+
添加模型
130+
</Button>
131+
</div>
132+
<div className="flex-1 border-card overflow-auto p-6">
133+
<Table columns={columns} data={configData} />
134+
<Form
135+
onValuesChange={(changedValues) => {
136+
setSystemConfig((prevConfig) => ({
137+
...prevConfig,
138+
...changedValues,
139+
}));
140+
}}
141+
layout="vertical"
142+
>
143+
<div className="grid grid-cols-2 gap-6 mt-6">
144+
<Form.Item name="siteName" label="站点名称">
145+
<Input />
146+
</Form.Item>
147+
<Form.Item name="maxFileSize" label="最大文件大小 (MB)">
148+
<Input type="number" />
149+
</Form.Item>
150+
<Form.Item name="logLevel" label="日志级别">
151+
<Select options={logLevelOptions}></Select>
152+
</Form.Item>
153+
<Form.Item name="sessionTimeout" label="会话超时 (分钟)">
154+
<Input type="number" />
155+
</Form.Item>
156+
</div>
157+
<Divider />
158+
<div className="space-y-4">
159+
<h4 className="font-medium">功能开关</h4>
160+
<div className="space-y-3">
161+
<div className="flex items-center justify-between">
162+
<div>
163+
<span>自动备份</span>
164+
<p className="text-sm text-gray-500">定期自动备份系统数据</p>
165+
</div>
166+
<Form.Item name="autoBackup" valuePropName="checked">
167+
<Switch />
168+
</Form.Item>
62169
</div>
63-
<Form.Item name="autoBackup" valuePropName="checked">
64-
<Switch />
65-
</Form.Item>
66-
</div>
67-
<div className="flex items-center justify-between">
68-
<div>
69-
<span>启用通知</span>
70-
<p className="text-sm text-gray-500">接收系统通知和提醒</p>
170+
<div className="flex items-center justify-between">
171+
<div>
172+
<span>启用通知</span>
173+
<p className="text-sm text-gray-500">接收系统通知和提醒</p>
174+
</div>
175+
<Form.Item name="enableNotifications" valuePropName="checked">
176+
<Switch />
177+
</Form.Item>
71178
</div>
72-
<Form.Item name="enableNotifications" valuePropName="checked">
73-
<Switch />
74-
</Form.Item>
75179
</div>
76180
</div>
77-
</div>
78-
<div className="flex justify-end mt-6">
79-
<Button type="primary" onClick={handleSaveSystemSettings}>
80-
保存设置
81-
</Button>
82-
</div>
83-
</Form>
84-
</Card>
181+
<div className="flex justify-end mt-6">
182+
<Button type="primary" onClick={handleSaveSystemSettings}>
183+
保存设置
184+
</Button>
185+
</div>
186+
</Form>
187+
</div>
188+
</div>
85189
);
86190
}

0 commit comments

Comments
 (0)