mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
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.
This commit is contained in:
@@ -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 }) => (
|
||||
<FormItem>
|
||||
<FormLabel className="flex items-center gap-2">
|
||||
<Clock className="w-4 h-4" />
|
||||
Task Name
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
@@ -381,7 +379,6 @@ export const HandleSchedules = ({ id, scheduleId, scheduleType }: Props) => {
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel className="flex items-center gap-2">
|
||||
<Clock className="w-4 h-4" />
|
||||
Schedule
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
@@ -444,7 +441,6 @@ export const HandleSchedules = ({ id, scheduleId, scheduleType }: Props) => {
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel className="flex items-center gap-2">
|
||||
<Terminal className="w-4 h-4" />
|
||||
Shell Type
|
||||
</FormLabel>
|
||||
<Select
|
||||
@@ -474,7 +470,6 @@ export const HandleSchedules = ({ id, scheduleId, scheduleType }: Props) => {
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel className="flex items-center gap-2">
|
||||
<Terminal className="w-4 h-4" />
|
||||
Command
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
|
||||
@@ -75,7 +75,7 @@ export const ShowSchedules = ({ id, scheduleType = "application" }: Props) => {
|
||||
</CardHeader>
|
||||
<CardContent className="px-0">
|
||||
{isLoadingSchedules ? (
|
||||
<div className="flex gap-4 w-full items-center justify-center text-center mx-auto">
|
||||
<div className="flex gap-4 w-full items-center justify-center text-center mx-auto min-h-[45vh]">
|
||||
<Loader2 className="size-4 text-muted-foreground/70 transition-colors animate-spin self-center" />
|
||||
<span className="text-sm text-muted-foreground/70">
|
||||
Loading scheduled tasks...
|
||||
@@ -146,7 +146,7 @@ export const ShowSchedules = ({ id, scheduleType = "application" }: Props) => {
|
||||
<div className="flex items-center gap-1.5">
|
||||
<ShowSchedulesLogs
|
||||
deployments={deployments || []}
|
||||
serverId={serverId}
|
||||
serverId={serverId || undefined}
|
||||
>
|
||||
<Button variant="ghost" size="icon">
|
||||
<ClipboardList className="size-4 transition-colors " />
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
createDefaultServerTraefikConfig,
|
||||
createDefaultTraefikConfig,
|
||||
initCronJobs,
|
||||
initSchedules,
|
||||
initializeNetwork,
|
||||
sendDokployRestartNotifications,
|
||||
setupDirectories,
|
||||
@@ -49,6 +50,7 @@ void app.prepare().then(async () => {
|
||||
createDefaultServerTraefikConfig();
|
||||
await migration();
|
||||
await initCronJobs();
|
||||
await initSchedules();
|
||||
await sendDokployRestartNotifications();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user