diff --git a/apps/dokploy/components/dashboard/docker/terminal/docker-terminal.tsx b/apps/dokploy/components/dashboard/docker/terminal/docker-terminal.tsx index d150774e7..842509bc0 100644 --- a/apps/dokploy/components/dashboard/docker/terminal/docker-terminal.tsx +++ b/apps/dokploy/components/dashboard/docker/terminal/docker-terminal.tsx @@ -4,7 +4,6 @@ import { FitAddon } from "xterm-addon-fit"; import "@xterm/xterm/css/xterm.css"; import { AttachAddon } from "@xterm/addon-attach"; import { useTheme } from "next-themes"; -import { Label } from "@/components/ui/label"; import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; interface Props { @@ -38,48 +37,30 @@ export const DockerTerminal: React.FC = ({ }, }); const addonFit = new FitAddon(); + const protocol = window.location.protocol === "https:" ? "wss:" : "ws:"; + + const wsUrl = `${protocol}//${window.location.host}/docker-container-terminal?containerId=${containerId}&activeWay=${activeWay}${serverId ? `&serverId=${serverId}` : ""}`; + + const ws = new WebSocket(wsUrl); + + const addonAttach = new AttachAddon(ws); // @ts-ignore term.open(termRef.current); // @ts-ignore term.loadAddon(addonFit); + term.loadAddon(addonAttach); addonFit.fit(); - - // only connect if containerId is provided - if ( - containerId && - containerId !== "" && - containerId !== "select-a-container" - ) { - const protocol = window.location.protocol === "https:" ? "wss:" : "ws:"; - - const wsUrl = `${protocol}//${window.location.host}/docker-container-terminal?containerId=${containerId}&activeWay=${activeWay}${serverId ? `&serverId=${serverId}` : ""}`; - - const ws = new WebSocket(wsUrl); - - const addonAttach = new AttachAddon(ws); - - term.loadAddon(addonAttach); - - ws.onopen = () => { - setIsConnected(true); - }; - - ws.onclose = () => { - setIsConnected(false); - }; - - return () => { - ws.readyState === WebSocket.OPEN && ws.close(); - }; - } + return () => { + ws.readyState === WebSocket.OPEN && ws.close(); + }; }, [containerId, activeWay, id]); return (
- + + Select way to connect to {containerId} + Bash