mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-26 14:23:48 +00:00
- 重构工作流模块目录结构,迁移代码文件 - 修复类型断言空值安全问题,添加 ! 操作符 - 优化样式类名,替换 flex-cc 为标准 flex 工具类 - 更新路由标签简化文案,移除冗余注释 - 调整 ruff 配置,放宽行长度限制 - 更新 README 与多语言文案,优化项目描述 - 修复表单、图表组件的类型与样式问题 - 简化搜索表单、数据卡片的布局代码
154 lines
3.0 KiB
TypeScript
154 lines
3.0 KiB
TypeScript
import { request } from "@utils";
|
|
|
|
const API_PATH = "/task/cronjob/job";
|
|
|
|
const JobAPI = {
|
|
getSchedulerStatus() {
|
|
return request<ApiResponse<SchedulerStatus>>({
|
|
url: `${API_PATH}/scheduler/status`,
|
|
method: "get",
|
|
});
|
|
},
|
|
|
|
getSchedulerJobs() {
|
|
return request<ApiResponse<SchedulerJob[]>>({
|
|
url: `${API_PATH}/scheduler/jobs`,
|
|
method: "get",
|
|
});
|
|
},
|
|
|
|
startScheduler() {
|
|
return request<ApiResponse>({
|
|
url: `${API_PATH}/scheduler/start`,
|
|
method: "post",
|
|
});
|
|
},
|
|
|
|
pauseScheduler() {
|
|
return request<ApiResponse>({
|
|
url: `${API_PATH}/scheduler/pause`,
|
|
method: "post",
|
|
});
|
|
},
|
|
|
|
resumeScheduler() {
|
|
return request<ApiResponse>({
|
|
url: `${API_PATH}/scheduler/resume`,
|
|
method: "post",
|
|
});
|
|
},
|
|
|
|
shutdownScheduler() {
|
|
return request<ApiResponse>({
|
|
url: `${API_PATH}/scheduler/shutdown`,
|
|
method: "post",
|
|
});
|
|
},
|
|
|
|
clearAllJobs() {
|
|
return request<ApiResponse>({
|
|
url: `${API_PATH}/scheduler/jobs/clear`,
|
|
method: "delete",
|
|
});
|
|
},
|
|
|
|
getSchedulerConsole() {
|
|
return request<ApiResponse<string>>({
|
|
url: `${API_PATH}/scheduler/console`,
|
|
method: "get",
|
|
});
|
|
},
|
|
|
|
syncJobsToDb() {
|
|
return request<ApiResponse<number>>({
|
|
url: `${API_PATH}/scheduler/sync`,
|
|
method: "post",
|
|
});
|
|
},
|
|
|
|
pauseJob(jobId: string) {
|
|
return request<ApiResponse>({
|
|
url: `${API_PATH}/task/pause/${jobId}`,
|
|
method: "post",
|
|
});
|
|
},
|
|
|
|
resumeJob(jobId: string) {
|
|
return request<ApiResponse>({
|
|
url: `${API_PATH}/task/resume/${jobId}`,
|
|
method: "post",
|
|
});
|
|
},
|
|
|
|
runJobNow(jobId: string) {
|
|
return request<ApiResponse>({
|
|
url: `${API_PATH}/task/run/${jobId}`,
|
|
method: "post",
|
|
});
|
|
},
|
|
|
|
removeJob(jobId: string) {
|
|
return request<ApiResponse>({
|
|
url: `${API_PATH}/task/remove/${jobId}`,
|
|
method: "delete",
|
|
});
|
|
},
|
|
|
|
getJobLogList(query: JobLogPageQuery) {
|
|
return request<ApiResponse<PageResult<JobLogTable>>>({
|
|
url: `${API_PATH}/log/list`,
|
|
method: "get",
|
|
params: query,
|
|
});
|
|
},
|
|
|
|
getJobLogDetail(id: number) {
|
|
return request<ApiResponse<JobLogTable>>({
|
|
url: `${API_PATH}/log/detail/${id}`,
|
|
method: "get",
|
|
});
|
|
},
|
|
|
|
deleteJobLog(ids: number[]) {
|
|
return request<ApiResponse>({
|
|
url: `${API_PATH}/log/delete`,
|
|
method: "delete",
|
|
data: ids,
|
|
});
|
|
},
|
|
};
|
|
|
|
export default JobAPI;
|
|
|
|
export interface SchedulerStatus {
|
|
status: string;
|
|
is_running: boolean;
|
|
job_count: number;
|
|
}
|
|
|
|
export interface SchedulerJob {
|
|
id: string;
|
|
name: string;
|
|
trigger: string;
|
|
next_run_time?: string;
|
|
status: number;
|
|
}
|
|
|
|
export interface JobLogPageQuery extends PageQuery, UserByQueryParams {
|
|
job_id?: string;
|
|
job_name?: string;
|
|
trigger_type?: string;
|
|
}
|
|
|
|
export interface JobLogTable extends BaseType {
|
|
job_id: string;
|
|
job_name?: string;
|
|
trigger_type?: string;
|
|
next_run_time?: string;
|
|
job_state?: string;
|
|
result?: string;
|
|
error?: string;
|
|
status?: number;
|
|
description?: string;
|
|
}
|