Merge pull request #989 from Dokploy/refactor/add-no-trunc

Refactor/add no trunc
This commit is contained in:
Mauricio Siu
2024-12-25 03:54:51 -06:00
committed by GitHub
4 changed files with 95 additions and 8 deletions

View File

@@ -0,0 +1,58 @@
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
import dynamic from "next/dynamic";
import type React from "react";
export const DockerLogsId = dynamic(
() =>
import("@/components/dashboard/docker/logs/docker-logs-id").then(
(e) => e.DockerLogsId,
),
{
ssr: false,
},
);
interface Props {
containerId: string;
children?: React.ReactNode;
serverId?: string | null;
}
export const ShowDockerModalStackLogs = ({
containerId,
children,
serverId,
}: Props) => {
return (
<Dialog>
<DialogTrigger asChild>
<DropdownMenuItem
className="w-full cursor-pointer space-x-3"
onSelect={(e) => e.preventDefault()}
>
{children}
</DropdownMenuItem>
</DialogTrigger>
<DialogContent className="max-h-screen overflow-y-auto sm:max-w-7xl">
<DialogHeader>
<DialogTitle>View Logs</DialogTitle>
<DialogDescription>View the logs for {containerId}</DialogDescription>
</DialogHeader>
<div className="flex flex-col gap-4 pt-2.5">
<DockerLogsId
containerId={containerId || ""}
serverId={serverId}
runType="swarm"
/>
</div>
</DialogContent>
</Dialog>
);
};

View File

@@ -11,11 +11,7 @@ import {
} from "@/components/ui/dropdown-menu"; } from "@/components/ui/dropdown-menu";
import { Badge } from "@/components/ui/badge"; import { Badge } from "@/components/ui/badge";
import { ShowNodeConfig } from "../details/show-node-config"; import { ShowDockerModalStackLogs } from "../../docker/logs/show-docker-modal-stack-logs";
// import { ShowContainerConfig } from "../config/show-container-config";
// import { ShowDockerModalLogs } from "../logs/show-docker-modal-logs";
// import { DockerTerminalModal } from "../terminal/docker-terminal-modal";
// import type { Container } from "./show-containers";
export interface ApplicationList { export interface ApplicationList {
ID: string; ID: string;
@@ -28,6 +24,7 @@ export interface ApplicationList {
DesiredState: string; DesiredState: string;
Error: string; Error: string;
Node: string; Node: string;
serverId: string;
} }
export const columns: ColumnDef<ApplicationList>[] = [ export const columns: ColumnDef<ApplicationList>[] = [
@@ -212,7 +209,37 @@ export const columns: ColumnDef<ApplicationList>[] = [
); );
}, },
cell: ({ row }) => { cell: ({ row }) => {
return <div>{row.getValue("Errors")}</div>; return <div className="w-[10rem]">{row.getValue("Errors")}</div>;
},
},
{
accessorKey: "Logs",
accessorFn: (row) => row.Error,
header: ({ column }) => {
return <span>Logs</span>;
},
cell: ({ row }) => {
return (
<span className="w-[10rem]">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" className="h-8 w-8 p-0">
<span className="sr-only">Open menu</span>
<MoreHorizontal className="h-4 w-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel>Actions</DropdownMenuLabel>
<ShowDockerModalStackLogs
containerId={row.original.ID}
serverId={row.original.serverId}
>
View Logs
</ShowDockerModalStackLogs>
</DropdownMenuContent>
</DropdownMenu>
</span>
);
}, },
}, },
]; ];

View File

@@ -89,6 +89,7 @@ export const ShowNodeApplications = ({ serverId }: Props) => {
Error: detail.Error, Error: detail.Error,
Node: detail.Node, Node: detail.Node,
Ports: detail.Ports || app.Ports, Ports: detail.Ports || app.Ports,
serverId: serverId || "",
})); }));
}); });

View File

@@ -425,7 +425,8 @@ export const getNodeApplications = async (serverId?: string) => {
const appArray = stdout const appArray = stdout
.trim() .trim()
.split("\n") .split("\n")
.map((line) => JSON.parse(line)); .map((line) => JSON.parse(line))
.filter((service) => !service.Name.startsWith('dokploy-'));
return appArray; return appArray;
} catch (error) {} } catch (error) {}
@@ -438,7 +439,7 @@ export const getApplicationInfo = async (
try { try {
let stdout = ""; let stdout = "";
let stderr = ""; let stderr = "";
const command = `docker service ps ${appName} --format '{{json .}}'`; const command = `docker service ps ${appName} --format '{{json .}}' --no-trunc`;
if (serverId) { if (serverId) {
const result = await execAsyncRemote(serverId, command); const result = await execAsyncRemote(serverId, command);