From 21ee22d4f52f3d2def61f77c8d142b79a12b19d9 Mon Sep 17 00:00:00 2001 From: Lorenzo Migliorero Date: Thu, 3 Oct 2024 15:27:48 +0200 Subject: [PATCH 1/5] add dropdown link --- .../components/dashboard/projects/show.tsx | 88 +++++++++++++++++-- apps/dokploy/server/api/routers/project.ts | 14 ++- 2 files changed, 93 insertions(+), 9 deletions(-) diff --git a/apps/dokploy/components/dashboard/projects/show.tsx b/apps/dokploy/components/dashboard/projects/show.tsx index a6bdc5b9..5e49fe60 100644 --- a/apps/dokploy/components/dashboard/projects/show.tsx +++ b/apps/dokploy/components/dashboard/projects/show.tsx @@ -15,14 +15,18 @@ import { Card, CardFooter, 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 { AlertTriangle, BookIcon, + CircuitBoard, + ExternalLink, ExternalLinkIcon, FolderInput, MoreHorizontalIcon, @@ -31,6 +35,7 @@ import { import Link from "next/link"; import { toast } from "sonner"; import { UpdateProject } from "./update"; +import { Fragment } from "react"; export const ShowProjects = () => { const utils = api.useUtils(); @@ -45,6 +50,7 @@ export const ShowProjects = () => { }, ); const { mutateAsync } = api.project.remove.useMutation(); + return ( <> {data?.length === 0 && ( @@ -74,17 +80,85 @@ export const ShowProjects = () => { project?.redis.length + project?.applications.length + project?.compose.length; + + const flattedDomains = [ + ...project.applications.flatMap((a) => a.domains), + ...project.compose.flatMap((a) => a.domains), + ]; + + const renderDomainsDropdown = ( + item: typeof project.compose | typeof project.applications, + ) => + item[0] ? ( + + + {"applicationId" in item[0] ? "Applications" : "Compose"} + + {item.map((a) => ( + + + + + {a.name} + + + {a.domains.map((domain) => ( + + e.stopPropagation()} + > + {domain.host} + + + + ))} + + + ))} + + ) : null; + return (
- + {flattedDomains.length > 1 ? ( + + + + + + {renderDomainsDropdown(project.applications)} + {renderDomainsDropdown(project.compose)} + + + ) : flattedDomains[0] ? ( + + ) : null} + diff --git a/apps/dokploy/server/api/routers/project.ts b/apps/dokploy/server/api/routers/project.ts index 4ad9be75..6fb0e213 100644 --- a/apps/dokploy/server/api/routers/project.ts +++ b/apps/dokploy/server/api/routers/project.ts @@ -125,6 +125,7 @@ export const projectRouter = createTRPCRouter({ applications.applicationId, accesedServices, ), + with: { domains: true }, }, mariadb: { where: buildServiceFilter(mariadb.mariadbId, accesedServices), @@ -143,6 +144,7 @@ export const projectRouter = createTRPCRouter({ }, compose: { where: buildServiceFilter(compose.composeId, accesedServices), + with: { domains: true }, }, }, orderBy: desc(projects.createdAt), @@ -153,13 +155,21 @@ export const projectRouter = createTRPCRouter({ return await db.query.projects.findMany({ with: { - applications: true, + applications: { + with: { + domains: true, + }, + }, mariadb: true, mongo: true, mysql: true, postgres: true, redis: true, - compose: true, + compose: { + with: { + domains: true, + }, + }, }, where: eq(projects.adminId, ctx.user.adminId), orderBy: desc(projects.createdAt), From 8f7bffc349ae4e5bed28e93c4adb7f08407d5319 Mon Sep 17 00:00:00 2001 From: Lorenzo Migliorero Date: Thu, 3 Oct 2024 15:32:45 +0200 Subject: [PATCH 2/5] add fragment --- apps/dokploy/components/dashboard/projects/show.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dokploy/components/dashboard/projects/show.tsx b/apps/dokploy/components/dashboard/projects/show.tsx index 5e49fe60..93ec332b 100644 --- a/apps/dokploy/components/dashboard/projects/show.tsx +++ b/apps/dokploy/components/dashboard/projects/show.tsx @@ -33,9 +33,9 @@ import { TrashIcon, } from "lucide-react"; import Link from "next/link"; +import { Fragment } from "react"; import { toast } from "sonner"; import { UpdateProject } from "./update"; -import { Fragment } from "react"; export const ShowProjects = () => { const utils = api.useUtils(); From f640b4a87f55d21682d55663f11abd7b6737ebfa Mon Sep 17 00:00:00 2001 From: Lorenzo Migliorero Date: Fri, 4 Oct 2024 11:03:11 +0200 Subject: [PATCH 3/5] stop propagation --- apps/dokploy/components/dashboard/projects/show.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/dokploy/components/dashboard/projects/show.tsx b/apps/dokploy/components/dashboard/projects/show.tsx index 93ec332b..6c3ff8cd 100644 --- a/apps/dokploy/components/dashboard/projects/show.tsx +++ b/apps/dokploy/components/dashboard/projects/show.tsx @@ -110,7 +110,6 @@ export const ShowProjects = () => { className="space-x-4 text-xs cursor-pointer justify-between" target="_blank" href={`${domain.https ? "https" : "http"}://${domain.host}${domain.path}`} - onClick={(e) => e.stopPropagation()} > {domain.host} @@ -138,7 +137,10 @@ export const ShowProjects = () => { - + e.stopPropagation()} + > {renderDomainsDropdown(project.applications)} {renderDomainsDropdown(project.compose)} From de6aeac243036058eda59aab439984010e8ccd16 Mon Sep 17 00:00:00 2001 From: Enrique Date: Fri, 4 Oct 2024 11:46:14 +0200 Subject: [PATCH 4/5] fix(application.create): add missing return statement and align response with application.one --- apps/dokploy/server/api/routers/application.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/dokploy/server/api/routers/application.ts b/apps/dokploy/server/api/routers/application.ts index 4c43fe7c..92a2f862 100644 --- a/apps/dokploy/server/api/routers/application.ts +++ b/apps/dokploy/server/api/routers/application.ts @@ -72,6 +72,7 @@ export const applicationRouter = createTRPCRouter({ if (ctx.user.rol === "user") { await addNewService(ctx.user.authId, newApplication.applicationId); } + return newApplication; } catch (error: unknown) { if (error instanceof TRPCError) { throw error; From 2be724f78086d810b6f64f23ea414a16baeb1a97 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sat, 5 Oct 2024 02:39:50 -0600 Subject: [PATCH 5/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 33891a3c..28b1f226 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ Dokploy include multiples features to make your life easier. - **Docker Management**: Easily deploy and manage Docker containers. - **CLI/API**: Manage your applications and databases using the command line or trought the API. - **Notifications**: Get notified when your deployments are successful or failed (Slack, Discord, Telegram, Email, etc.) +- **Multi Server**: Deploy and manager your applications remotely to external servers. - **Self-Hosted**: Self-host Dokploy on your VPS. ## 🚀 Getting Started