replace list with table

This commit is contained in:
Alex Holliday committed 2025-02-19 14:54:21 -08:00
1 parent 2d182ba9d2
commit 13a6b79df7
1 file changed
+44 -20
@@ -1,7 +1,8 @@
import { Stack, Typography, List, ListItem } from "@mui/material"; import { Stack, Typography } from "@mui/material";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import PulseDot from "../../../../../Components/Animated/PulseDot"; import PulseDot from "../../../../../Components/Animated/PulseDot";
import "flag-icons/css/flag-icons.min.css"; import "flag-icons/css/flag-icons.min.css";
import { styled } from "@mui/material/styles";
const BASE_BOX_PADDING_VERTICAL = 16; const BASE_BOX_PADDING_VERTICAL = 16;
const BASE_BOX_PADDING_HORIZONTAL = 8; const BASE_BOX_PADDING_HORIZONTAL = 8;
@@ -23,12 +24,12 @@ const DeviceTicker = ({ data, width = "100%", connectionStatus }) => {
backgroundColor: theme.palette.background.main, backgroundColor: theme.palette.background.main,
border: 1, border: 1,
borderStyle: "solid", borderStyle: "solid",
borderRadius: theme.spacing(4),
borderColor: theme.palette.primary.lowContrast, borderColor: theme.palette.primary.lowContrast,
}} }}
> >
<Stack <Stack
direction="row" direction="row"
justifyContent={"center"}
gap={theme.spacing(4)} gap={theme.spacing(4)}
> >
<PulseDot color={statusColor[connectionStatus]} /> <PulseDot color={statusColor[connectionStatus]} />
@@ -41,29 +42,52 @@ const DeviceTicker = ({ data, width = "100%", connectionStatus }) => {
{connectionStatus === "up" ? "Connected" : "No connection"} {connectionStatus === "up" ? "Connected" : "No connection"}
</Typography> </Typography>
</Stack> </Stack>
<List> <table>
{data.slice(Math.max(data.length - 5, 0)).map((dataPoint) => { <thead>
<tr>
<th style={{ textAlign: "left" }}>
<Typography>COUNTRY</Typography>
</th>
<th style={{ textAlign: "left" }}>
<Typography>CITY</Typography>
</th>
<th style={{ textAlign: "right" }}>
<Typography>RESPONSE</Typography>
</th>
<th style={{ textAlign: "right" }}>
<Typography>UPT BURNED</Typography>
</th>
</tr>
</thead>
<tbody>
{data.map((dataPoint) => {
const countryCode = dataPoint?.countryCode?.toLowerCase() ?? null; const countryCode = dataPoint?.countryCode?.toLowerCase() ?? null;
const flag = countryCode ? `fi fi-${countryCode}` : null; const flag = countryCode ? `fi fi-${countryCode}` : null;
const city = dataPoint?.city !== "" ? dataPoint?.city : "Unknown";
return ( return (
<ListItem key={Math.random()}> <tr key={Math.random()}>
<Stack direction="column"> <td style={{ padding: theme.spacing(4) }}>
<Stack <Typography>
direction="row" {flag ? <span className={flag} /> : null}{" "}
alignItems="center" {countryCode?.toUpperCase() ?? "N/A"}
gap={theme.spacing(4)} </Typography>
> </td>
{flag && <span className={flag} />} <td>
<Typography variant="h2">{dataPoint?.city || "Unknown"}</Typography> <Typography>{city}</Typography>
</Stack> </td>
<Typography variant="p">{`Response time: ${Math.floor(dataPoint?.responseTime ?? 0)} ms`}</Typography> <td style={{ textAlign: "right" }}>
<Typography variant="p">{`UPT burned: ${dataPoint.uptBurnt}`}</Typography> <Typography>{Math.floor(dataPoint.responseTime)} ms</Typography>
<Typography variant="p">{`${dataPoint?.device?.manufacturer} ${dataPoint?.device?.model}`}</Typography> </td>
</Stack> <td style={{ textAlign: "right" }}>
</ListItem> <Typography color={theme.palette.warning.main}>
+{dataPoint.uptBurnt}
</Typography>
</td>
</tr>
); );
})} })}
</List> </tbody>
</table>
</Stack> </Stack>
); );
}; };