From ace071e974e5b4d52fd51d494eefc729cb49051a Mon Sep 17 00:00:00 2001 From: proddy Date: Mon, 25 May 2026 12:28:42 +0200 Subject: [PATCH] Scheduler with type "Immediate", click Execute does not run the command Fixes #3092 --- interface/src/app/main/Scheduler.tsx | 10 +- interface/src/app/main/SchedulerDialog.tsx | 20 ++- interface/src/app/main/types.ts | 4 +- interface/src/app/main/validators.ts | 6 +- mock-api/restServer.ts | 45 ++++--- src/web/WebSchedulerService.cpp | 144 +++------------------ src/web/WebSchedulerService.h | 2 + src/web/WebStatusService.cpp | 2 + 8 files changed, 78 insertions(+), 155 deletions(-) diff --git a/interface/src/app/main/Scheduler.tsx b/interface/src/app/main/Scheduler.tsx index d85183a12..bf50067dc 100644 --- a/interface/src/app/main/Scheduler.tsx +++ b/interface/src/app/main/Scheduler.tsx @@ -297,10 +297,12 @@ const Scheduler = () => { {tableList.map((si: ScheduleItem) => ( editScheduleItem(si)}> - + {si.flags !== ScheduleFlag.SCHEDULE_IMMEDIATE && ( + + )} diff --git a/interface/src/app/main/SchedulerDialog.tsx b/interface/src/app/main/SchedulerDialog.tsx index d68d9b727..c3b52874c 100644 --- a/interface/src/app/main/SchedulerDialog.tsx +++ b/interface/src/app/main/SchedulerDialog.tsx @@ -1,4 +1,5 @@ import { useEffect, useState } from 'react'; +import { toast } from 'react-toastify'; import AddIcon from '@mui/icons-material/Add'; import CancelIcon from '@mui/icons-material/Cancel'; @@ -20,7 +21,9 @@ import { Typography } from '@mui/material'; +import { callAction } from '@/api/app'; import { dialogStyle } from 'CustomTheme'; +import { useRequest } from 'alova/client'; import type Schema from 'async-validator'; import type { ValidateFieldsError } from 'async-validator'; import { BlockFormControlLabel, ValidatedTextField } from 'components'; @@ -128,8 +131,15 @@ const SchedulerDialog = ({ await handleSave(editItem); }; - const saveandactivate = async () => { - await handleSave({ ...editItem, active: true }); + const { send: executeSchedule } = useRequest( + (id: string) => callAction({ action: 'executeSchedule', param: id }), + { immediate: false } + ).onError((error) => { + toast.error(String(error.error?.message || 'An error occurred')); + }); + + const execute = async () => { + await executeSchedule(editItem.name); }; const remove = () => { @@ -351,7 +361,7 @@ const SchedulerDialog = ({ {creating ? LL.ADD(0) : LL.UPDATE()} - {isImmediateSchedule && editItem.cmd !== '' && ( + {isImmediateSchedule && !creating && editItem.cmd !== '' && (