diff --git a/apps/dokploy/components/dashboard/application/schedules/show-schedules.tsx b/apps/dokploy/components/dashboard/application/schedules/show-schedules.tsx index 184b540a..1a908643 100644 --- a/apps/dokploy/components/dashboard/application/schedules/show-schedules.tsx +++ b/apps/dokploy/components/dashboard/application/schedules/show-schedules.tsx @@ -1,15 +1,14 @@ import { Button } from "@/components/ui/button"; -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table"; import { api } from "@/utils/api"; import { HandleSchedules } from "./handle-schedules"; -import { Clock, Play, Terminal, Trash2 } from "lucide-react"; +import { + Clock, + Play, + Terminal, + Trash2, + ClipboardList, + Loader2, +} from "lucide-react"; import { Card, CardContent, @@ -33,9 +32,10 @@ interface Props { } export const ShowSchedules = ({ applicationId }: Props) => { - const { data: schedules } = api.schedule.list.useQuery({ - applicationId, - }); + const { data: schedules, isLoading: isLoadingSchedules } = + api.schedule.list.useQuery({ + applicationId, + }); const utils = api.useUtils(); const { mutateAsync: deleteSchedule, isLoading: isDeleting } = @@ -47,7 +47,7 @@ export const ShowSchedules = ({ applicationId }: Props) => { return ( -
+
Scheduled Tasks @@ -63,138 +63,145 @@ export const ShowSchedules = ({ applicationId }: Props) => {
- {schedules && schedules.length > 0 ? ( -
- - - - Task Name - Schedule - Shell - Command - Status - Actions - - - - {schedules.map((schedule) => { - const application = schedule.application; - const deployments = schedule.deployments; - return ( - - - {schedule.name} - - - - {schedule.cronExpression} - - - - - {schedule.shellType} - - - -
- - - {schedule.command} - -
-
- + {isLoadingSchedules ? ( +
+ + + Loading scheduled tasks... + +
+ ) : schedules && schedules.length > 0 ? ( +
+ {schedules.map((schedule) => { + const application = schedule.application; + const deployments = schedule.deployments; + return ( +
+
+
+ +
+
+
+

+ {schedule.name} +

{schedule.enabled ? "Enabled" : "Disabled"} - - -
- +
+
+ + {schedule.cronExpression} + + + • + + + {schedule.shellType} + +
+
+ + + {schedule.command} + +
+
+
- - - - - - - Run Manual Schedule - - - +
+ + + - - - + + + - -
- - - ); - })} - -
+ + + + Run Manual Schedule + + + + + + { + await deleteSchedule({ + scheduleId: schedule.scheduleId, + }) + .then(() => { + utils.schedule.list.invalidate({ + applicationId, + }); + toast.success("Schedule deleted successfully"); + }) + .catch(() => { + toast.error("Error deleting schedule"); + }); + }} + > + + +
+
+ ); + })}
) : (