"use client"; 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 { Play, Square, MoreVertical, Plus, Rocket } from "lucide-react"; import { Progress } from "@/components/ui/progress"; import InstallApplicationDialog from "@/components/dialogs/InstallApplication"; import { useEffect, useState } from "react"; import { ImageApp } from "@/lib/types"; import { getApplications, removeApp } from "@/core/application"; import RemoveDialog from "@/components/dialogs/Remove"; export default function ApplicationsPage() { const [applications, setApplications] = useState([]); useEffect(() => { const fetch = async () => { setApplications(await getApplications()); }; fetch(); const iid = setInterval(fetch, 3000); return () => clearInterval(iid); }, []); const remove = async (appId: string) => { await removeApp(appId); setApplications((prev) => prev.filter((app) => app.id !== appId)); }; return ( {/* Header */}
{applications.length} apps {applications.filter((a) => a.status === "running").length} running
{applications.map((app, i) => (
{/* Status & Name */}
{/* {app.status} */}
{app.app?.name || app.name}
{app.image}
{/* Containers */}
Containers
{app.replicas}
{/* CPU */}
CPU
{app.cpu.toFixed(1)}%
{/* Memory */}
Memory
{app.memory.toFixed(1)}%
{/* Network */}
Network
{app.network}
{/* Ports */}
Ports
{app.ports?.length > 0 ? ( app.ports.map((port) => ( {port} )) ) : ( — )}
{/* Actions */}
{app.status === "running" ? ( ) : ( )} app.app?.id && remove(app.app?.id)} />
))}
); }