mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-20 02:58:53 +00:00
3ca5afd49f
* feat: update dependencies and enhance UI components in Dokploy - Updated various package versions in pnpm-lock.yaml to improve compatibility and performance, including React and Tailwind CSS. - Modified components.json to change the styling to "radix-nova" and added new properties for icon library and menu color. - Refactored multiple components to use updated class names for better styling consistency and responsiveness. - Removed unused Radix UI components from package.json to streamline dependencies. - Adjusted layout and styling in several dashboard components for improved user experience and visual appeal. - Enhanced tooltip and form item components for better accessibility and usability. * refactor: enhance UI components in HandleCertificate and SidebarLogo - Updated the HandleCertificate component to improve dialog content height and textarea styling for better usability. - Adjusted the SidebarLogo component layout to enhance alignment and spacing, ensuring a more consistent appearance across the sidebar. - Implemented responsive design adjustments to textarea elements, preventing overflow and improving user experience. * refactor: improve UI consistency and styling across dashboard components - Updated Card components in ShowDeployments, ShowSchedules, and ShowVolumeBackups to remove unnecessary border styles for a cleaner look. - Enhanced TabsList components in ShowProviderForm and ShowProviderFormCompose by adding a variant for improved visual distinction. - Adjusted spacing in AdvancedEnvironmentSelector for better layout and readability. - Removed redundant border classes in Service component for a more streamlined design. * [autofix.ci] apply automated fixes * chore: update package dependencies and refactor email rendering - Upgraded React and React DOM to version 19.2.7 across multiple packages for improved performance and compatibility. - Updated TSX to version 4.22.4 in various package.json files. - Refactored email rendering from `renderAsync` to `render` in notification utilities and email templates for consistency. - Adjusted Tailwind configuration usage in email templates to utilize a centralized configuration file. These changes enhance the overall stability and maintainability of the codebase. * refactor: update badge variants across dashboard components - Changed badge variant from "outline-solid" to "outline" in multiple components including columns, show-domains, and various deployment tables for consistency in styling. - Updated button variants in billing and project templates to align with the new badge styling. - Enhanced input components to support password generation and error messaging, improving user experience. These changes streamline the UI and ensure a cohesive design across the application. * refactor: clean up calendar component imports and structure - Removed redundant imports of icons from lucide-react and streamlined the import statements for better readability. - Adjusted the placement of type imports to enhance code organization. These changes improve the maintainability and clarity of the calendar component. * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
252 lines
8.1 KiB
TypeScript
252 lines
8.1 KiB
TypeScript
import {
|
|
ClipboardList,
|
|
Clock,
|
|
Loader2,
|
|
Play,
|
|
Terminal,
|
|
Trash2,
|
|
} from "lucide-react";
|
|
import { useState } from "react";
|
|
import { toast } from "sonner";
|
|
import { DialogAction } from "@/components/shared/dialog-action";
|
|
import { Badge } from "@/components/ui/badge";
|
|
import { Button } from "@/components/ui/button";
|
|
import {
|
|
Card,
|
|
CardContent,
|
|
CardDescription,
|
|
CardHeader,
|
|
CardTitle,
|
|
} from "@/components/ui/card";
|
|
import {
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipProvider,
|
|
TooltipTrigger,
|
|
} from "@/components/ui/tooltip";
|
|
import { api } from "@/utils/api";
|
|
import { ShowDeploymentsModal } from "../deployments/show-deployments-modal";
|
|
import { HandleSchedules } from "./handle-schedules";
|
|
|
|
interface Props {
|
|
id: string;
|
|
scheduleType?: "application" | "compose" | "server" | "dokploy-server";
|
|
}
|
|
|
|
export const ShowSchedules = ({ id, scheduleType = "application" }: Props) => {
|
|
const [runningSchedules, setRunningSchedules] = useState<Set<string>>(
|
|
new Set(),
|
|
);
|
|
const {
|
|
data: schedules,
|
|
isLoading: isLoadingSchedules,
|
|
refetch: refetchSchedules,
|
|
} = api.schedule.list.useQuery(
|
|
{
|
|
id: id || "",
|
|
scheduleType,
|
|
},
|
|
{
|
|
enabled: !!id,
|
|
},
|
|
);
|
|
const utils = api.useUtils();
|
|
const { mutateAsync: deleteSchedule, isPending: isDeleting } =
|
|
api.schedule.delete.useMutation();
|
|
const { mutateAsync: runManually } = api.schedule.runManually.useMutation();
|
|
|
|
const handleRunManually = async (scheduleId: string) => {
|
|
setRunningSchedules((prev) => new Set(prev).add(scheduleId));
|
|
try {
|
|
await runManually({ scheduleId });
|
|
toast.success("Schedule run successfully");
|
|
await refetchSchedules();
|
|
} catch {
|
|
toast.error("Error running schedule");
|
|
} finally {
|
|
setRunningSchedules((prev) => {
|
|
const newSet = new Set(prev);
|
|
newSet.delete(scheduleId);
|
|
return newSet;
|
|
});
|
|
}
|
|
};
|
|
|
|
return (
|
|
<Card className=" px-6 shadow-none bg-transparent h-full min-h-[50vh]">
|
|
<CardHeader className="px-0">
|
|
<div className="flex justify-between items-center gap-y-2 flex-wrap">
|
|
<div className="flex flex-col gap-2">
|
|
<CardTitle className="text-xl font-bold flex items-center gap-2">
|
|
Scheduled Tasks
|
|
</CardTitle>
|
|
<CardDescription>
|
|
Schedule tasks to run automatically at specified intervals.
|
|
</CardDescription>
|
|
</div>
|
|
{schedules && schedules.length > 0 && (
|
|
<HandleSchedules id={id} scheduleType={scheduleType} />
|
|
)}
|
|
</div>
|
|
</CardHeader>
|
|
<CardContent className="px-0">
|
|
{isLoadingSchedules ? (
|
|
<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...
|
|
</span>
|
|
</div>
|
|
) : schedules && schedules.length > 0 ? (
|
|
<div className="grid xl:grid-cols-2 gap-4 grid-cols-1 h-full">
|
|
{schedules.map((schedule) => {
|
|
const serverId =
|
|
schedule.serverId ||
|
|
schedule.application?.serverId ||
|
|
schedule.compose?.serverId;
|
|
return (
|
|
<div
|
|
key={schedule.scheduleId}
|
|
className="flex flex-col sm:flex-row sm:items-center flex-wrap sm:flex-nowrap gap-y-2 justify-between rounded-lg border p-3 transition-colors bg-muted/50 w-full"
|
|
>
|
|
<div className="flex items-start gap-3 w-full sm:w-auto">
|
|
<div className="flex shrink-0 h-9 w-9 items-center justify-center rounded-full bg-primary/5">
|
|
<Clock className="size-4 text-primary/70" />
|
|
</div>
|
|
<div className="space-y-1.5 w-full sm:w-auto">
|
|
<div className="flex items-center gap-2 flex-wrap">
|
|
<h3 className="text-sm font-medium leading-none wrap-anywhere line-clamp-3">
|
|
{schedule.name}
|
|
</h3>
|
|
<Badge
|
|
variant={schedule.enabled ? "default" : "secondary"}
|
|
className="text-[10px] px-1 py-0"
|
|
>
|
|
{schedule.enabled ? "Enabled" : "Disabled"}
|
|
</Badge>
|
|
</div>
|
|
{schedule.description && (
|
|
<p className="text-xs text-muted-foreground/70 wrap-anywhere line-clamp-2">
|
|
{schedule.description}
|
|
</p>
|
|
)}
|
|
<div className="flex items-center gap-2 text-sm text-muted-foreground flex-wrap">
|
|
<Badge
|
|
variant="outline"
|
|
className="font-mono text-[10px] bg-transparent"
|
|
>
|
|
Cron: {schedule.cronExpression}
|
|
</Badge>
|
|
{schedule.scheduleType !== "server" &&
|
|
schedule.scheduleType !== "dokploy-server" && (
|
|
<>
|
|
<span className="text-xs text-muted-foreground/50">
|
|
•
|
|
</span>
|
|
<Badge
|
|
variant="outline"
|
|
className="font-mono text-[10px] bg-transparent"
|
|
>
|
|
{schedule.shellType}
|
|
</Badge>
|
|
</>
|
|
)}
|
|
</div>
|
|
{schedule.command && (
|
|
<div className="flex items-start gap-2 max-w-full">
|
|
<Terminal className="size-3.5 text-muted-foreground/70 shrink-0 mt-0.5" />
|
|
<code className="font-mono text-[10px] text-muted-foreground/70 break-all max-w-[calc(100%-20px)]">
|
|
{schedule.command}
|
|
</code>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
<div className="flex items-center gap-0.5 md:gap-1.5">
|
|
<ShowDeploymentsModal
|
|
id={schedule.scheduleId}
|
|
type="schedule"
|
|
serverId={serverId || undefined}
|
|
>
|
|
<Button variant="ghost" size="icon">
|
|
<ClipboardList className="size-4 transition-colors" />
|
|
</Button>
|
|
</ShowDeploymentsModal>
|
|
<TooltipProvider delayDuration={0}>
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<Button
|
|
type="button"
|
|
variant="ghost"
|
|
size="icon"
|
|
disabled={runningSchedules.has(schedule.scheduleId)}
|
|
onClick={() =>
|
|
handleRunManually(schedule.scheduleId)
|
|
}
|
|
>
|
|
{runningSchedules.has(schedule.scheduleId) ? (
|
|
<Loader2 className="size-4 animate-spin" />
|
|
) : (
|
|
<Play className="size-4 transition-colors" />
|
|
)}
|
|
</Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent>Run Manual Schedule</TooltipContent>
|
|
</Tooltip>
|
|
</TooltipProvider>
|
|
<HandleSchedules
|
|
scheduleId={schedule.scheduleId}
|
|
id={id}
|
|
scheduleType={scheduleType}
|
|
/>
|
|
<DialogAction
|
|
title="Delete Schedule"
|
|
description="Are you sure you want to delete this schedule?"
|
|
type="destructive"
|
|
onClick={async () => {
|
|
await deleteSchedule({
|
|
scheduleId: schedule.scheduleId,
|
|
})
|
|
.then(() => {
|
|
utils.schedule.list.invalidate({
|
|
id,
|
|
scheduleType,
|
|
});
|
|
toast.success("Schedule deleted successfully");
|
|
})
|
|
.catch(() => {
|
|
toast.error("Error deleting schedule");
|
|
});
|
|
}}
|
|
>
|
|
<Button
|
|
variant="ghost"
|
|
size="icon"
|
|
className="group hover:bg-red-500/10"
|
|
disabled={isDeleting}
|
|
>
|
|
<Trash2 className="size-4 text-primary group-hover:text-red-500" />
|
|
</Button>
|
|
</DialogAction>
|
|
</div>
|
|
</div>
|
|
);
|
|
})}
|
|
</div>
|
|
) : (
|
|
<div className="flex flex-col gap-2 items-center justify-center py-12 rounded-lg">
|
|
<Clock className="size-8 mb-4 text-muted-foreground" />
|
|
<p className="text-lg font-medium text-muted-foreground">
|
|
No scheduled tasks
|
|
</p>
|
|
<p className="text-sm text-muted-foreground mt-1">
|
|
Create your first scheduled task to automate your workflows
|
|
</p>
|
|
<HandleSchedules id={id} scheduleType={scheduleType} />
|
|
</div>
|
|
)}
|
|
</CardContent>
|
|
</Card>
|
|
);
|
|
};
|