From f4bcc2e8a8fc95a958edc4c67c45898890988675 Mon Sep 17 00:00:00 2001 From: Mauricio Siu Date: Tue, 21 Jul 2026 19:10:51 -0600 Subject: [PATCH] refactor(networks): enhance network display and management interface - Updated the ShowNetworks component to improve the layout and user experience. - Introduced a new Pencil icon for editing networks and added a Badge component for displaying network drivers. - Refactored loading and empty state handling for better visual feedback. - Modified the API query to include server details for each network, enhancing the data returned for better context. --- .../dashboard/networks/show-networks.tsx | 174 ++++++++++-------- apps/dokploy/server/api/routers/network.ts | 17 +- 2 files changed, 105 insertions(+), 86 deletions(-) diff --git a/apps/dokploy/components/dashboard/networks/show-networks.tsx b/apps/dokploy/components/dashboard/networks/show-networks.tsx index 4e8ef6513..0d8f642b5 100644 --- a/apps/dokploy/components/dashboard/networks/show-networks.tsx +++ b/apps/dokploy/components/dashboard/networks/show-networks.tsx @@ -1,10 +1,12 @@ "use client"; -import { Loader2, Network } from "lucide-react"; +import { Loader2, Network, Pencil } from "lucide-react"; import { HandleNetwork } from "@/components/dashboard/networks/handle-network"; +import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Card, + CardAction, CardContent, CardDescription, CardHeader, @@ -27,89 +29,99 @@ export const ShowNetworks = () => {
-
- - - - Networks - - - Manage Docker networks for your organization. Networks can be - scoped to a server (optional). - - - {networks && networks?.length > 0 && } -
+ + + + Networks + + + Manage Docker networks for your organization. Networks can be + scoped to a server (optional). + + {networks && networks.length > 0 && ( + + + + )} + -
-
-
- {isLoading ? ( -
- Loading... - -
- ) : !networks?.length ? ( -
-
- -
-
-

No networks yet

-

- Create Docker networks for your organization and - optionally attach them to a server. Add your first - network to get started. -

-
- -
- ) : ( - - - - Name - Driver - Scope - Internal - Attachable - Server - Created - Actions - - - - {networks.map((n) => ( - - - {n.name} - - {n.driver} - {n.scope ?? "—"} - {n.internal ? "Yes" : "No"} - {n.attachable ? "Yes" : "No"} - - {n.serverId ?? "Dokploy server"} - - - {new Date(n.createdAt).toLocaleDateString()} - - - - - - - - ))} - -
- )} -
+ {isLoading ? ( +
+ Loading... +
-
+ ) : !networks?.length ? ( +
+
+ +
+
+

No networks yet

+

+ Create Docker networks for your organization and optionally + attach them to a server. Add your first network to get + started. +

+
+ +
+ ) : ( +
+ + + + Name + Driver + Scope + Internal + Attachable + Server + Created + + Actions + + + + + {networks.map((n) => ( + + {n.name} + + {n.driver} + + + {n.scope ?? "—"} + + + {n.internal ? "Yes" : "No"} + + + {n.attachable ? "Yes" : "No"} + + + {n.server?.name ?? "Dokploy Server"} + + + {new Date(n.createdAt).toLocaleDateString()} + + + + + + + + ))} + +
+
+ )}
diff --git a/apps/dokploy/server/api/routers/network.ts b/apps/dokploy/server/api/routers/network.ts index 46da4d79d..cf6503375 100644 --- a/apps/dokploy/server/api/routers/network.ts +++ b/apps/dokploy/server/api/routers/network.ts @@ -18,11 +18,18 @@ import { export const networkRouter = createTRPCRouter({ all: protectedProcedure.query(async ({ ctx }) => { - const rows = await db - .select() - .from(networkTable) - .where(eq(networkTable.organizationId, ctx.session.activeOrganizationId)) - .orderBy(desc(networkTable.createdAt)); + const rows = await db.query.network.findMany({ + where: eq(networkTable.organizationId, ctx.session.activeOrganizationId), + with: { + server: { + columns: { + serverId: true, + name: true, + }, + }, + }, + orderBy: desc(networkTable.createdAt), + }); return rows; }),