diff --git a/src/components/form/IPInput.tsx b/src/components/form/IPInput.tsx index b21bfd20..ba832b81 100755 --- a/src/components/form/IPInput.tsx +++ b/src/components/form/IPInput.tsx @@ -38,7 +38,12 @@ export const IPInput = forwardRef(function Input( return (
- + setNumericalValue(parseInt(e.target.value))} + ref={ref} + hidden + /> { diff --git a/src/components/generic/Table/index.tsx b/src/components/generic/Table/index.tsx new file mode 100755 index 00000000..884aa66a --- /dev/null +++ b/src/components/generic/Table/index.tsx @@ -0,0 +1,53 @@ +import { ChevronUpIcon } from "@heroicons/react/24/outline"; + +export interface TableProps { + headings: Heading[]; + rows: JSX.Element[][]; +} + +export interface Heading { + title: string; + type: "blank" | "normal"; + sortable: boolean; +} + +export const Table = ({ headings, rows }: TableProps): JSX.Element => { + return ( + + + + {headings.map((heading, index) => ( + + ))} + + + + {rows.map((row, index) => ( + + {row.map((item, index) => ( + + ))} + + ))} + +
+
+ {heading.title} + {heading.sortable && } +
+
+ {item} +
+ ); +}; diff --git a/src/components/generic/Table/tmp/TimeAgo.tsx b/src/components/generic/Table/tmp/TimeAgo.tsx new file mode 100755 index 00000000..32a766ff --- /dev/null +++ b/src/components/generic/Table/tmp/TimeAgo.tsx @@ -0,0 +1,9 @@ +import TimeAgoReact from "timeago-react"; + +export interface TimeAgoProps { + timestamp: number; +} + +export const TimeAgo = ({ timestamp }: TimeAgoProps): JSX.Element => { + return ; +}; diff --git a/src/pages/Peers.tsx b/src/pages/Peers.tsx index b8d0449c..e3b932c2 100644 --- a/src/pages/Peers.tsx +++ b/src/pages/Peers.tsx @@ -1,122 +1,53 @@ import type React from "react"; -import toast from "react-hot-toast"; import { base16 } from "rfc4648"; -import { IconButton } from "@app/components/form/IconButton.js"; -import { Mono } from "@app/components/generic/Mono.js"; +import { Mono } from "@components/generic/Mono.js"; +import { Table } from "@components/generic/Table"; +import { TimeAgo } from "@components/generic/Table/tmp/TimeAgo.js"; import { useDevice } from "@core/providers/useDevice.js"; import { Hashicon } from "@emeraldpay/hashicon-react"; -import { - ArrowPathRoundedSquareIcon, - EllipsisHorizontalIcon -} from "@heroicons/react/24/outline"; import { Protobuf } from "@meshtastic/meshtasticjs"; -import TimeAgo from "timeago-react"; export const PeersPage = (): JSX.Element => { const { connection, nodes } = useDevice(); return (
- - - - - - - - - - - - - - {nodes.map((node, index) => ( - - - - - - - - - - ))} - -
- Name - - Model - - MAC Address - - Versions - - Last Heard - - SNR - - Edit -
- - - {node.data.user?.longName ?? - `Meshtastic_${base16 - .stringify(node.data.user?.macaddr.subarray(4, 6) ?? []) - .toLowerCase()}`} - - - - - {Protobuf.HardwareModel[node.data.user?.hwModel ?? 0]} - - - - - {base16 - .stringify(node.data.user?.macaddr ?? []) - .match(/.{1,2}/g) - ?.join(":") ?? ""} - - - {node.metadata ? ( - <> - {node.metadata.firmwareVersion} - / - {node.metadata.deviceStateVersion} - - ) : ( - { - if (connection) { - void toast.promise( - connection.getMetadata({ nodeNum: node.data.num }), - { - loading: "Requesting Metadata...", - success: "Recieved Metadata", - error: "No response received" - } - ); - } - }} - icon={} - /> - )} - - - - {node.data.snr}db - - } - /> -
+ [ + , +

+ {node.data.user?.longName ?? node.data.user?.macaddr + ? `Meshtastic_${base16 + .stringify(node.data.user?.macaddr.subarray(4, 6) ?? []) + .toLowerCase()}` + : `UNK: ${node.data.num}`} +

, + + {Protobuf.HardwareModel[node.data.user?.hwModel ?? 0]}, + + {base16 + .stringify(node.data.user?.macaddr ?? []) + .match(/.{1,2}/g) + ?.join(":") ?? "UNK"} + , + , + + {node.data.snr}db/ + {Math.min(Math.max((node.data.snr + 10) * 5, 0), 100)}%/ + {(node.data.snr + 10) * 5}raw + + ])} + /> ); };