mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-20 21:35:23 +02:00
refactor(application): update application handling to support multiple app names and improve data structure
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { Layers, Loader2 } from "lucide-react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
@@ -8,7 +9,6 @@ import {
|
|||||||
DialogTrigger,
|
DialogTrigger,
|
||||||
} from "@/components/ui/dialog";
|
} from "@/components/ui/dialog";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import { Layers, Loader2 } from "lucide-react";
|
|
||||||
import { type ApplicationList, columns } from "./columns";
|
import { type ApplicationList, columns } from "./columns";
|
||||||
import { DataTable } from "./data-table";
|
import { DataTable } from "./data-table";
|
||||||
|
|
||||||
@@ -20,10 +20,10 @@ export const ShowNodeApplications = ({ serverId }: Props) => {
|
|||||||
const { data: NodeApps, isLoading: NodeAppsLoading } =
|
const { data: NodeApps, isLoading: NodeAppsLoading } =
|
||||||
api.swarm.getNodeApps.useQuery({ serverId });
|
api.swarm.getNodeApps.useQuery({ serverId });
|
||||||
|
|
||||||
let applicationList = "";
|
let applicationList: string[] = [];
|
||||||
|
|
||||||
if (NodeApps && NodeApps.length > 0) {
|
if (NodeApps && NodeApps.length > 0) {
|
||||||
applicationList = NodeApps.map((app) => app.Name).join(" ");
|
applicationList = NodeApps.map((app) => app.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data: NodeAppDetails, isLoading: NodeAppDetailsLoading } =
|
const { data: NodeAppDetails, isLoading: NodeAppDetailsLoading } =
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import {
|
import {
|
||||||
|
findServerById,
|
||||||
getApplicationInfo,
|
getApplicationInfo,
|
||||||
getNodeApplications,
|
getNodeApplications,
|
||||||
getNodeInfo,
|
getNodeInfo,
|
||||||
getSwarmNodes,
|
getSwarmNodes,
|
||||||
} from "@dokploy/server";
|
} from "@dokploy/server";
|
||||||
import { findServerById } from "@dokploy/server";
|
|
||||||
import { TRPCError } from "@trpc/server";
|
import { TRPCError } from "@trpc/server";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { createTRPCRouter, protectedProcedure } from "../trpc";
|
import { createTRPCRouter, protectedProcedure } from "../trpc";
|
||||||
@@ -55,7 +55,12 @@ export const swarmRouter = createTRPCRouter({
|
|||||||
getAppInfos: protectedProcedure
|
getAppInfos: protectedProcedure
|
||||||
.input(
|
.input(
|
||||||
z.object({
|
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(),
|
serverId: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -441,13 +441,13 @@ export const getNodeApplications = async (serverId?: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getApplicationInfo = async (
|
export const getApplicationInfo = async (
|
||||||
appName: string,
|
appNames: string[],
|
||||||
serverId?: string,
|
serverId?: string,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
let stdout = "";
|
let stdout = "";
|
||||||
let stderr = "";
|
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) {
|
if (serverId) {
|
||||||
const result = await execAsyncRemote(serverId, command);
|
const result = await execAsyncRemote(serverId, command);
|
||||||
|
|||||||
Reference in New Issue
Block a user