From 30727952327691a1f716703176fa2cae98491445 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Fri, 2 May 2025 23:05:39 -0600 Subject: [PATCH] Enhance schedule initialization and management features - Introduced a new `initSchedules` function to initialize and schedule active schedules from the database, improving the management of scheduled tasks. - Updated the `createSchedule` and `updateSchedule` functions to handle scheduling jobs based on the enabled status of schedules, ensuring proper job management. - Refactored the `removeScheduleJob` utility to cancel existing scheduled jobs, enhancing the flexibility of schedule updates. - Improved the `HandleSchedules` and `ShowSchedules` components by removing unused imports and enhancing the user interface for better clarity and usability. --- .../schedules/handle-schedules.tsx | 9 ++--- .../application/schedules/show-schedules.tsx | 4 +-- apps/dokploy/server/server.ts | 2 ++ packages/server/src/index.ts | 1 + packages/server/src/services/schedule.ts | 36 +++++++++++++++---- packages/server/src/utils/schedules/index.ts | 28 +++++++++++++++ packages/server/src/utils/schedules/utils.ts | 7 +++- 7 files changed, 71 insertions(+), 16 deletions(-) create mode 100644 packages/server/src/utils/schedules/index.ts diff --git a/apps/dokploy/components/dashboard/application/schedules/handle-schedules.tsx b/apps/dokploy/components/dashboard/application/schedules/handle-schedules.tsx index f99eee86b..c133ae4d9 100644 --- a/apps/dokploy/components/dashboard/application/schedules/handle-schedules.tsx +++ b/apps/dokploy/components/dashboard/application/schedules/handle-schedules.tsx @@ -14,8 +14,6 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { useForm } from "react-hook-form"; import { z } from "zod"; import { - Clock, - Terminal, Info, PlusCircle, PenBoxIcon, @@ -49,7 +47,8 @@ import type { CacheType } from "../../compose/domains/add-domain"; import { AlertBlock } from "@/components/shared/alert-block"; import { CodeEditor } from "@/components/shared/code-editor"; import { cn } from "@/lib/utils"; -const commonCronExpressions = [ + +export const commonCronExpressions = [ { label: "Every minute", value: "* * * * *" }, { label: "Every hour", value: "0 * * * *" }, { label: "Every day at midnight", value: "0 0 * * *" }, @@ -361,7 +360,6 @@ export const HandleSchedules = ({ id, scheduleId, scheduleType }: Props) => { render={({ field }) => ( - Task Name @@ -381,7 +379,6 @@ export const HandleSchedules = ({ id, scheduleId, scheduleType }: Props) => { render={({ field }) => ( - Schedule @@ -444,7 +441,6 @@ export const HandleSchedules = ({ id, scheduleId, scheduleType }: Props) => { render={({ field }) => ( - Shell Type