Skip to content

Commit bd88068

Browse files
display serial number on peer information and on peers table
* add serial on peers list (included in OS information to minimize informations) * permit a lookup via serial number * add serial on peer information
1 parent 25be69e commit bd88068

File tree

5 files changed

+67
-5
lines changed

5 files changed

+67
-5
lines changed

src/app/(dashboard)/peer/page.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import dayjs from "dayjs";
3131
import { isEmpty, trim } from "lodash";
3232
import {
3333
Cpu,
34+
Barcode,
3435
FlagIcon,
3536
Globe,
3637
History,
@@ -429,6 +430,17 @@ function PeerInformationCard({ peer }: { peer: Peer }) {
429430
}
430431
value={peer.os}
431432
/>
433+
434+
<Card.ListItem
435+
label={
436+
<>
437+
<Barcode size={16} />
438+
Serial Number
439+
</>
440+
}
441+
value={peer.serial_number}
442+
/>
443+
432444
<Card.ListItem
433445
label={
434446
<>
@@ -465,6 +477,7 @@ function PeerInformationCard({ peer }: { peer: Peer }) {
465477
}
466478
value={peer.ui_version?.replace("netbird-desktop-ui/", "")}
467479
/>
480+
468481
</Card.List>
469482
</Card>
470483
);

src/interfaces/Peer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ export interface Peer {
2323
city_name: string;
2424
country_code: string;
2525
connection_ip: string;
26+
serial_number: string;
2627
}

src/modules/groups/AssignPeerToGroupModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,6 @@ const PeersTableColumns: ColumnDef<Peer>[] = [
370370
header: ({ column }) => {
371371
return <DataTableHeader column={column}>OS</DataTableHeader>;
372372
},
373-
cell: ({ row }) => <PeerOSCell os={row.original.os} />,
373+
cell: ({ row }) => <PeerOSCell os={row.original.os} serial={row.original.serial_number} />,
374374
},
375375
];

src/modules/peers/PeerOSCell.tsx

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
TooltipProvider,
55
TooltipTrigger,
66
} from "@components/Tooltip";
7+
import { Barcode, Laptop } from "lucide-react";
78
import Image from "next/image";
89
import React, { useMemo } from "react";
910
import { FaWindows } from "react-icons/fa6";
@@ -14,7 +15,7 @@ import FreeBSDLogo from "@/assets/os-icons/FreeBSD.png";
1415
import { getOperatingSystem } from "@/hooks/useOperatingSystem";
1516
import { OperatingSystem } from "@/interfaces/OperatingSystem";
1617

17-
export function PeerOSCell({ os }: { os: string }) {
18+
export function PeerOSCell({ os, serial }: { os: string, serial?: string }) {
1819
return (
1920
<TooltipProvider>
2021
<Tooltip delayDuration={1}>
@@ -34,13 +35,50 @@ export function PeerOSCell({ os }: { os: string }) {
3435
</div>
3536
</TooltipTrigger>
3637
<TooltipContent>
37-
<div className={"text-neutral-300 flex flex-col gap-1"}>{os}</div>
38+
<ListItem
39+
icon={<Laptop size={14} />}
40+
label={"OS"}
41+
value={os}
42+
/>
43+
{ (serial !== undefined) &&
44+
<ListItem
45+
46+
icon={<Barcode size={14} />}
47+
label={"Serial"}
48+
value={serial}
49+
/>
50+
}
3851
</TooltipContent>
3952
</Tooltip>
4053
</TooltipProvider>
4154
);
4255
}
4356

57+
const ListItem = ({
58+
icon,
59+
label,
60+
value,
61+
}: {
62+
icon: React.ReactNode;
63+
label: string;
64+
value: string | React.ReactNode;
65+
}) => {
66+
return (
67+
<div
68+
className={
69+
"flex justify-between gap-5 border-b border-nb-gray-920 py-2 px-4 last:border-b-0 text-xs"
70+
}
71+
>
72+
<div className={"flex items-center gap-2 text-nb-gray-100 font-medium"}>
73+
{icon}
74+
{label}
75+
</div>
76+
<div className={"text-nb-gray-400"}>{value}</div>
77+
</div>
78+
);
79+
};
80+
81+
4482
export function OSLogo({ os }: { os: string }) {
4583
const icon = useMemo(() => {
4684
return getOperatingSystem(os);

src/modules/peers/PeersTable.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,20 @@ const PeersTableColumns: ColumnDef<Peer>[] = [
134134
cell: ({ row }) => <PeerLastSeenCell peer={row.original} />,
135135
},
136136
{
137+
id: "os",
137138
accessorKey: "os",
138139
header: ({ column }) => {
139140
return <DataTableHeader column={column}>OS</DataTableHeader>;
140141
},
141-
cell: ({ row }) => <PeerOSCell os={row.original.os} />,
142+
cell: ({ row }) => <PeerOSCell os={row.original.os} serial={row.original.serial_number} />,
143+
},
144+
{
145+
id: "serial",
146+
header: ({ column }) => {
147+
return <DataTableHeader column={column}>Serial number</DataTableHeader>;
148+
},
149+
accessorFn: (peer) => peer.serial_number,
150+
sortingFn: "text",
142151
},
143152
{
144153
accessorKey: "version",
@@ -241,14 +250,15 @@ export default function PeersTable({ peers, isLoading, headingTarget }: Props) {
241250
setSorting={setSorting}
242251
columns={PeersTableColumns}
243252
data={peers}
244-
searchPlaceholder={"Search by name, IP, owner or group..."}
253+
searchPlaceholder={"Search by name, IP, Serial, owner or group..."}
245254
columnVisibility={{
246255
select: !isUser,
247256
connected: false,
248257
approval_required: false,
249258
group_name_strings: false,
250259
group_names: false,
251260
ip: false,
261+
serial: false,
252262
user_name: false,
253263
user_email: false,
254264
actions: !isUser,

0 commit comments

Comments
 (0)