From caf05d9126af1421d23beea401a10f7c3695327f Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 3 Oct 2024 20:52:05 +0200 Subject: [PATCH] Display log events --- central_frontend/src/routes/LogsRoute.tsx | 51 ++++++++++++++++++- .../src/widgets/SolarEnergyRouteContainer.tsx | 9 +++- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/central_frontend/src/routes/LogsRoute.tsx b/central_frontend/src/routes/LogsRoute.tsx index 12c37f1..192264e 100644 --- a/central_frontend/src/routes/LogsRoute.tsx +++ b/central_frontend/src/routes/LogsRoute.tsx @@ -1,7 +1,18 @@ import NavigateBeforeIcon from "@mui/icons-material/NavigateBefore"; import NavigateNextIcon from "@mui/icons-material/NavigateNext"; import RefreshIcon from "@mui/icons-material/Refresh"; -import { IconButton, Tooltip } from "@mui/material"; +import { + IconButton, + Paper, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + Tooltip, + Typography, +} from "@mui/material"; import { DatePicker } from "@mui/x-date-pickers"; import dayjs from "dayjs"; import React from "react"; @@ -41,6 +52,7 @@ export function LogsRoute(): React.ReactElement { display: "flex", alignItems: "center", justifyContent: "center", + marginBottom: "10px", }} > @@ -71,5 +83,40 @@ export function LogsRoute(): React.ReactElement { } function LogsView(p: { logs: LogEntry[] }): React.ReactElement { - return "TODO : show logs"; + if (p.logs.length == 0) { + return ( + + There was no log recorded on this day. + + ); + } + + return ( + + + + + Device ID + Time + Severity + Message + + + + {p.logs.map((row, id) => ( + + + {row.device_id ?? "Backend"} + + + {new Date(row.time * 1000).toLocaleTimeString()} + + {row.severity} + {row.message} + + ))} + +
+
+ ); } diff --git a/central_frontend/src/widgets/SolarEnergyRouteContainer.tsx b/central_frontend/src/widgets/SolarEnergyRouteContainer.tsx index 5b87fee..80a3cc3 100644 --- a/central_frontend/src/widgets/SolarEnergyRouteContainer.tsx +++ b/central_frontend/src/widgets/SolarEnergyRouteContainer.tsx @@ -9,13 +9,20 @@ export function SolarEnergyRouteContainer( } & PropsWithChildren ): React.ReactElement { return ( -
+
{p.label}