feat(dashboard): enhance Traefik actions with health check integration

- Added a new health check mutation for reloading Traefik, improving user feedback during the reload process.
- Updated button states to reflect the execution status of health checks, preventing user actions during ongoing operations.
- Refactored error handling for Traefik reload to provide clearer feedback on failures.
This commit is contained in:
Mauricio Siu
2026-02-07 00:53:32 -06:00
parent ad29bb6ec2
commit a1a348e22d
2 changed files with 31 additions and 15 deletions
@@ -39,12 +39,22 @@ export const ShowTraefikActions = ({ serverId }: Props) => {
isExecuting: isHealthCheckExecuting, isExecuting: isHealthCheckExecuting,
} = useHealthCheckAfterMutation({ } = useHealthCheckAfterMutation({
initialDelay: 5000, initialDelay: 5000,
pollInterval: 4000,
successMessage: "Traefik dashboard updated successfully", successMessage: "Traefik dashboard updated successfully",
onSuccess: () => { onSuccess: () => {
refetchDashboard(); refetchDashboard();
}, },
}); });
const {
execute: executeReloadWithHealthCheck,
isExecuting: isReloadHealthCheckExecuting,
} = useHealthCheckAfterMutation({
initialDelay: 5000,
pollInterval: 4000,
successMessage: "Traefik Reloaded",
});
return ( return (
<DropdownMenu> <DropdownMenu>
<DropdownMenuTrigger <DropdownMenuTrigger
@@ -52,14 +62,16 @@ export const ShowTraefikActions = ({ serverId }: Props) => {
disabled={ disabled={
reloadTraefikIsLoading || reloadTraefikIsLoading ||
toggleDashboardIsLoading || toggleDashboardIsLoading ||
isHealthCheckExecuting isHealthCheckExecuting ||
isReloadHealthCheckExecuting
} }
> >
<Button <Button
isLoading={ isLoading={
reloadTraefikIsLoading || reloadTraefikIsLoading ||
toggleDashboardIsLoading || toggleDashboardIsLoading ||
isHealthCheckExecuting isHealthCheckExecuting ||
isReloadHealthCheckExecuting
} }
variant="outline" variant="outline"
> >
@@ -74,15 +86,19 @@ export const ShowTraefikActions = ({ serverId }: Props) => {
<DropdownMenuGroup> <DropdownMenuGroup>
<DropdownMenuItem <DropdownMenuItem
onClick={async () => { onClick={async () => {
await reloadTraefik({ try {
serverId: serverId, await executeReloadWithHealthCheck(() =>
}) reloadTraefik({ serverId }),
.then(async () => { );
toast.success("Traefik Reloaded"); } catch (error) {
}) const errorMessage =
.catch(() => {}); (error as Error)?.message ||
"Failed to reload Traefik. Please try again.";
toast.error(errorMessage);
}
}} }}
className="cursor-pointer" className="cursor-pointer"
disabled={isReloadHealthCheckExecuting}
> >
<span>{t("settings.server.webServer.reload")}</span> <span>{t("settings.server.webServer.reload")}</span>
</DropdownMenuItem> </DropdownMenuItem>
+6 -6
View File
@@ -118,12 +118,12 @@ export const settingsRouter = createTRPCRouter({
reloadTraefik: adminProcedure reloadTraefik: adminProcedure
.input(apiServerSchema) .input(apiServerSchema)
.mutation(async ({ input }) => { .mutation(async ({ input }) => {
try { // Run in background so the request returns immediately; avoids proxy timeouts.
await reloadDockerResource("dokploy-traefik", input?.serverId); void reloadDockerResource("dokploy-traefik", input?.serverId).catch(
} catch (err) { (err) => {
console.error(err); console.error("reloadTraefik background:", err);
} },
);
return true; return true;
}), }),
toggleDashboard: adminProcedure toggleDashboard: adminProcedure