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…
This commit is contained in:
Mauricio Siu
2025-08-01 00:35:32 -06:00
committed by GitHub
3 changed files with 12 additions and 7 deletions

View File

@@ -1,3 +1,4 @@
import { Layers, Loader2 } from "lucide-react";
import { Button } from "@/components/ui/button";
import {
Dialog,
@@ -8,7 +9,6 @@ import {
DialogTrigger,
} from "@/components/ui/dialog";
import { api } from "@/utils/api";
import { Layers, Loader2 } from "lucide-react";
import { type ApplicationList, columns } from "./columns";
import { DataTable } from "./data-table";
@@ -20,10 +20,10 @@ export const ShowNodeApplications = ({ serverId }: Props) => {
const { data: NodeApps, isLoading: NodeAppsLoading } =
api.swarm.getNodeApps.useQuery({ serverId });
let applicationList = "";
let applicationList: string[] = [];
if (NodeApps && NodeApps.length > 0) {
applicationList = NodeApps.map((app) => app.Name).join(" ");
applicationList = NodeApps.map((app) => app.Name);
}
const { data: NodeAppDetails, isLoading: NodeAppDetailsLoading } =

View File

@@ -1,10 +1,10 @@
import {
findServerById,
getApplicationInfo,
getNodeApplications,
getNodeInfo,
getSwarmNodes,
} from "@dokploy/server";
import { findServerById } from "@dokploy/server";
import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { createTRPCRouter, protectedProcedure } from "../trpc";
@@ -55,7 +55,12 @@ export const swarmRouter = createTRPCRouter({
getAppInfos: protectedProcedure
.input(
z.object({
appName: z.string().min(1).regex(containerIdRegex, "Invalid app name."),
appName: z
.string()
.min(1)
.regex(containerIdRegex, "Invalid app name.")
.array()
.min(1),
serverId: z.string().optional(),
}),
)

View File

@@ -441,13 +441,13 @@ export const getNodeApplications = async (serverId?: string) => {
};
export const getApplicationInfo = async (
appName: string,
appNames: string[],
serverId?: string,
) => {
try {
let stdout = "";
let stderr = "";
const command = `docker service ps ${appName} --format '{{json .}}' --no-trunc`;
const command = `docker service ps ${appNames.join(" ")} --format '{{json .}}' --no-trunc`;
if (serverId) {
const result = await execAsyncRemote(serverId, command);