Skip to content

Commit

Permalink
Merge pull request #989 from Dokploy/refactor/add-no-trunc
Browse files Browse the repository at this point in the history
Refactor/add no trunc
  • Loading branch information
Siumauricio authored Dec 25, 2024
2 parents 566d9e0 + 5c1993a commit 229a9a3
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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>
);
};
39 changes: 33 additions & 6 deletions apps/dokploy/components/dashboard/swarm/applications/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import {
} from "@/components/ui/dropdown-menu";

import { Badge } from "@/components/ui/badge";
import { ShowNodeConfig } from "../details/show-node-config";
// 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";
import { ShowDockerModalStackLogs } from "../../docker/logs/show-docker-modal-stack-logs";

export interface ApplicationList {
ID: string;
Expand All @@ -28,6 +24,7 @@ export interface ApplicationList {
DesiredState: string;
Error: string;
Node: string;
serverId: string;
}

export const columns: ColumnDef<ApplicationList>[] = [
Expand Down Expand Up @@ -212,7 +209,37 @@ export const columns: ColumnDef<ApplicationList>[] = [
);
},
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>
);
},
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const ShowNodeApplications = ({ serverId }: Props) => {
Error: detail.Error,
Node: detail.Node,
Ports: detail.Ports || app.Ports,
serverId: serverId || "",
}));
});

Expand Down
5 changes: 3 additions & 2 deletions packages/server/src/services/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ export const getNodeApplications = async (serverId?: string) => {
const appArray = stdout
.trim()
.split("\n")
.map((line) => JSON.parse(line));
.map((line) => JSON.parse(line))
.filter((service) => !service.Name.startsWith('dokploy-'));

return appArray;
} catch (error) {}
Expand All @@ -438,7 +439,7 @@ export const getApplicationInfo = async (
try {
let stdout = "";
let stderr = "";
const command = `docker service ps ${appName} --format '{{json .}}'`;
const command = `docker service ps ${appName} --format '{{json .}}' --no-trunc`;

if (serverId) {
const result = await execAsyncRemote(serverId, command);
Expand Down

0 comments on commit 229a9a3

Please sign in to comment.