Merge branch 'hugo' into dev
This commit is contained in:
commit
40b25ec988
21 files changed
+2185
-593
No files matched your search
@@ -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',
|
||||
|
||||
+941
-158
File diff suppressed because it is too large.
Load diff
@@ -1002,8 +1002,25 @@ const workspaceScheduleRuns = ref<ScheduleRun[]>([]);
|
||||
const workspaceScheduleLoading = ref(false);
|
||||
const wsScheduleStatusFilter = ref('all');
|
||||
const wsScheduleNameFilter = ref('');
|
||||
const wsScheduleStartedAfter = ref('');
|
||||
const wsScheduleStartedBefore = ref('');
|
||||
const toDateTimeLocalValue = (date: Date) => {
|
||||
const pad = (n: number) => String(n).padStart(2, '0');
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
||||
};
|
||||
|
||||
const todayStartLocal = () => {
|
||||
const d = new Date();
|
||||
d.setHours(0, 0, 0, 0);
|
||||
return toDateTimeLocalValue(d);
|
||||
};
|
||||
|
||||
const todayEndLocal = () => {
|
||||
const d = new Date();
|
||||
d.setHours(23, 59, 59, 0);
|
||||
return toDateTimeLocalValue(d);
|
||||
};
|
||||
|
||||
const wsScheduleStartedAfter = ref(todayStartLocal());
|
||||
const wsScheduleStartedBefore = ref(todayEndLocal());
|
||||
|
||||
const wsScheduleStatusOptions = [
|
||||
{ value: 'all', label: '全部状态' },
|
||||
@@ -1032,18 +1049,6 @@ const formatDateTime = (iso?: string | null) => {
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
|
||||
};
|
||||
|
||||
const todayStart = () => {
|
||||
const d = new Date();
|
||||
d.setHours(0, 0, 0, 0);
|
||||
return d.toISOString();
|
||||
};
|
||||
|
||||
const todayEnd = () => {
|
||||
const d = new Date();
|
||||
d.setHours(23, 59, 59, 0);
|
||||
return d.toISOString();
|
||||
};
|
||||
|
||||
const loadWorkspaceScheduleRuns = async () => {
|
||||
workspaceScheduleLoading.value = true;
|
||||
try {
|
||||
@@ -1063,8 +1068,8 @@ const loadWorkspaceScheduleRuns = async () => {
|
||||
const resetWsScheduleFilters = () => {
|
||||
wsScheduleStatusFilter.value = 'all';
|
||||
wsScheduleNameFilter.value = '';
|
||||
wsScheduleStartedAfter.value = todayStart().slice(0, 16);
|
||||
wsScheduleStartedBefore.value = todayEnd().slice(0, 16);
|
||||
wsScheduleStartedAfter.value = todayStartLocal();
|
||||
wsScheduleStartedBefore.value = todayEndLocal();
|
||||
loadWorkspaceScheduleRuns();
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user