reorder columns in Nodes page

This commit is contained in:
bkimmel
2025-03-19 17:50:20 -04:00
parent ed13af2382
commit 28cc7b9800
+48 -44
View File
@@ -19,12 +19,17 @@ export interface DeleteNoteDialogProps {
onOpenChange: (open: boolean) => void; onOpenChange: (open: boolean) => void;
} }
function shortNameFromNode(node: ReturnType<useDevice>["nodes"][number]): string { function shortNameFromNode(
const shortNameOfNode = node.user?.shortName ?? (node.user?.macaddr node: ReturnType<useDevice>["nodes"][number],
? `${base16 ): string {
.stringify(node.user?.macaddr.subarray(4, 6) ?? []) const shortNameOfNode = node.user?.shortName ??
.toLowerCase()}` (node.user?.macaddr
: `${numberToHexUnpadded(node.num).slice(-4)}`); ? `${
base16
.stringify(node.user?.macaddr.subarray(4, 6) ?? [])
.toLowerCase()
}`
: `${numberToHexUnpadded(node.num).slice(-4)}`);
return String(shortNameOfNode); return String(shortNameOfNode);
} }
@@ -72,7 +77,6 @@ const NodesPage = (): JSX.Element => {
}; };
}, [connection]); }, [connection]);
const handleLocation = useCallback( const handleLocation = useCallback(
(location: Types.PacketMetadata<Protobuf.Mesh.Position>) => { (location: Types.PacketMetadata<Protobuf.Mesh.Position>) => {
if (location.to.valueOf() !== hardware.myNodeNum) return; if (location.to.valueOf() !== hardware.myNodeNum) return;
@@ -99,12 +103,12 @@ const NodesPage = (): JSX.Element => {
headings={[ headings={[
{ title: "", type: "blank", sortable: false }, { title: "", type: "blank", sortable: false },
{ title: "Long Name", type: "normal", sortable: true }, { title: "Long Name", type: "normal", sortable: true },
{ title: "Connection", type: "normal", sortable: true },
{ title: "Last Heard", type: "normal", sortable: true },
{ title: "Encryption", type: "normal", sortable: false },
{ title: "SNR", type: "normal", sortable: true },
{ title: "Model", type: "normal", sortable: true }, { title: "Model", type: "normal", sortable: true },
{ title: "MAC Address", type: "normal", sortable: true }, { title: "MAC Address", type: "normal", sortable: true },
{ title: "Last Heard", type: "normal", sortable: true },
{ title: "SNR", type: "normal", sortable: true },
{ title: "Encryption", type: "normal", sortable: false },
{ title: "Connection", type: "normal", sortable: true },
]} ]}
rows={filteredNodes.map((node) => [ rows={filteredNodes.map((node) => [
<div key={node.num}> <div key={node.num}>
@@ -113,19 +117,47 @@ const NodesPage = (): JSX.Element => {
<h1 <h1
key="longName" key="longName"
onMouseDown={() => setSelectedNode(node)} onMouseDown={() => setSelectedNode(node)}
onKeyUp={(evt)=>{ evt.key === "Enter" && setSelectedNode(node) }} onKeyUp={(evt) => {
evt.key === "Enter" && setSelectedNode(node);
}}
className="cursor-pointer underline" className="cursor-pointer underline"
tabIndex={0} tabIndex={0}
role="button" role="button"
> >
{node.user?.longName ?? {node.user?.longName ??
(node.user?.macaddr (node.user?.macaddr
? `Meshtastic ${base16 ? `Meshtastic ${
.stringify(node.user?.macaddr.subarray(4, 6) ?? []) base16
.toLowerCase()}` .stringify(node.user?.macaddr.subarray(4, 6) ?? [])
.toLowerCase()
}`
: `!${numberToHexUnpadded(node.num)}`)} : `!${numberToHexUnpadded(node.num)}`)}
</h1>, </h1>,
<Mono key="hops">
{node.lastHeard !== 0
? node.viaMqtt === false && node.hopsAway === 0
? "Direct"
: `${node.hopsAway?.toString()} ${
node.hopsAway > 1 ? "hops" : "hop"
} away`
: "-"}
{node.viaMqtt === true ? ", via MQTT" : ""}
</Mono>,
<Mono key="lastHeard">
{node.lastHeard === 0
? <p>Never</p>
: <TimeAgo timestamp={node.lastHeard * 1000} />}
</Mono>,
<Mono key="pki">
{node.user?.publicKey && node.user?.publicKey.length > 0
? <LockIcon className="text-green-600 mx-auto" />
: <LockOpenIcon className="text-yellow-300 mx-auto" />}
</Mono>,
<Mono key="snr">
{node.snr}db/
{Math.min(Math.max((node.snr + 10) * 5, 0), 100)}%/
{(node.snr + 10) * 5}raw
</Mono>,
<Mono key="model"> <Mono key="model">
{Protobuf.Mesh.HardwareModel[node.user?.hwModel ?? 0]} {Protobuf.Mesh.HardwareModel[node.user?.hwModel ?? 0]}
</Mono>, </Mono>,
@@ -135,34 +167,6 @@ const NodesPage = (): JSX.Element => {
.match(/.{1,2}/g) .match(/.{1,2}/g)
?.join(":") ?? "UNK"} ?.join(":") ?? "UNK"}
</Mono>, </Mono>,
<Mono key="lastHeard">
{node.lastHeard === 0 ? (
<p>Never</p>
) : (
<TimeAgo timestamp={node.lastHeard * 1000} />
)}
</Mono>,
<Mono key="snr">
{node.snr}db/
{Math.min(Math.max((node.snr + 10) * 5, 0), 100)}%/
{(node.snr + 10) * 5}raw
</Mono>,
<Mono key="pki">
{node.user?.publicKey && node.user?.publicKey.length > 0 ? (
<LockIcon className="text-green-600 mx-auto" />
) : (
<LockOpenIcon className="text-yellow-300 mx-auto" />
)}
</Mono>,
<Mono key="hops">
{node.lastHeard !== 0
? node.viaMqtt === false && node.hopsAway === 0
? "Direct"
: `${node.hopsAway?.toString()} ${node.hopsAway > 1 ? "hops" : "hop"
} away`
: "-"}
{node.viaMqtt === true ? ", via MQTT" : ""}
</Mono>,
])} ])}
/> />
<NodeOptionsDialog <NodeOptionsDialog