diff --git a/apps/dokploy/components/dashboard/application/general/show.tsx b/apps/dokploy/components/dashboard/application/general/show.tsx index b8ebca50..01b38bd3 100644 --- a/apps/dokploy/components/dashboard/application/general/show.tsx +++ b/apps/dokploy/components/dashboard/application/general/show.tsx @@ -24,290 +24,287 @@ import { useRouter } from "next/router"; import { toast } from "sonner"; import { DockerTerminalModal } from "../../settings/web-server/docker-terminal-modal"; interface Props { - applicationId: string; + applicationId: string; } export const ShowGeneralApplication = ({ applicationId }: Props) => { - const router = useRouter(); - const { data, refetch } = api.application.one.useQuery( - { - applicationId, - }, - { enabled: !!applicationId } - ); - const { mutateAsync: update } = api.application.update.useMutation(); - const { mutateAsync: start, isLoading: isStarting } = - api.application.start.useMutation(); - const { mutateAsync: stop, isLoading: isStopping } = - api.application.stop.useMutation(); + const router = useRouter(); + const { data, refetch } = api.application.one.useQuery( + { + applicationId, + }, + { enabled: !!applicationId }, + ); + const { mutateAsync: update } = api.application.update.useMutation(); + const { mutateAsync: start, isLoading: isStarting } = + api.application.start.useMutation(); + const { mutateAsync: stop, isLoading: isStopping } = + api.application.stop.useMutation(); - const { mutateAsync: deploy } = api.application.deploy.useMutation(); + const { mutateAsync: deploy } = api.application.deploy.useMutation(); - const { mutateAsync: reload, isLoading: isReloading } = - api.application.reload.useMutation(); + const { mutateAsync: reload, isLoading: isReloading } = + api.application.reload.useMutation(); - const { mutateAsync: redeploy } = api.application.redeploy.useMutation(); + const { mutateAsync: redeploy } = api.application.redeploy.useMutation(); - return ( - <> - - - Deploy Settings - - - - { - await deploy({ - applicationId: applicationId, - }) - .then(() => { - toast.success("Application deployed successfully"); - refetch(); - router.push( - `/dashboard/project/${data?.projectId}/services/application/${applicationId}?tab=deployments` - ); - }) - .catch(() => { - toast.error("Error deploying application"); - }); - }} - > - - - - - - -

- Downloads the source code and performs a complete build -

-
-
-
-
- { - await reload({ - applicationId: applicationId, - appName: data?.appName || "", - }) - .then(() => { - toast.success("Application reloaded successfully"); - refetch(); - }) - .catch(() => { - toast.error("Error reloading application"); - }); - }} - > - - - - - - -

- Reload the application when you change configuration or - environment variables -

-
-
-
-
- { - await redeploy({ - applicationId: applicationId, - }) - .then(() => { - toast.success("Application rebuilt successfully"); - refetch(); - }) - .catch(() => { - toast.error("Error rebuilding application"); - }); - }} - > - - - - - - -

- Only rebuilds the application without downloading new code -

-
-
-
-
+ return ( + <> + + + Deploy Settings + + + + { + await deploy({ + applicationId: applicationId, + }) + .then(() => { + toast.success("Application deployed successfully"); + refetch(); + router.push( + `/dashboard/project/${data?.projectId}/services/application/${applicationId}?tab=deployments`, + ); + }) + .catch(() => { + toast.error("Error deploying application"); + }); + }} + > + + + + + + +

+ Downloads the source code and performs a complete build +

+
+
+
+
+ { + await reload({ + applicationId: applicationId, + appName: data?.appName || "", + }) + .then(() => { + toast.success("Application reloaded successfully"); + refetch(); + }) + .catch(() => { + toast.error("Error reloading application"); + }); + }} + > + + + + + + +

Reload the application without rebuilding it

+
+
+
+
+ { + await redeploy({ + applicationId: applicationId, + }) + .then(() => { + toast.success("Application rebuilt successfully"); + refetch(); + }) + .catch(() => { + toast.error("Error rebuilding application"); + }); + }} + > + + + + + + +

+ Only rebuilds the application without downloading new code +

+
+
+
+
- {data?.applicationStatus === "idle" ? ( - { - await start({ - applicationId: applicationId, - }) - .then(() => { - toast.success("Application started successfully"); - refetch(); - }) - .catch(() => { - toast.error("Error starting application"); - }); - }} - > - - - - - - -

- Start the application (requires a previous successful - build) -

-
-
-
-
- ) : ( - { - await stop({ - applicationId: applicationId, - }) - .then(() => { - toast.success("Application stopped successfully"); - refetch(); - }) - .catch(() => { - toast.error("Error stopping application"); - }); - }} - > - - - - - - -

Stop the currently running application

-
-
-
-
- )} -
- - - -
- Autodeploy - { - await update({ - applicationId, - autoDeploy: enabled, - }) - .then(async () => { - toast.success("Auto Deploy Updated"); - await refetch(); - }) - .catch(() => { - toast.error("Error updating Auto Deploy"); - }); - }} - className="flex flex-row gap-2 items-center data-[state=checked]:bg-primary" - /> -
+ {data?.applicationStatus === "idle" ? ( + { + await start({ + applicationId: applicationId, + }) + .then(() => { + toast.success("Application started successfully"); + refetch(); + }) + .catch(() => { + toast.error("Error starting application"); + }); + }} + > + + + + + + +

+ Start the application (requires a previous successful + build) +

+
+
+
+
+ ) : ( + { + await stop({ + applicationId: applicationId, + }) + .then(() => { + toast.success("Application stopped successfully"); + refetch(); + }) + .catch(() => { + toast.error("Error stopping application"); + }); + }} + > + + + + + + +

Stop the currently running application

+
+
+
+
+ )} +
+ + + +
+ Autodeploy + { + await update({ + applicationId, + autoDeploy: enabled, + }) + .then(async () => { + toast.success("Auto Deploy Updated"); + await refetch(); + }) + .catch(() => { + toast.error("Error updating Auto Deploy"); + }); + }} + className="flex flex-row gap-2 items-center data-[state=checked]:bg-primary" + /> +
-
- Clean Cache - { - await update({ - applicationId, - cleanCache: enabled, - }) - .then(async () => { - toast.success("Clean Cache Updated"); - await refetch(); - }) - .catch(() => { - toast.error("Error updating Clean Cache"); - }); - }} - className="flex flex-row gap-2 items-center data-[state=checked]:bg-primary" - /> -
-
-
- - - - ); +
+ Clean Cache + { + await update({ + applicationId, + cleanCache: enabled, + }) + .then(async () => { + toast.success("Clean Cache Updated"); + await refetch(); + }) + .catch(() => { + toast.error("Error updating Clean Cache"); + }); + }} + className="flex flex-row gap-2 items-center data-[state=checked]:bg-primary" + /> +
+ + + + + + ); }; diff --git a/apps/dokploy/components/dashboard/compose/general/actions.tsx b/apps/dokploy/components/dashboard/compose/general/actions.tsx index 5fda2ba5..fc5daec7 100644 --- a/apps/dokploy/components/dashboard/compose/general/actions.tsx +++ b/apps/dokploy/components/dashboard/compose/general/actions.tsx @@ -15,211 +15,208 @@ import { toast } from "sonner"; import { DockerTerminalModal } from "../../settings/web-server/docker-terminal-modal"; interface Props { - composeId: string; + composeId: string; } export const ComposeActions = ({ composeId }: Props) => { - const router = useRouter(); - const { data, refetch } = api.compose.one.useQuery( - { - composeId, - }, - { enabled: !!composeId } - ); - const { mutateAsync: update } = api.compose.update.useMutation(); - const { mutateAsync: deploy } = api.compose.deploy.useMutation(); - const { mutateAsync: redeploy } = api.compose.redeploy.useMutation(); - const { mutateAsync: start, isLoading: isStarting } = - api.compose.start.useMutation(); - const { mutateAsync: stop, isLoading: isStopping } = - api.compose.stop.useMutation(); - return ( -
- - { - await deploy({ - composeId: composeId, - }) - .then(() => { - toast.success("Compose deployed successfully"); - refetch(); - router.push( - `/dashboard/project/${data?.project.projectId}/services/compose/${composeId}?tab=deployments` - ); - }) - .catch(() => { - toast.error("Error deploying compose"); - }); - }} - > - - - - - - -

Downloads the source code and performs a complete build

-
-
-
-
- { - await redeploy({ - composeId: composeId, - }) - .then(() => { - toast.success("Compose reloaded successfully"); - refetch(); - }) - .catch(() => { - toast.error("Error reloading compose"); - }); - }} - > - - - - - - -

- Reload the compose when you change configuration or - environment variables -

-
-
-
-
- {data?.composeType === "docker-compose" && - data?.composeStatus === "idle" ? ( - { - await start({ - composeId: composeId, - }) - .then(() => { - toast.success("Compose started successfully"); - refetch(); - }) - .catch(() => { - toast.error("Error starting compose"); - }); - }} - > - - - - - - -

- Start the compose (requires a previous successful build) -

-
-
-
-
- ) : ( - { - await stop({ - composeId: composeId, - }) - .then(() => { - toast.success("Compose stopped successfully"); - refetch(); - }) - .catch(() => { - toast.error("Error stopping compose"); - }); - }} - > - - - - - - -

Stop the currently running compose

-
-
-
-
- )} -
- - - -
- Autodeploy - { - await update({ - composeId, - autoDeploy: enabled, - }) - .then(async () => { - toast.success("Auto Deploy Updated"); - await refetch(); - }) - .catch(() => { - toast.error("Error updating Auto Deploy"); - }); - }} - className="flex flex-row gap-2 items-center data-[state=checked]:bg-primary" - /> -
-
- ); + const router = useRouter(); + const { data, refetch } = api.compose.one.useQuery( + { + composeId, + }, + { enabled: !!composeId }, + ); + const { mutateAsync: update } = api.compose.update.useMutation(); + const { mutateAsync: deploy } = api.compose.deploy.useMutation(); + const { mutateAsync: redeploy } = api.compose.redeploy.useMutation(); + const { mutateAsync: start, isLoading: isStarting } = + api.compose.start.useMutation(); + const { mutateAsync: stop, isLoading: isStopping } = + api.compose.stop.useMutation(); + return ( +
+ + { + await deploy({ + composeId: composeId, + }) + .then(() => { + toast.success("Compose deployed successfully"); + refetch(); + router.push( + `/dashboard/project/${data?.project.projectId}/services/compose/${composeId}?tab=deployments`, + ); + }) + .catch(() => { + toast.error("Error deploying compose"); + }); + }} + > + + + + + + +

Downloads the source code and performs a complete build

+
+
+
+
+ { + await redeploy({ + composeId: composeId, + }) + .then(() => { + toast.success("Compose reloaded successfully"); + refetch(); + }) + .catch(() => { + toast.error("Error reloading compose"); + }); + }} + > + + + + + + +

Reload the compose without rebuilding it

+
+
+
+
+ {data?.composeType === "docker-compose" && + data?.composeStatus === "idle" ? ( + { + await start({ + composeId: composeId, + }) + .then(() => { + toast.success("Compose started successfully"); + refetch(); + }) + .catch(() => { + toast.error("Error starting compose"); + }); + }} + > + + + + + + +

+ Start the compose (requires a previous successful build) +

+
+
+
+
+ ) : ( + { + await stop({ + composeId: composeId, + }) + .then(() => { + toast.success("Compose stopped successfully"); + refetch(); + }) + .catch(() => { + toast.error("Error stopping compose"); + }); + }} + > + + + + + + +

Stop the currently running compose

+
+
+
+
+ )} +
+ + + +
+ Autodeploy + { + await update({ + composeId, + autoDeploy: enabled, + }) + .then(async () => { + toast.success("Auto Deploy Updated"); + await refetch(); + }) + .catch(() => { + toast.error("Error updating Auto Deploy"); + }); + }} + className="flex flex-row gap-2 items-center data-[state=checked]:bg-primary" + /> +
+
+ ); }; diff --git a/apps/dokploy/components/dashboard/postgres/general/show-general-postgres.tsx b/apps/dokploy/components/dashboard/postgres/general/show-general-postgres.tsx index 3692e600..999bc850 100644 --- a/apps/dokploy/components/dashboard/postgres/general/show-general-postgres.tsx +++ b/apps/dokploy/components/dashboard/postgres/general/show-general-postgres.tsx @@ -3,10 +3,10 @@ import { DrawerLogs } from "@/components/shared/drawer-logs"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { - Tooltip, - TooltipContent, - TooltipProvider, - TooltipTrigger, + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, } from "@/components/ui/tooltip"; import { api } from "@/utils/api"; import * as TooltipPrimitive from "@radix-ui/react-tooltip"; @@ -17,230 +17,227 @@ import { type LogLine, parseLogs } from "../../docker/logs/utils"; import { DockerTerminalModal } from "../../settings/web-server/docker-terminal-modal"; interface Props { - postgresId: string; + postgresId: string; } export const ShowGeneralPostgres = ({ postgresId }: Props) => { - const { data, refetch } = api.postgres.one.useQuery( - { - postgresId: postgresId, - }, - { enabled: !!postgresId } - ); + const { data, refetch } = api.postgres.one.useQuery( + { + postgresId: postgresId, + }, + { enabled: !!postgresId }, + ); - const { mutateAsync: reload, isLoading: isReloading } = - api.postgres.reload.useMutation(); + const { mutateAsync: reload, isLoading: isReloading } = + api.postgres.reload.useMutation(); - const { mutateAsync: stop, isLoading: isStopping } = - api.postgres.stop.useMutation(); + const { mutateAsync: stop, isLoading: isStopping } = + api.postgres.stop.useMutation(); - const { mutateAsync: start, isLoading: isStarting } = - api.postgres.start.useMutation(); + const { mutateAsync: start, isLoading: isStarting } = + api.postgres.start.useMutation(); - const [isDrawerOpen, setIsDrawerOpen] = useState(false); - const [filteredLogs, setFilteredLogs] = useState([]); - const [isDeploying, setIsDeploying] = useState(false); - api.postgres.deployWithLogs.useSubscription( - { - postgresId: postgresId, - }, - { - enabled: isDeploying, - onData(log) { - if (!isDrawerOpen) { - setIsDrawerOpen(true); - } + const [isDrawerOpen, setIsDrawerOpen] = useState(false); + const [filteredLogs, setFilteredLogs] = useState([]); + const [isDeploying, setIsDeploying] = useState(false); + api.postgres.deployWithLogs.useSubscription( + { + postgresId: postgresId, + }, + { + enabled: isDeploying, + onData(log) { + if (!isDrawerOpen) { + setIsDrawerOpen(true); + } - if (log === "Deployment completed successfully!") { - setIsDeploying(false); - } - const parsedLogs = parseLogs(log); - setFilteredLogs((prev) => [...prev, ...parsedLogs]); - }, - onError(error) { - console.error("Deployment logs error:", error); - setIsDeploying(false); - }, - } - ); + if (log === "Deployment completed successfully!") { + setIsDeploying(false); + } + const parsedLogs = parseLogs(log); + setFilteredLogs((prev) => [...prev, ...parsedLogs]); + }, + onError(error) { + console.error("Deployment logs error:", error); + setIsDeploying(false); + }, + }, + ); - return ( - <> -
- - - Deploy Settings - - - - { - setIsDeploying(true); - await new Promise((resolve) => setTimeout(resolve, 1000)); - refetch(); - }} - > - - - - - - -

Downloads and sets up the PostgreSQL database

-
-
-
-
- { - await reload({ - postgresId: postgresId, - appName: data?.appName || "", - }) - .then(() => { - toast.success("Postgres reloaded successfully"); - refetch(); - }) - .catch(() => { - toast.error("Error reloading Postgres"); - }); - }} - > - - - - - - -

- Reload the PostgreSQL when you change configuration or - environment variables -

-
-
-
-
- {data?.applicationStatus === "idle" ? ( - { - await start({ - postgresId: postgresId, - }) - .then(() => { - toast.success("Postgres started successfully"); - refetch(); - }) - .catch(() => { - toast.error("Error starting Postgres"); - }); - }} - > - - - - - - -

- Start the PostgreSQL database (requires a previous - successful setup) -

-
-
-
-
- ) : ( - { - await stop({ - postgresId: postgresId, - }) - .then(() => { - toast.success("Postgres stopped successfully"); - refetch(); - }) - .catch(() => { - toast.error("Error stopping Postgres"); - }); - }} - > - - - - - - -

Stop the currently running PostgreSQL database

-
-
-
-
- )} -
- - - -
-
- { - setIsDrawerOpen(false); - setFilteredLogs([]); - setIsDeploying(false); - refetch(); - }} - filteredLogs={filteredLogs} - /> -
- - ); + return ( + <> +
+ + + Deploy Settings + + + + { + setIsDeploying(true); + await new Promise((resolve) => setTimeout(resolve, 1000)); + refetch(); + }} + > + + + + + + +

Downloads and sets up the PostgreSQL database

+
+
+
+
+ { + await reload({ + postgresId: postgresId, + appName: data?.appName || "", + }) + .then(() => { + toast.success("Postgres reloaded successfully"); + refetch(); + }) + .catch(() => { + toast.error("Error reloading Postgres"); + }); + }} + > + + + + + + +

Reload the PostgreSQL without rebuilding it

+
+
+
+
+ {data?.applicationStatus === "idle" ? ( + { + await start({ + postgresId: postgresId, + }) + .then(() => { + toast.success("Postgres started successfully"); + refetch(); + }) + .catch(() => { + toast.error("Error starting Postgres"); + }); + }} + > + + + + + + +

+ Start the PostgreSQL database (requires a previous + successful setup) +

+
+
+
+
+ ) : ( + { + await stop({ + postgresId: postgresId, + }) + .then(() => { + toast.success("Postgres stopped successfully"); + refetch(); + }) + .catch(() => { + toast.error("Error stopping Postgres"); + }); + }} + > + + + + + + +

Stop the currently running PostgreSQL database

+
+
+
+
+ )} +
+ + + +
+
+ { + setIsDrawerOpen(false); + setFilteredLogs([]); + setIsDeploying(false); + refetch(); + }} + filteredLogs={filteredLogs} + /> +
+ + ); };