Skip to content

Commit b5b63ea

Browse files
authored
Merge pull request #2288 from Dokploy/git-fetch-origin-git-checkout-2263-swarm-containers-no-data-found
refactor(application): update application handling to support multipl…
2 parents 17e9154 + 794e034 commit b5b63ea

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

apps/dokploy/components/dashboard/swarm/applications/show-applications.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Layers, Loader2 } from "lucide-react";
12
import { Button } from "@/components/ui/button";
23
import {
34
Dialog,
@@ -8,7 +9,6 @@ import {
89
DialogTrigger,
910
} from "@/components/ui/dialog";
1011
import { api } from "@/utils/api";
11-
import { Layers, Loader2 } from "lucide-react";
1212
import { type ApplicationList, columns } from "./columns";
1313
import { DataTable } from "./data-table";
1414

@@ -20,10 +20,10 @@ export const ShowNodeApplications = ({ serverId }: Props) => {
2020
const { data: NodeApps, isLoading: NodeAppsLoading } =
2121
api.swarm.getNodeApps.useQuery({ serverId });
2222

23-
let applicationList = "";
23+
let applicationList: string[] = [];
2424

2525
if (NodeApps && NodeApps.length > 0) {
26-
applicationList = NodeApps.map((app) => app.Name).join(" ");
26+
applicationList = NodeApps.map((app) => app.Name);
2727
}
2828

2929
const { data: NodeAppDetails, isLoading: NodeAppDetailsLoading } =

apps/dokploy/server/api/routers/swarm.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import {
2+
findServerById,
23
getApplicationInfo,
34
getNodeApplications,
45
getNodeInfo,
56
getSwarmNodes,
67
} from "@dokploy/server";
7-
import { findServerById } from "@dokploy/server";
88
import { TRPCError } from "@trpc/server";
99
import { z } from "zod";
1010
import { createTRPCRouter, protectedProcedure } from "../trpc";
@@ -55,7 +55,12 @@ export const swarmRouter = createTRPCRouter({
5555
getAppInfos: protectedProcedure
5656
.input(
5757
z.object({
58-
appName: z.string().min(1).regex(containerIdRegex, "Invalid app name."),
58+
appName: z
59+
.string()
60+
.min(1)
61+
.regex(containerIdRegex, "Invalid app name.")
62+
.array()
63+
.min(1),
5964
serverId: z.string().optional(),
6065
}),
6166
)

packages/server/src/services/docker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,13 +441,13 @@ export const getNodeApplications = async (serverId?: string) => {
441441
};
442442

443443
export const getApplicationInfo = async (
444-
appName: string,
444+
appNames: string[],
445445
serverId?: string,
446446
) => {
447447
try {
448448
let stdout = "";
449449
let stderr = "";
450-
const command = `docker service ps ${appName} --format '{{json .}}' --no-trunc`;
450+
const command = `docker service ps ${appNames.join(" ")} --format '{{json .}}' --no-trunc`;
451451

452452
if (serverId) {
453453
const result = await execAsyncRemote(serverId, command);

0 commit comments

Comments
 (0)