From aabb55b43c9562115d9cc3f0f9af86720a2fbafa Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Sat, 14 Feb 2026 14:44:42 +0100 Subject: [PATCH] Redeploy --- src/app/deployments/page.tsx | 25 ++++++++++++++++++++----- src/components/dialogs/DeployApp.tsx | 8 ++++++-- src/lib/dockship/deploy.ts | 6 ++++-- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/app/deployments/page.tsx b/src/app/deployments/page.tsx index 4bbb912..052974b 100644 --- a/src/app/deployments/page.tsx +++ b/src/app/deployments/page.tsx @@ -10,13 +10,14 @@ import { } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; -import { Plus, Play, Pause, Square } from "lucide-react"; +import { Plus, Play, Pause, Square, RotateCcw } from "lucide-react"; import { getDeployments, toggleDeployment } from "@/lib/dockship/deploy"; import { getApps } from "@/lib/dockship/application"; import { cn } from "@/lib/utils"; import DeployAppDialog from "@/components/dialogs/DeployApp"; import { useAsync, useAsyncInterval } from "@/hooks/use-async"; import RemoveDialog from "@/components/dialogs/Remove"; +import { Application } from "@/lib/types"; const statusDot = { running: "bg-chart-2", @@ -34,11 +35,11 @@ export default function DeploymentsPage() { [apps], ); - const appNameByContainer = useMemo(() => { - const map = new Map(); + const appByContainer = useMemo(() => { + const map = new Map(); for (const app of apps) { for (const container of app.deployments) { - map.set(container, app.name); + map.set(container, app); } } return map; @@ -90,7 +91,8 @@ export default function DeploymentsPage() { {dep.name} @{" "} - {appNameByContainer.get(dep.container) ?? "Unknown app"} + {appByContainer.get(dep.container)?.name ?? + "Unknown app"} @@ -123,6 +125,19 @@ export default function DeploymentsPage() { )} + ({ + containerPort: from.toString(), + hostPort: to.toString(), + protocol: "tcp", + }))} + nodeId={dep.nodeId} + > + + {}} /> diff --git a/src/components/dialogs/DeployApp.tsx b/src/components/dialogs/DeployApp.tsx index 5c48506..b91d80e 100644 --- a/src/components/dialogs/DeployApp.tsx +++ b/src/components/dialogs/DeployApp.tsx @@ -24,17 +24,21 @@ import { Plus } from "lucide-react"; export default function DeployAppDialog({ defaultApp, children, + ports: initialPorts, + nodeId: defaultNode, }: { defaultApp?: string; + nodeId?: string; + ports?: Port[]; children: ReactNode; }) { const { value: nodes } = useAsync("liveNodes", [], getLiveNodes); const { value: apps } = useAsync("apps", [], getApps); const [name, setName] = useState(""); const [app, setApp] = useState(defaultApp || ""); - const [node, setNode] = useState(""); + const [node, setNode] = useState(defaultNode || ""); - const [ports, setPorts] = useState([]); + const [ports, setPorts] = useState(initialPorts || []); const [newPort, setNewPort] = useState({ containerPort: "", hostPort: "", diff --git a/src/lib/dockship/deploy.ts b/src/lib/dockship/deploy.ts index 0c2fb87..0ba8a02 100644 --- a/src/lib/dockship/deploy.ts +++ b/src/lib/dockship/deploy.ts @@ -5,7 +5,9 @@ import { getNodes } from "./node"; import axios from "axios"; import { editApp, getApp, getApps } from "./application"; -export async function getDeployments(): Promise { +export async function getDeployments(): Promise< + (Deployment & { nodeId: string })[] +> { const nodes = await getNodes(); const apps = await getApps(); @@ -17,7 +19,7 @@ export async function getDeployments(): Promise { await axios.post(`http://${n.ip}:3000/api/get-deployments`, apps, { headers: { Authorization: `ApiKey ${n.key}` }, }) - ).data.deployments, + ).data.deployments.map((d: any) => ({ ...d, nodeId: n.node_id })), ), ) ).flat();