import React, { useEffect, useState } from "react"; import { Button } from "@/components/ui/button"; import { Switch } from "@/components/ui/switch"; import { Label } from "@/components/ui/label"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { api } from "@/utils/api"; import { toast } from "sonner"; import { ShowModalLogs } from "./web-server/show-modal-logs"; import { TerminalModal } from "./web-server/terminal-modal"; import { DockerTerminalModal } from "./web-server/docker-terminal-modal"; import { ShowMainTraefikConfig } from "./web-server/show-main-traefik-config"; import { ShowServerTraefikConfig } from "./web-server/show-server-traefik-config"; import { ShowServerMiddlewareConfig } from "./web-server/show-server-middleware-config"; import { UpdateServer } from "./web-server/update-server"; export const WebServer = () => { const { data, refetch } = api.admin.one.useQuery(); const { mutateAsync: reloadServer, isLoading } = api.settings.reloadServer.useMutation(); const { mutateAsync: reloadTraefik, isLoading: reloadTraefikIsLoading } = api.settings.reloadTraefik.useMutation(); const { mutateAsync: cleanAll, isLoading: cleanAllIsLoading } = api.settings.cleanAll.useMutation(); const { mutateAsync: cleanDockerBuilder, isLoading: cleanDockerBuilderIsLoading, } = api.settings.cleanDockerBuilder.useMutation(); const { mutateAsync: cleanMonitoring, isLoading: cleanMonitoringIsLoading } = api.settings.cleanMonitoring.useMutation(); const { mutateAsync: cleanUnusedImages, isLoading: cleanUnusedImagesIsLoading, } = api.settings.cleanUnusedImages.useMutation(); const { mutateAsync: cleanUnusedVolumes, isLoading: cleanUnusedVolumesIsLoading, } = api.settings.cleanUnusedVolumes.useMutation(); const { mutateAsync: cleanStoppedContainers, isLoading: cleanStoppedContainersIsLoading, } = api.settings.cleanStoppedContainers.useMutation(); const { data: dokployVersion } = api.settings.getDokployVersion.useQuery(); const { mutateAsync: updateDockerCleanup } = api.settings.updateDockerCleanup.useMutation(); return ( Web server settings Reload or clean the web server.
Actions { await reloadServer() .then(async () => { toast.success("Server Reloaded"); }) .catch(() => { toast.success("Server Reloaded"); }); }} > Reload Watch logs e.preventDefault()} className="w-full cursor-pointer space-x-3" > View Traefik config e.preventDefault()} className="w-full cursor-pointer space-x-3" > View middlewares config Enter the terminal Actions { await reloadTraefik() .then(async () => { toast.success("Traefik Reloaded"); }) .catch(() => { toast.error("Error to reload the traefik"); }); }} > Reload Watch logs e.preventDefault()} className="w-full cursor-pointer space-x-3" > View Traefik config e.preventDefault()} > Enter the terminal Actions { await cleanUnusedImages() .then(async () => { toast.success("Cleaned images"); }) .catch(() => { toast.error("Error to clean images"); }); }} > Clean unused images { await cleanUnusedVolumes() .then(async () => { toast.success("Cleaned volumes"); }) .catch(() => { toast.error("Error to clean volumes"); }); }} > Clean unused volumes { await cleanStoppedContainers() .then(async () => { toast.success("Stopped containers cleaned"); }) .catch(() => { toast.error("Error to clean stopped containers"); }); }} > Clean stopped containers { await cleanDockerBuilder() .then(async () => { toast.success("Cleaned Docker Builder"); }) .catch(() => { toast.error("Error to clean Docker Builder"); }); }} > Clean Docker Builder & System { await cleanMonitoring() .then(async () => { toast.success("Cleaned Monitoring"); }) .catch(() => { toast.error("Error to clean Monitoring"); }); }} > Clean Monitoring { await cleanAll() .then(async () => { toast.success("Cleaned all"); }) .catch(() => { toast.error("Error to clean all"); }); }} > Clean all
Server IP: {data?.serverIp} Version: {dokployVersion}
{ await updateDockerCleanup({ enableDockerCleanup: e, }) .then(async () => { toast.success("Docker Cleanup Enabled"); }) .catch(() => { toast.error("Docker Cleanup Error"); }); refetch(); }} />
); };