From afe9a29a3fa7046011cec38a69920eecaa7cc576 Mon Sep 17 00:00:00 2001 From: stijndeleeuw Date: Mon, 22 Apr 2024 10:37:36 +0200 Subject: [PATCH] Added current date to the query parameter if there is no current scheduleTime provided fixes #97 --- db-scheduler-ui-frontend/src/services/runTask.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/db-scheduler-ui-frontend/src/services/runTask.ts b/db-scheduler-ui-frontend/src/services/runTask.ts index 0608a738..579af15e 100644 --- a/db-scheduler-ui-frontend/src/services/runTask.ts +++ b/db-scheduler-ui-frontend/src/services/runTask.ts @@ -16,12 +16,16 @@ const API_BASE_URL: string = window.location.origin + '/db-scheduler-api'; const runTask = async (id: string, name: string, scheduleTime?:Date) => { - + const queryParams = new URLSearchParams(); queryParams.append('id', id); queryParams.append('name', name); - scheduleTime&&queryParams.append('scheduleTime', scheduleTime.toISOString()); + if (scheduleTime) { + queryParams.append('scheduleTime', scheduleTime.toISOString()); + } else { + queryParams.append('scheduleTime', new Date().toISOString()); + } const response = await fetch( `${API_BASE_URL}/tasks/rerun?${queryParams}`,