From e9b8042ca7f48e7173e51e77f66038dc16b8004e Mon Sep 17 00:00:00 2001 From: oliver Date: Thu, 17 Sep 2026 19:11:50 +0800 Subject: [PATCH] Use schedule checkbox for biz-state; add compare job delete action. Co-authored-by: Cursor --- web/src/i18n/en.ts | 10 +- web/src/i18n/zh.ts | 10 +- web/src/pages/network/BizComparePage.tsx | 29 ++++++ web/src/pages/network/BizStatePage.tsx | 117 ++++++++++++----------- web/src/services/api.ts | 3 + 5 files changed, 109 insertions(+), 60 deletions(-) diff --git a/web/src/i18n/en.ts b/web/src/i18n/en.ts index da8b399..060ccb0 100644 --- a/web/src/i18n/en.ts +++ b/web/src/i18n/en.ts @@ -183,12 +183,16 @@ const en = { colConnect: "Connect", start: "Start schedule", pause: "Pause", + scheduleEnabled: "Enable schedule", + scheduleOn: "Scheduled", + scheduleOff: "Manual", + scheduleHint: "When checked, collect on interval; otherwise only Collect now.", collectNow: "Collect now", delete: "Delete", confirmDelete: "Delete this task and all batches?", deleted: "Deleted", - started: "Schedule started", - paused: "Paused", + started: "Schedule enabled", + paused: "Schedule off (manual only)", collecting: "Collecting", detail: "Details", interval: "Interval", @@ -244,6 +248,7 @@ const en = { templateSaved: "Template saved", templateDeleted: "Template deleted", confirmDeleteTemplate: "Delete this compare template?", + confirmDeleteJob: "Delete this compare job and all runs?", emptyTemplates: "No templates yet. Create one or use built-ins.", templateHint: "A template holds multiple metric sheets. Key: row identity (no separate compare). Interface: port mapping. Compare: value checks after key match. Leave compare empty for presence-only (entry set match).", @@ -296,6 +301,7 @@ const en = { runNow: "Run now", saveJob: "Save config", jobSaved: "Job config saved", + jobDeleted: "Compare job deleted", jobList: "Compare jobs", detail: "Details", edit: "Edit", diff --git a/web/src/i18n/zh.ts b/web/src/i18n/zh.ts index b3afd19..508bb67 100644 --- a/web/src/i18n/zh.ts +++ b/web/src/i18n/zh.ts @@ -183,12 +183,16 @@ const zh = { colConnect: "连通", start: "启动周期", pause: "暂停", + scheduleEnabled: "启用周期调度", + scheduleOn: "周期", + scheduleOff: "手动", + scheduleHint: "勾选后按周期自动采集;不勾选则仅支持「立即采集」。", collectNow: "立即采集", delete: "删除", confirmDelete: "删除该业务监控任务及所有批次?", deleted: "已删除", - started: "已启动周期采集", - paused: "已暂停", + started: "已启用周期采集", + paused: "已关闭周期(仅手动采集)", collecting: "采集中", detail: "详情", interval: "采集周期", @@ -244,6 +248,7 @@ const zh = { templateSaved: "模板已保存", templateDeleted: "模板已删除", confirmDeleteTemplate: "删除该比对模板?", + confirmDeleteJob: "删除该比对任务及全部运行记录?", emptyTemplates: "暂无模板。可新建或使用系统默认。", templateHint: "一个模板可包含多张监控表。Key:对齐前后条目(选中后即为行身份,无需再勾比对);接口:参与端口映射;比对:勾选具体参数做值检查。若不勾任何比对字段,则只校验条目是否一致(存在性)。", @@ -295,6 +300,7 @@ const zh = { runNow: "立即比对", saveJob: "保存配置", jobSaved: "任务配置已保存", + jobDeleted: "比对任务已删除", jobList: "比对任务", detail: "详情", edit: "编辑", diff --git a/web/src/pages/network/BizComparePage.tsx b/web/src/pages/network/BizComparePage.tsx index 5e6a3d3..d334222 100644 --- a/web/src/pages/network/BizComparePage.tsx +++ b/web/src/pages/network/BizComparePage.tsx @@ -9,6 +9,7 @@ import { bizCompareCreateJob, bizCompareCreateMapping, bizCompareCreateTemplate, + bizCompareDeleteJob, bizCompareDeleteTemplate, bizCompareGetRun, bizCompareListJobs, @@ -471,6 +472,21 @@ export function BizComparePage() { } }; + const removeJob = async (id: string) => { + if (!window.confirm(t("bizCompare.confirmDeleteJob"))) return; + setBusy(true); + try { + await bizCompareDeleteJob(id); + if (jobId === id) closeJob(); + showOk(t("bizCompare.jobDeleted")); + await refresh(); + } catch (e) { + showError(formatErr(e)); + } finally { + setBusy(false); + } + }; + const parseMapRows = () => { const rows: { before_if: string; after_if: string }[] = []; for (const line of mapText.split(/\r?\n/)) { @@ -945,6 +961,14 @@ export function BizComparePage() { + @@ -1409,6 +1433,11 @@ export function BizComparePage() { + {jobId ? ( + + ) : null} diff --git a/web/src/pages/network/BizStatePage.tsx b/web/src/pages/network/BizStatePage.tsx index 64f053d..3c59e5e 100644 --- a/web/src/pages/network/BizStatePage.tsx +++ b/web/src/pages/network/BizStatePage.tsx @@ -397,13 +397,12 @@ export function BizStatePage() { } }; - const setStatus = async (status: string) => { - if (!taskId) return; + const setScheduleEnabled = async (id: string, enabled: boolean) => { setBusy(true); try { - await bizStatePatchTask(taskId, { status }); - showOk(status === "running" ? t("bizState.started") : t("bizState.paused")); - await loadTask(taskId); + await bizStatePatchTask(id, { status: enabled ? "running" : "paused" }); + showOk(enabled ? t("bizState.started") : t("bizState.paused")); + if (taskId === id) await loadTask(id); await refreshTasks(); } catch (e) { showError(formatErr(e)); @@ -593,7 +592,7 @@ export function BizStatePage() {
{tasks.length}
-
{t("bizState.start")}
+
{t("bizState.scheduleOn")}
{runningCount}
@@ -613,6 +612,7 @@ export function BizStatePage() { {t("bizState.colNe")} {t("bizState.colSource")} {t("bizState.colInterval")} + {t("bizState.scheduleEnabled")} {t("bizState.colStatus")} {t("bizState.colLast")} {t("bizState.colActions")} @@ -641,12 +641,28 @@ export function BizStatePage() { t("bizState.intervalUnitSeconds"), )} + + +
- {row.status} {row.collect_running ? ( {t("bizState.collecting")} - ) : null} + ) : ( + + {row.status === "running" ? t("bizState.scheduleOn") : t("bizState.scheduleOff")} + + )}
{fmtTime(row.last_collect_ended_at)} @@ -658,47 +674,33 @@ export function BizStatePage() { - {row.status !== "running" ? ( - - ) : ( - - )} + await refreshTasks(); + } catch (e) { + showError(formatErr(e)); + } finally { + setBusy(false); + } + }} + > + {t("bizState.collectNow")} + - -