feat: monitor connected Wi-Fi signal per interface (#2367)

This commit is contained in:
Vito Cappello
2026-09-25 17:43:57 -04:00
committed by GitHub
parent badd4c8245
commit 86ab0fae8b
24 changed files with 814 additions and 0 deletions

View File

@@ -38,6 +38,7 @@ import {
secondsToUptimeString,
} from "@/lib/utils"
import { batteryStateTranslations } from "@/lib/i18n"
import { connectedWiFi, strongestWiFiSignal } from "@/lib/wifi"
import type { SystemRecord } from "@/types"
import { SystemDialog } from "../add-system"
import AlertButton from "../alerts/alert-button"
@@ -346,6 +347,46 @@ export function SystemsTableColumns(viewMode: "table" | "grid"): ColumnDef<Syste
)
},
},
{
accessorFn: strongestWiFiSignal,
id: "wifi",
name: () => t`Wi-Fi`,
size: 80,
Icon: WifiIcon,
header: sortableHeader,
hideSort: true,
sortUndefined: "last",
cell(info) {
const connections = connectedWiFi(info.row.original)
if (!connections.length) {
return null
}
const strongest = connections.reduce((best, current) =>
(current[1].r ?? Number.NEGATIVE_INFINITY) > (best[1].r ?? Number.NEGATIVE_INFINITY) ? current : best
)
const displayedConnections = viewMode === "table" ? [strongest] : connections
const title = connections
.map(([id, wifi]) => `${id}${wifi.s ? ` (${wifi.s})` : ""}: ${wifi.r === undefined ? "—" : `${wifi.r} dBm`}`)
.join("\n")
return (
<Link
href={getPagePath($router, "system", { id: info.row.original.id })}
tabIndex={-1}
className="flex flex-col gap-0.5 min-w-0 py-1 relative z-10"
title={title}
>
{displayedConnections.map(([id, wifi]) => (
<span key={id} className="tabular-nums whitespace-nowrap">
{wifi.r === undefined ? "—" : `${wifi.r} dBm`}
</span>
))}
{viewMode === "table" && connections.length > 1 && (
<span className="text-xs text-muted-foreground">+{connections.length - 1}</span>
)}
</Link>
)
},
},
{
accessorFn: ({ info }) => info.sv?.[0],
id: "services",