增加团队管理页面
This commit is contained in:
parent
1dbb411e08
commit
10bfa7bcbd
@ -9,10 +9,10 @@ import { DataTablePagination } from '@/components/ui/pagination';
|
||||
import {Tabs, TabsContent, TabsList, TabsTrigger} from '@/components/ui/tabs';
|
||||
import {
|
||||
Loader2, Plus, Search, Edit, Trash2, Play, Pause,
|
||||
Clock, Activity, CheckCircle2, XCircle, FolderKanban, PlayCircle, FileText, BarChart3, List
|
||||
Clock, Activity, CheckCircle2, XCircle, FolderKanban, PlayCircle, FileText, BarChart3, List, Ban
|
||||
} from 'lucide-react';
|
||||
import {useToast} from '@/components/ui/use-toast';
|
||||
import { getScheduleJobs, getJobCategoryList, startJob, pauseJob, resumeJob, stopJob, triggerJob, deleteScheduleJob } from './service';
|
||||
import {getScheduleJobs, getJobCategoryList, startJob, pauseJob, resumeJob, stopJob, triggerJob, disableJob, deleteScheduleJob, enableJob} from './service';
|
||||
import type {ScheduleJobResponse, ScheduleJobQuery, JobCategoryResponse, JobStatus} from './types';
|
||||
import type {Page} from '@/types/base';
|
||||
import {DEFAULT_PAGE_SIZE, DEFAULT_CURRENT} from '@/utils/page';
|
||||
@ -236,6 +236,44 @@ const ScheduleJobList: React.FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 禁用任务
|
||||
const handleDisable = async (record: ScheduleJobResponse) => {
|
||||
try {
|
||||
await disableJob(record.id);
|
||||
toast({
|
||||
title: '禁用成功',
|
||||
description: `任务 "${record.jobName}" 已禁用`,
|
||||
});
|
||||
loadData();
|
||||
} catch (error) {
|
||||
console.error('禁用失败:', error);
|
||||
toast({
|
||||
variant: 'destructive',
|
||||
title: '禁用失败',
|
||||
description: error instanceof Error ? error.message : '未知错误',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 启用(解除禁用)任务
|
||||
const handleEnable = async (record: ScheduleJobResponse) => {
|
||||
try {
|
||||
await enableJob(record.id);
|
||||
toast({
|
||||
title: '启用成功',
|
||||
description: `任务 "${record.jobName}" 已启用`,
|
||||
});
|
||||
loadData();
|
||||
} catch (error) {
|
||||
console.error('启用失败:', error);
|
||||
toast({
|
||||
variant: 'destructive',
|
||||
title: '启用失败',
|
||||
description: error instanceof Error ? error.message : '未知错误',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 查看日志
|
||||
const handleViewLog = (record: ScheduleJobResponse) => {
|
||||
setSelectedJob(record);
|
||||
@ -457,18 +495,12 @@ const ScheduleJobList: React.FC = () => {
|
||||
<span className="text-muted-foreground">-</span>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell sticky width="240px">
|
||||
<TableCell sticky width="280px">
|
||||
<div className="flex items-center gap-1">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
onClick={() => handleTrigger(record)}
|
||||
title="立即触发"
|
||||
>
|
||||
<PlayCircle className="h-4 w-4" />
|
||||
</Button>
|
||||
{/* ENABLED 按钮控制 */}
|
||||
{record.status === 'ENABLED' && (
|
||||
<>
|
||||
{/* 暂停 */}
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
@ -478,8 +510,32 @@ const ScheduleJobList: React.FC = () => {
|
||||
>
|
||||
<Pause className="h-4 w-4"/>
|
||||
</Button>
|
||||
{/* 禁用 */}
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7 text-orange-600 hover:text-orange-700 hover:bg-orange-50 dark:text-orange-500 dark:hover:bg-orange-950/20"
|
||||
onClick={() => handleDisable(record)}
|
||||
title="禁用"
|
||||
>
|
||||
<Ban className="h-4 w-4"/>
|
||||
</Button>
|
||||
{/* 立即执行 */}
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7 text-green-600 hover:text-green-700 hover:bg-green-50 dark:text-green-500 dark:hover:bg-green-950/20"
|
||||
onClick={() => handleTrigger(record)}
|
||||
title="立即执行"
|
||||
>
|
||||
<PlayCircle className="h-4 w-4"/>
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
{/* PAUSED 按钮控制 */}
|
||||
{record.status === 'PAUSED' && (
|
||||
<>
|
||||
{/* 恢复 */}
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
@ -489,7 +545,40 @@ const ScheduleJobList: React.FC = () => {
|
||||
>
|
||||
<Play className="h-4 w-4"/>
|
||||
</Button>
|
||||
{/* 禁用 */}
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7 text-orange-600 hover:text-orange-700 hover:bg-orange-50 dark:text-orange-500 dark:hover:bg-orange-950/20"
|
||||
onClick={() => handleDisable(record)}
|
||||
title="禁用"
|
||||
>
|
||||
<Ban className="h-4 w-4"/>
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
{/* DISABLED 按钮控制 */}
|
||||
{record.status === 'DISABLED' && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7 text-blue-600 hover:text-blue-700 hover:bg-blue-50 dark:text-blue-400 dark:hover:bg-blue-950/20"
|
||||
onClick={() => handleEnable(record)}
|
||||
title="启用"
|
||||
>
|
||||
<CheckCircle2 className="h-4 w-4"/>
|
||||
</Button>
|
||||
)}
|
||||
{/* 删除按钮 所有状态显示 */}
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7 text-destructive hover:text-destructive"
|
||||
onClick={() => handleDeleteClick(record)}
|
||||
title="删除"
|
||||
>
|
||||
<Trash2 className="h-4 w-4"/>
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
@ -508,15 +597,6 @@ const ScheduleJobList: React.FC = () => {
|
||||
>
|
||||
<Edit className="h-4 w-4"/>
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7 text-destructive hover:text-destructive"
|
||||
onClick={() => handleDeleteClick(record)}
|
||||
title="删除"
|
||||
>
|
||||
<Trash2 className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
|
||||
@ -122,6 +122,17 @@ export const stopJob = (id: number) =>
|
||||
export const triggerJob = (id: number) =>
|
||||
request.post<void>(`${SCHEDULE_JOB_URL}/${id}/trigger`);
|
||||
|
||||
/**
|
||||
* 禁用任务
|
||||
*/
|
||||
export const disableJob = (id: number) =>
|
||||
request.post<void>(`${SCHEDULE_JOB_URL}/${id}/disable`);
|
||||
|
||||
/**
|
||||
* 启用任务(解除禁用)
|
||||
*/
|
||||
export const enableJob = (id: number) => request.post<void>(`${SCHEDULE_JOB_URL}/${id}/enable`);
|
||||
|
||||
/**
|
||||
* 更新Cron表达式
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user