From 442f051457a506f32eb18d6b3312bcbc05d7eaf9 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Fri, 2 May 2025 03:45:07 -0600 Subject: [PATCH] Add 'enabled' field to schedule management - Introduced a new boolean field `enabled` in the `schedule` schema to indicate the active status of schedules. - Updated the `HandleSchedules` component to include a toggle switch for enabling/disabling schedules. - Enhanced the `ShowSchedules` component to display the status of each schedule with a badge indicating whether it is enabled or disabled. - Added a new API mutation to run schedules manually, ensuring proper error handling for non-existent schedules. - Updated database schema to reflect the new `enabled` field with a default value of true. --- .../schedules/handle-schedules.tsx | 18 + .../application/schedules/show-schedules.tsx | 31 +- apps/dokploy/drizzle/0090_colossal_azazel.sql | 1 + apps/dokploy/drizzle/meta/0090_snapshot.json | 5496 +++++++++++++++++ apps/dokploy/drizzle/meta/_journal.json | 7 + apps/dokploy/server/api/routers/schedule.ts | 18 + packages/server/src/db/schema/schedule.ts | 3 +- 7 files changed, 5567 insertions(+), 7 deletions(-) create mode 100644 apps/dokploy/drizzle/0090_colossal_azazel.sql create mode 100644 apps/dokploy/drizzle/meta/0090_snapshot.json diff --git a/apps/dokploy/components/dashboard/application/schedules/handle-schedules.tsx b/apps/dokploy/components/dashboard/application/schedules/handle-schedules.tsx index adf03c5b7..2799953ea 100644 --- a/apps/dokploy/components/dashboard/application/schedules/handle-schedules.tsx +++ b/apps/dokploy/components/dashboard/application/schedules/handle-schedules.tsx @@ -27,6 +27,7 @@ import { TooltipProvider, TooltipTrigger, } from "@/components/ui/tooltip"; +import { Switch } from "@/components/ui/switch"; const commonCronExpressions = [ { label: "Every minute", value: "* * * * *" }, @@ -42,6 +43,7 @@ const formSchema = z.object({ name: z.string().min(1, "Name is required"), cronExpression: z.string().min(1, "Cron expression is required"), command: z.string().min(1, "Command is required"), + enabled: z.boolean().default(true), }); interface Props { @@ -68,6 +70,7 @@ export const HandleSchedules = ({ name: "", cronExpression: "", command: "", + enabled: true, }, }); @@ -205,6 +208,21 @@ export const HandleSchedules = ({ )} /> + ( + + + + Enabled + + + )} + />