1.排程管理功能更新,支持数据源配置以及自定义查询条件测试

2.应用管理增加Dify应用类型,支持不同类型下的连通性测试
This commit is contained in:
hugo committed 2026-05-20 17:21:46 +08:00
1 parent 72642b981e
commit 6ada6810c5
18 files changed
+2185 -535

No files matched your search

+66 -3
View File
@@ -11,6 +11,7 @@ export interface ScheduleTask {
wait_seconds: number;
dify_agent_id?: number | null;
platform_api_path?: string | null;
data_source_type?: string;
notify_user_ids_json: number[];
notify_enabled: boolean;
enabled: boolean;
@@ -38,6 +39,7 @@ export interface ScheduleRun {
api_request_json?: Record<string, any> | null;
api_response_json?: Record<string, any> | null;
response_summary_json?: Record<string, any> | null;
step_logs?: StepLog[] | null;
error_message?: string | null;
excel_file_name?: string | null;
excel_file_size?: number | null;
@@ -47,25 +49,86 @@ export interface ScheduleRun {
created_at?: string | null;
}
export interface StepLog {
step: string;
status: string;
started_at?: string;
finished_at?: string;
duration_ms?: number;
row_id?: string;
detail?: Record<string, any>;
}
async function getJson<T>(url: string): Promise<T> {
const res = await fetch(url, { headers: getAuthHeaders() });
if (!res.ok) throw new Error((await res.json().catch(() => ({})))?.error || 'Request failed');
return (await res.json()) as T;
}
export const listAdminSchedules = () => getJson<ScheduleTask[]>('/api/admin/schedules');
export const createAdminSchedule = (payload: Partial<ScheduleTask>) =>
export const listAdminSchedules = () =>
getJson<ScheduleTask[]>('/api/admin/schedules');
export const getAdminScheduleTaskConfig = (taskId: number) =>
getJson<{ data_source_type: string; config: Record<string, any> | null }>(`/api/admin/schedule-config/${taskId}`);
export const updateAdminScheduleTaskConfig = (taskId: number, payload: Record<string, any>) =>
fetch(`/api/admin/schedule-config/${taskId}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json', ...getAuthHeaders() },
body: JSON.stringify(payload),
}).then(r => {
if (!r.ok) throw new Error('Update config failed');
return r.json();
});
export const testAdminScheduleSql = (taskId: number, payload: { fetch_where_conditions?: string; fetch_order_by?: string; limit?: number }) =>
fetch(`/api/admin/schedule-config/${taskId}/test-sql`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', ...getAuthHeaders() },
body: JSON.stringify(payload),
}).then(r => {
if (!r.ok) return r.json().then(e => { throw new Error(e.error || 'Test failed'); });
return r.json();
});
export interface TestScheduleRunResult {
run_no: string;
sql: string;
limit: number;
total_count: number;
success_count: number;
failed_count: number;
skipped_count: number;
details: Record<string, any>[];
errors: string[];
step_logs: StepLog[];
dify_agent_id: number | null;
}
export const testAdminScheduleRun = (taskId: number, payload: { fetch_where_conditions?: string; fetch_order_by?: string; limit?: number }) =>
fetch(`/api/admin/schedule-config/${taskId}/test-run`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', ...getAuthHeaders() },
body: JSON.stringify(payload),
}).then(r => {
if (!r.ok) return r.json().then(e => { throw new Error(e.error || 'Test run failed'); });
return r.json() as Promise<TestScheduleRunResult>;
});
export const createAdminSchedule = (payload: Partial<ScheduleTask> & { config?: Record<string, any> }) =>
fetch('/api/admin/schedules', {
method: 'POST',
headers: { 'Content-Type': 'application/json', ...getAuthHeaders() },
body: JSON.stringify(payload),
});
export const updateAdminSchedule = (id: number, payload: Partial<ScheduleTask>) =>
export const updateAdminSchedule = (id: number, payload: Partial<ScheduleTask> & { config?: Record<string, any> }) =>
fetch(`/api/admin/schedules/${id}`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json', ...getAuthHeaders() },
body: JSON.stringify(payload),
});
export const deleteAdminSchedule = (id: number) =>
fetch(`/api/admin/schedules/${id}`, {
method: 'DELETE',