diff --git a/apps/dokploy/components/dashboard/settings/servers/actions/show-dokploy-actions.tsx b/apps/dokploy/components/dashboard/settings/servers/actions/show-dokploy-actions.tsx index 49f6772b..9c30c13f 100644 --- a/apps/dokploy/components/dashboard/settings/servers/actions/show-dokploy-actions.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/actions/show-dokploy-actions.tsx @@ -1,6 +1,7 @@ import { Button } from "@/components/ui/button"; import React from "react"; +import { UpdateServerIp } from "@/components/dashboard/settings/web-server/update-server-ip"; import { DropdownMenu, DropdownMenuContent, @@ -39,12 +40,26 @@ export const ShowDokployActions = () => { toast.success("Server Reloaded"); }); }} + className="cursor-pointer" > - Reload + Reload - Watch logs + e.preventDefault()} + > + Watch Logs + + + e.preventDefault()} + > + Update Server IP + + diff --git a/apps/dokploy/components/dashboard/settings/servers/actions/show-server-actions.tsx b/apps/dokploy/components/dashboard/settings/servers/actions/show-server-actions.tsx index 1f7f2d14..fcc0e315 100644 --- a/apps/dokploy/components/dashboard/settings/servers/actions/show-server-actions.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/actions/show-server-actions.tsx @@ -1,4 +1,3 @@ -import { CardDescription, CardTitle } from "@/components/ui/card"; import { Dialog, DialogContent, @@ -21,13 +20,13 @@ export const ShowServerActions = ({ serverId }: Props) => { e.preventDefault()} > View Actions - +
Web server settings Reload or clean the web server. diff --git a/apps/dokploy/components/dashboard/settings/servers/actions/show-storage-actions.tsx b/apps/dokploy/components/dashboard/settings/servers/actions/show-storage-actions.tsx index b3f9c334..4294d7d7 100644 --- a/apps/dokploy/components/dashboard/settings/servers/actions/show-storage-actions.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/actions/show-storage-actions.tsx @@ -85,7 +85,7 @@ export const ShowStorageActions = ({ serverId }: Props) => { }); }} > - Clean unused images + Clean Unused Images { }); }} > - Clean unused volumes + Clean Unused Volumes { }); }} > - Clean stopped containers + Clean Stopped Containers { }); }} > - Clean all + Clean All diff --git a/apps/dokploy/components/dashboard/settings/servers/actions/show-traefik-actions.tsx b/apps/dokploy/components/dashboard/settings/servers/actions/show-traefik-actions.tsx index a0ea3f5e..d37e3aba 100644 --- a/apps/dokploy/components/dashboard/settings/servers/actions/show-traefik-actions.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/actions/show-traefik-actions.tsx @@ -70,16 +70,22 @@ export const ShowTraefikActions = ({ serverId }: Props) => { toast.error("Error to reload the traefik"); }); }} + className="cursor-pointer" > Reload - Watch logs + e.preventDefault()} + className="cursor-pointer" + > + Watch Logs + e.preventDefault()} - className="w-full cursor-pointer space-x-3" + className="cursor-pointer" > Modify Env diff --git a/apps/dokploy/components/dashboard/settings/web-server/show-modal-logs.tsx b/apps/dokploy/components/dashboard/settings/web-server/show-modal-logs.tsx index 607ff7b2..2693f79c 100644 --- a/apps/dokploy/components/dashboard/settings/web-server/show-modal-logs.tsx +++ b/apps/dokploy/components/dashboard/settings/web-server/show-modal-logs.tsx @@ -58,14 +58,7 @@ export const ShowModalLogs = ({ appName, children, serverId }: Props) => { }, [data]); return ( - - e.preventDefault()} - > - {children} - - + {children} View Logs diff --git a/apps/dokploy/components/dashboard/settings/web-server/update-server-ip.tsx b/apps/dokploy/components/dashboard/settings/web-server/update-server-ip.tsx new file mode 100644 index 00000000..4834ef92 --- /dev/null +++ b/apps/dokploy/components/dashboard/settings/web-server/update-server-ip.tsx @@ -0,0 +1,125 @@ +import { AlertBlock } from "@/components/shared/alert-block"; +import { CodeEditor } from "@/components/shared/code-editor"; +import { Button } from "@/components/ui/button"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog"; +import { + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; +import { Input } from "@/components/ui/input"; +import { api } from "@/utils/api"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { useEffect, useState } from "react"; +import { useForm } from "react-hook-form"; +import { toast } from "sonner"; +import { z } from "zod"; + +const schema = z.object({ + serverIp: z.string(), +}); + +type Schema = z.infer; + +interface Props { + children?: React.ReactNode; + serverId?: string; +} + +export const UpdateServerIp = ({ children, serverId }: Props) => { + const [isOpen, setIsOpen] = useState(false); + + const { data } = api.admin.one.useQuery(); + + const { mutateAsync, isLoading, error, isError } = + api.admin.update.useMutation(); + + const form = useForm({ + defaultValues: { + serverIp: data?.serverIp || "", + }, + resolver: zodResolver(schema), + }); + + useEffect(() => { + if (data) { + form.reset({ + serverIp: data.serverIp || "", + }); + } + }, [form, form.reset, data]); + + const utils = api.useUtils(); + + const onSubmit = async (data: Schema) => { + await mutateAsync({ + serverIp: data.serverIp, + }) + .then(async () => { + toast.success("Server IP Updated"); + await utils.admin.one.invalidate(); + setIsOpen(false); + }) + .catch(() => { + toast.error("Error to update the IP of the server"); + }); + }; + + return ( + + {children} + + + Update Server IP + Update the IP of the server + + {isError && {error?.message}} + +
+ + ( + + Server IP + + + +
+										
+									
+
+ )} + /> + + + + + + +
+
+ ); +}; diff --git a/apps/dokploy/components/dashboard/settings/web-server/update-server.tsx b/apps/dokploy/components/dashboard/settings/web-server/update-server.tsx index 16591865..757c7795 100644 --- a/apps/dokploy/components/dashboard/settings/web-server/update-server.tsx +++ b/apps/dokploy/components/dashboard/settings/web-server/update-server.tsx @@ -87,7 +87,7 @@ export const UpdateServer = () => { }} isLoading={isLoading} > - Check updates + Check Updates )}
diff --git a/apps/dokploy/server/api/routers/admin.ts b/apps/dokploy/server/api/routers/admin.ts index 42ce15bc..d910f223 100644 --- a/apps/dokploy/server/api/routers/admin.ts +++ b/apps/dokploy/server/api/routers/admin.ts @@ -4,6 +4,7 @@ import { apiCreateUserInvitation, apiFindOneToken, apiRemoveUser, + apiUpdateAdmin, users, } from "@/server/db/schema"; import { @@ -13,6 +14,7 @@ import { findUserById, getUserByToken, removeUserByAuthId, + updateAdmin, } from "@dokploy/server"; import { TRPCError } from "@trpc/server"; import { eq } from "drizzle-orm"; @@ -26,6 +28,12 @@ export const adminRouter = createTRPCRouter({ ...rest, }; }), + update: adminProcedure + .input(apiUpdateAdmin) + .mutation(async ({ input, ctx }) => { + const { authId } = await findAdminById(ctx.user.adminId); + return updateAdmin(authId, input); + }), createUserInvitation: adminProcedure .input(apiCreateUserInvitation) .mutation(async ({ input, ctx }) => { diff --git a/packages/server/src/db/schema/admin.ts b/packages/server/src/db/schema/admin.ts index cce611c2..222fb16c 100644 --- a/packages/server/src/db/schema/admin.ts +++ b/packages/server/src/db/schema/admin.ts @@ -53,6 +53,8 @@ const createSchema = createInsertSchema(admins, { letsEncryptEmail: z.string().optional(), }); +export const apiUpdateAdmin = createSchema.partial(); + export const apiSaveSSHKey = createSchema .pick({ sshPrivateKey: true,