diff --git a/app/components/dashboard/DashboardCardNetwork/DashboardCardNetwork.server.tsx b/app/components/dashboard/DashboardCardNetwork/DashboardCardNetwork.server.tsx
index bfdf8cc..df4ec7b 100644
--- a/app/components/dashboard/DashboardCardNetwork/DashboardCardNetwork.server.tsx
+++ b/app/components/dashboard/DashboardCardNetwork/DashboardCardNetwork.server.tsx
@@ -1,13 +1,25 @@
import SpeedMeter from './SpeedMeter.client';
import { getUptime } from '@/lib/get-uptime';
import DashboardUptime from './DashboardUptime.client';
+import { db } from '@/lib/db';
+import PerUserSpeedDetails from './PerUserSpeedDetails.client';
+
+type ipToName = {
+ index_number: number;
+ ip: string;
+ name: string;
+ display_name: string;
+}[];
export default async function DashboardCardNetWork() {
let uptime = await getUptime();
+ let allUsers = db
+ .prepare('SELECT index_number, ip, name, display_name FROM users')
+ .all() as ipToName;
return (
<>
-
+
@@ -24,6 +36,7 @@ export default async function DashboardCardNetWork() {
maxSpeed={parseInt(process.env.MAX_UPLOAD_SPEED || '15')}
/>
+
diff --git a/app/components/dashboard/DashboardCardNetwork/PerUserSpeedDetails.client.tsx b/app/components/dashboard/DashboardCardNetwork/PerUserSpeedDetails.client.tsx
new file mode 100644
index 0000000..b14313b
--- /dev/null
+++ b/app/components/dashboard/DashboardCardNetwork/PerUserSpeedDetails.client.tsx
@@ -0,0 +1,144 @@
+'use client';
+import { useAtomValue } from 'jotai';
+import { allSpeedStates } from '../../boundaries/SpeedBoundarie.client';
+import { useRef } from 'react';
+
+export default function PerUserSpeedDetails({
+ allUsers
+}: {
+ allUsers: {
+ index_number: number;
+ ip: string;
+ name: string;
+ display_name: string;
+ }[];
+}) {
+ const perUserSpeedModal = useRef(
+ null
+ ) as unknown as React.MutableRefObject;
+ return (
+ <>
+
+
perUserSpeedModal.current?.showModal()}
+ className="mt-2 w-5/6"
+ >
+ Show Details
+
+
+
+ >
+ );
+}
+
+function PerUserSpeedDetailsPopUp({
+ allUsers,
+ perUserSpeedModal
+}: {
+ allUsers: {
+ index_number: number;
+ ip: string;
+ name: string;
+ display_name: string;
+ }[];
+ perUserSpeedModal: React.MutableRefObject;
+}) {
+ function closePopUp() {
+ perUserSpeedModal.current?.close();
+ }
+ const allSpeeds = useAtomValue(allSpeedStates);
+ if (!allSpeeds[0].length)
+ return (
+ <>
+
+ >
+ );
+ const ipToName = allSpeeds[0].map((user) => {
+ const name = allUsers.filter((u) => u.ip === user.ip)[0];
+ if (!name) return;
+ if (Number(user.in) <= 0 && Number(user.out) <= 0) return;
+ return {
+ index_number: name.index_number,
+ name: name.name == 'Unknown' ? name.display_name : name.name,
+ in: user.in,
+ out: user.out
+ };
+ });
+ const ipToNameFiltered = ipToName.filter((u) => u !== undefined) as {
+ index_number: number;
+ name: string;
+ in: string;
+ out: string;
+ }[];
+ ipToNameFiltered.sort((a, b) => a.index_number - b.index_number);
+ return (
+ <>
+
+ >
+ );
+}