Node status checking

This commit is contained in:
2025-12-29 19:49:37 +01:00
parent 98c8e86872
commit 4d18edcffe
10 changed files with 59 additions and 95 deletions
+1 -2
View File
@@ -4,7 +4,6 @@ import { DashboardLayout } from "@/components/dashboard/DashboardLayout";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { StatusIndicator } from "@/components/dashboard/StatusIndicator";
import { Play, Square, RotateCcw, MoreVertical, Plus } from "lucide-react";
import { Progress } from "@/components/ui/progress";
@@ -111,7 +110,7 @@ export default function ApplicationsPage() {
<div className="grid grid-cols-1 md:grid-cols-12 gap-4 md:items-center">
{/* Status & Name */}
<div className="flex items-center gap-3 md:col-span-3">
<StatusIndicator status={app.status} />
{/* {app.status} */}
<div className="min-w-0">
<div className="font-mono text-sm font-medium">
{app.name}
+2 -5
View File
@@ -4,7 +4,6 @@ import { DashboardLayout } from "@/components/dashboard/DashboardLayout";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { StatusIndicator } from "@/components/dashboard/StatusIndicator";
import { Terminal, MoreVertical, Play, Square, Trash2 } from "lucide-react";
const containers = [
@@ -184,9 +183,7 @@ export default function ContainersPage() {
<Badge>{container.node}</Badge>
</td>
<td className="py-3 px-4">
<StatusIndicator status={container.status} showLabel />
</td>
<td className="py-3 px-4">{/* {container.status} */}</td>
<td className="py-3 px-4 font-mono text-xs">
{container.uptime}
@@ -235,7 +232,7 @@ export default function ContainersPage() {
<Terminal className="w-4 h-4 text-muted-foreground" />
<span className="font-mono text-sm">{container.name}</span>
</div>
<StatusIndicator status={container.status} />
{/* {container.status} */}
</div>
<div className="text-[10px] font-mono text-muted-foreground">
+2 -5
View File
@@ -4,7 +4,6 @@ import { DashboardLayout } from "@/components/dashboard/DashboardLayout";
import { Card, CardContent } from "@/components/ui/card";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { StatusIndicator } from "@/components/dashboard/StatusIndicator";
import {
Rocket,
RotateCcw,
@@ -153,9 +152,7 @@ export default function DeploymentsPage() {
</div>
</td>
<td className="py-3 px-4">
<StatusIndicator status={dep.status} showLabel />
</td>
<td className="py-3 px-4">{dep.status}</td>
<td className="py-3 px-4 font-mono text-sm">
{dep.replicas}
@@ -201,7 +198,7 @@ export default function DeploymentsPage() {
<Rocket className="w-4 h-4 text-muted-foreground" />
<span className="font-mono text-sm">{dep.app}</span>
</div>
<StatusIndicator status={dep.status} />
{dep.status}
</div>
<div className="flex items-center gap-2 text-xs">
+2 -2
View File
@@ -56,8 +56,8 @@ export default function MonitoringPage() {
const fetchNodes = async () => {
const nodes = await getLiveNodes();
setLiveData({
cpuUsage: average(nodes, (n) => n.liveData.cpu.usage),
ramUsage: average(nodes, (n) => n.liveData.memory.usage),
cpuUsage: average(nodes, (n) => n.liveData?.cpu.usage || 0),
ramUsage: average(nodes, (n) => n.liveData?.memory.usage || 0),
});
};
fetchNodes();
+20 -13
View File
@@ -8,12 +8,15 @@ import { Server, Plus, Settings, Trash2 } from "lucide-react";
import { Progress } from "@/components/ui/progress";
import { Docker, Node, NodeLiveData } from "@/lib/types";
import { useEffect, useState } from "react";
import { getDockerNode, getLiveNodes } from "@/core/node";
import { getLiveNodes } from "@/core/node";
import { formatBytes } from "@/lib/format";
import { setNodes as updateNodes } from "@/core/node";
import AddNode from "@/components/dialogs/AddNode";
import { getDocker } from "@/core/docker";
function DiskUsage({ liveData }: NodeLiveData) {
if (!liveData) return null;
const usage = (liveData.disk.used / liveData.disk.size) * 100;
return (
@@ -44,7 +47,7 @@ export default function NodesPage() {
useEffect(() => {
const fetchDocker = async () => {
setDockerNodes(await Promise.all(nodes.map(getDockerNode)));
setDockerNodes(await getDocker(nodes));
};
fetchDocker();
}, [nodes]);
@@ -54,9 +57,7 @@ export default function NodesPage() {
<div className="flex flex-col sm:flex-row items-start sm:items-center justify-between mb-6 gap-2">
<div className="flex flex-wrap items-center gap-2">
<Badge>{nodes.length} nodes</Badge>
<Badge>
{/* {nodes.filter((n) => n.status === "running").length} online */}
</Badge>
<Badge>{nodes.filter((node) => node.liveData).length} online</Badge>
</div>
<AddNode>
<Button size="sm" className="gap-2">
@@ -75,8 +76,12 @@ export default function NodesPage() {
</div>
<div>
<div className="flex items-center gap-2 flex-wrap">
{/* <StatusIndicator status={node.status} /> */}
<CardTitle className="font-mono">{node.name}</CardTitle>
{node.liveData ? (
<span className="size-2 rounded-full bg-chart-2" />
) : (
<span className="size-2 rounded-full bg-chart-5" />
)}
</div>
<div className="text-xs text-muted-foreground font-mono">
{node.ip} • {node.ip}
@@ -135,13 +140,13 @@ export default function NodesPage() {
{/* CPU */}
<div>
<div className="text-xs text-muted-foreground mb-2">
CPU ({node.liveData.cpu.cores} cores)
CPU ({node.liveData?.cpu.cores} cores)
</div>
<div className="stat-value mb-2">
{node.liveData.cpu.usage.toFixed(0)}%
{node.liveData?.cpu.usage.toFixed(0)}%
</div>
<Progress
value={node.liveData.cpu.usage}
value={node.liveData?.cpu.usage}
className="w-full"
/>
</div>
@@ -152,15 +157,17 @@ export default function NodesPage() {
Memory
</div>
<div className="stat-value mb-2">
{node.liveData.memory.usage.toFixed(0)}%
{node.liveData?.memory.usage.toFixed(0)}%
</div>
<Progress
value={node.liveData.memory.usage}
value={node.liveData?.memory.usage}
className="w-full"
/>
<div className="text-[10px] text-muted-foreground mt-1 font-mono">
{formatBytes(node.liveData.memory.used)} /{" "}
{formatBytes(node.liveData.memory.total)}
{node.liveData &&
formatBytes(node.liveData?.memory.used) +
"/" +
formatBytes(node.liveData?.memory.total)}
</div>
</div>
+11 -10
View File
@@ -5,7 +5,6 @@ import { StatCard } from "@/components/dashboard/StatCard";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { StatusIndicator } from "@/components/dashboard/StatusIndicator";
import {
Box,
Server,
@@ -178,9 +177,7 @@ export default function OverviewPage() {
{app.memory}%
</span>
</div>
<div className="col-span-2">
<StatusIndicator status={app.status} showLabel />
</div>
<div className="col-span-2">{app.status}</div>
</div>
))}
</div>
@@ -205,7 +202,7 @@ export default function OverviewPage() {
className="flex flex-col sm:flex-row sm:items-center sm:justify-between py-2 border-b border-border last:border-0"
>
<div className="flex items-center gap-3">
<StatusIndicator status={dep.status} size="sm" />
{dep.status}
<div>
<div className="font-mono text-sm">{dep.app}</div>
<div className="text-xs text-muted-foreground">
@@ -235,7 +232,11 @@ export default function OverviewPage() {
<div key={i} className="border border-border p-4 bg-secondary/30">
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between mb-3 gap-2">
<div className="flex items-center gap-2">
<StatusIndicator status={"running"} />
{node.liveData ? (
<span className="size-2 rounded-full bg-chart-2" />
) : (
<span className="size-2 rounded-full bg-chart-5" />
)}
<span className="font-mono text-sm">{node.name}</span>
</div>
<span className="text-xs text-muted-foreground font-mono">
@@ -246,21 +247,21 @@ export default function OverviewPage() {
<div className="flex items-center justify-between text-xs">
<span className="text-muted-foreground">CPU</span>
<span className="font-mono">
{node.liveData.cpu.usage.toFixed(0)}%
{node.liveData?.cpu.usage.toFixed(0)}%
</span>
</div>
<Progress
value={node.liveData.cpu.usage}
value={node.liveData?.cpu.usage}
className="[&>div]:bg-chart-1"
/>
<div className="flex items-center justify-between text-xs">
<span className="text-muted-foreground">Memory</span>
<span className="font-mono">
{node.liveData.memory.usage.toFixed(0)}%
{node.liveData?.memory.usage.toFixed(0)}%
</span>
</div>
<Progress
value={node.liveData.memory.usage}
value={node.liveData?.memory.usage}
className="w-full [&>div]:bg-chart-3"
/>
<div className="flex items-center justify-between text-xs pt-2 border-t border-border mt-2">