"use client"; import { useState } from "react"; import { Activity } from "lucide-react"; import { fmtBytes } from "@/lib/utils"; import { Pagination } from "./Pagination"; interface Props { flows: any[]; ip: string; } interface ColDef { header: string; width: string; align?: "center" | "right"; } function TableWrap({ children, cols }: { children: React.ReactNode; cols: ColDef[] }) { return (
{cols.map((c) => ( ))} {children}
{c.header}
); } function Cell({ value, className = "", center = false, right = false }: { value: string | number; className?: string; center?: boolean; right?: boolean }) { const str = String(value ?? "—"); const align = center ? "text-center" : right ? "text-right" : ""; return (
{str || "—"}
); } export default function DeviceFlowsTab({ flows, ip }: Props) { const [page, setPage] = useState(1); const pageSize = 50; const totalPages = Math.ceil(flows.length / pageSize); const startIndex = (page - 1) * pageSize; const paginated = flows.slice(startIndex, startIndex + pageSize); if (flows.length === 0) { return (

No Flow Data Yet

Network flows for this IP haven't been captured or are currently being ingested. If you just started the system, please wait a few moments as data is actively being synchronized.

); } const COLS: ColDef[] = [ { header: "Time", width: "w-[130px]", align: "center" }, { header: "Source", width: "min-w-[120px]" }, { header: "Destination", width: "min-w-[120px]" }, { header: "Port", width: "w-[80px]", align: "center" }, { header: "App / Protocol", width: "min-w-[150px] w-full" }, { header: "Download", width: "w-[90px]", align: "right" }, { header: "Upload", width: "w-[90px]", align: "right" }, ]; return (
{paginated.map((f: any, i: number) => { const isOutbound = f.src_ip === ip; const timeStr = f.last_seen ? new Date(f.last_seen).toLocaleString() : '-'; return ( {f.app_label || f.protocol || '-'} ); })} {totalPages > 0 && ( )}
); }