Files
DataMate/frontend/src/components/TaskPopover.tsx
chenghh-9609 e8e2c1a96b refactor: 修复标签管理功能、优化数据选择项显示、屏蔽开发中功能 (#12)
* refactor: clean up tag management and dataset handling, update API endpoints

* feat: add showTime prop to DevelopmentInProgress component across multiple pages

* refactor: update component styles and improve layout with new utility classes
2025-10-22 16:09:03 +08:00

163 lines
5.3 KiB
TypeScript

import { Button, Popover, Progress } from "antd";
import { Calendar, Clock, Play, Trash2, X } from "lucide-react";
interface TaskItem {
id: string;
name: string;
status: string;
progress: number;
scheduleConfig: {
type: string;
cronExpression?: string;
executionCount?: number;
maxExecutions?: number;
};
nextExecution?: string;
importConfig: {
source?: string;
};
createdAt: string;
}
export default function TaskPopover() {
const tasks: TaskItem[] = [
{
id: "1",
name: "导入客户数据",
status: "importing",
progress: 65,
scheduleConfig: {
type: "manual",
},
importConfig: {
source: "local",
},
createdAt: "2025-07-29 14:23",
},
{
id: "2",
name: "定时同步订单",
status: "waiting",
progress: 0,
scheduleConfig: {
type: "scheduled",
cronExpression: "0 0 * * *",
executionCount: 3,
maxExecutions: 10,
},
nextExecution: "2025-07-31 00:00",
importConfig: {
source: "api",
},
createdAt: "2025-07-28 09:10",
},
{
id: "3",
name: "清理历史日志",
status: "finished",
progress: 100,
scheduleConfig: {
type: "manual",
},
importConfig: {
source: "system",
},
createdAt: "2025-07-27 17:45",
},
];
return (
<Popover
placement="topLeft"
content={
<div className="w-[500px]">
<div className="flex items-center justify-between">
<h3 className="font-medium text-gray-900"></h3>
<Button type="text" className="h-6 w-6 p-0">
<X className="w-4 h-4 text-black-400 hover:text-gray-500" />
</Button>
</div>
<div className="p-2">
{tasks.length === 0 ? (
<div className="text-center py-8 text-gray-500">
<Clock className="w-8 h-8 mx-auto mb-2 text-gray-300" />
<p className="text-sm"></p>
</div>
) : (
<div className="space-y-2">
{tasks.map((task) => (
<div
key={task.id}
className="p-3 border-card hover:bg-gray-50"
>
<div className="space-y-2">
<div className="flex items-center justify-between">
<h4 className="font-medium text-sm truncate flex-1">
{task.name}
</h4>
<div className="flex items-center gap-2">
{task.status === "waiting" && (
<Button
className="h-6 w-6 p-0 text-blue-500 hover:text-blue-700"
title="立即执行"
>
<Play className="w-3 h-3" />
</Button>
)}
<Button className="h-6 w-6 p-0 text-gray-400 hover:text-red-500">
<Trash2 className="w-3 h-3" />
</Button>
</div>
</div>
{task.status === "importing" && (
<div className="space-y-1">
<div className="flex justify-between text-xs text-gray-500">
<span></span>
<span>{Math.round(task.progress)}%</span>
</div>
<Progress percent={task.progress} />
</div>
)}
{/* Schedule Information */}
{task.scheduleConfig.type === "scheduled" && (
<div className="text-xs text-gray-500 bg-gray-50 p-2 rounded">
<div className="flex items-center gap-1 mb-1">
<Calendar className="w-3 h-3" />
<span className="font-medium"></span>
</div>
<div>Cron: {task.scheduleConfig.cronExpression}</div>
{task.nextExecution && (
<div>: {task.nextExecution}</div>
)}
<div>
: {task.scheduleConfig.executionCount || 0}/
{task.scheduleConfig.maxExecutions || 10}
</div>
</div>
)}
<div className="flex items-center justify-between text-xs text-gray-400">
<span>
{task.importConfig.source === "local"
? "本地上传"
: task.importConfig.source || "未知来源"}
</span>
<span>{task.createdAt}</span>
</div>
</div>
</div>
))}
</div>
)}
</div>
</div>
}
>
<Button block></Button>
</Popover>
);
}