From 8ca47fba4476b56fcd571fcd1d5a84f128ff3142 Mon Sep 17 00:00:00 2001 From: Daniel Pupius Date: Wed, 23 Apr 2025 10:57:28 -0700 Subject: [PATCH] Show Node Info in more compressed form --- web/src/components/packets/NodeInfoPacket.tsx | 89 +++++++++++-------- web/src/components/packets/PacketCard.tsx | 36 ++++---- 2 files changed, 73 insertions(+), 52 deletions(-) diff --git a/web/src/components/packets/NodeInfoPacket.tsx b/web/src/components/packets/NodeInfoPacket.tsx index ac7716c..8d28c16 100644 --- a/web/src/components/packets/NodeInfoPacket.tsx +++ b/web/src/components/packets/NodeInfoPacket.tsx @@ -2,7 +2,6 @@ import React from "react"; import { Packet } from "../../lib/types"; import { User } from "lucide-react"; import { PacketCard } from "./PacketCard"; -import { KeyValueGrid, KeyValuePair } from "./KeyValuePair"; interface NodeInfoPacketProps { packet: Packet; @@ -24,47 +23,67 @@ export const NodeInfoPacket: React.FC = ({ packet }) => { label="Node Info" backgroundColor="bg-purple-950/5" > -
- +
+ {/* First row: Long name and short name */} +
+ {nodeInfo.longName && ( +
+ {nodeInfo.longName} +
+ )} + + {nodeInfo.shortName && ( +
+ {nodeInfo.shortName} +
+ )} +
- - - {nodeInfo.id || "—"}} - /> + {/* Second row: All technical details */} +
{nodeInfo.hwModel && ( - +
+ HW: + {nodeInfo.hwModel} +
)} {nodeInfo.role && ( - - )} - {nodeInfo.batteryLevel !== undefined && ( - +
+ ROLE: + {nodeInfo.role} +
)} {nodeInfo.lastHeard && ( - +
+ LAST: + {new Date(nodeInfo.lastHeard * 1000).toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})} +
)} - + {nodeInfo.batteryLevel !== undefined && ( +
+ BAT: + {nodeInfo.batteryLevel}% +
+ )} + {nodeInfo.voltage !== undefined && ( +
+ V: + {nodeInfo.voltage.toFixed(1)}V +
+ )} + {nodeInfo.snr !== undefined && ( +
+ SNR: + {nodeInfo.snr.toFixed(1)}dB +
+ )} + {nodeInfo.channelUtilization !== undefined && ( +
+ CH: + {nodeInfo.channelUtilization.toFixed(1)}% +
+ )} +
); diff --git a/web/src/components/packets/PacketCard.tsx b/web/src/components/packets/PacketCard.tsx index 2a55d6a..7c0a81a 100644 --- a/web/src/components/packets/PacketCard.tsx +++ b/web/src/components/packets/PacketCard.tsx @@ -1,5 +1,6 @@ import React, { ReactNode } from "react"; import { Packet } from "../../lib/types"; +import { cn } from "@/lib/cn"; interface PacketCardProps { packet: Packet; @@ -21,30 +22,33 @@ export const PacketCard: React.FC = ({ const { data } = packet; return ( -
+
{/* Card Header with all metadata */} -
+
{/* Left side: Icon, From, Channel */}
-
- {React.cloneElement(icon as React.ReactElement, { - className: "h-3.5 w-3.5 text-white" +
+ {React.cloneElement(icon as React.ReactElement, { + className: "h-3.5 w-3.5 text-white", })}
- {data.from ? `!${data.from.toString(16).toLowerCase()}` : "Unknown"} - - - Channel: {packet.info.channel} + {data.from + ? `!${data.from.toString(16).toLowerCase()}` + : "Unknown"} + {packet.info.channel}
- + {/* Right side: ID and Type */}
- - ID: {data.id || "None"} - + {data.id || "None"} {label} @@ -53,9 +57,7 @@ export const PacketCard: React.FC = ({
{/* Card Content */} -
- {children} -
+
{children}
); -}; \ No newline at end of file +};