From cf2dfd9a54dedf18a2a7d554a25733bfe9ce0cfe Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sun, 7 Apr 2024 14:36:08 -0600 Subject: [PATCH] Redesign logs page (#10853) * Adjust outline and structure to match designs * More color changes to fit design * Properly parse go2rtc severity * Add ability to filter by clicking item * Implement sheet / drawer for viewing full log * Add toast and filtering * Add links to docs when specific log items are selected * Cleanup log seeking * Use header in layout * Fix mobile menus * Fix safari theme * Hide rings * Theme adjustment --- web/src/components/filter/LogLevelFilter.tsx | 126 ++++++++++ .../components/filter/ReviewFilterGroup.tsx | 4 +- web/src/components/indicators/Chip.tsx | 35 ++- web/src/components/overlay/LogInfoDialog.tsx | 129 ++++++++++ .../components/settings/GeneralSettings.tsx | 8 +- web/src/pages/Logs.tsx | 221 ++++++++++-------- web/src/pages/SubmitPlus.tsx | 1 + web/tailwind.config.js | 8 +- web/themes/theme-default.css | 36 ++- 9 files changed, 449 insertions(+), 119 deletions(-) create mode 100644 web/src/components/filter/LogLevelFilter.tsx create mode 100644 web/src/components/overlay/LogInfoDialog.tsx diff --git a/web/src/components/filter/LogLevelFilter.tsx b/web/src/components/filter/LogLevelFilter.tsx new file mode 100644 index 000000000..4eb19d350 --- /dev/null +++ b/web/src/components/filter/LogLevelFilter.tsx @@ -0,0 +1,126 @@ +import { Button } from "../ui/button"; +import { FaFilter } from "react-icons/fa"; +import { isMobile } from "react-device-detect"; +import { Drawer, DrawerContent, DrawerTrigger } from "../ui/drawer"; +import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover"; +import { LogSeverity } from "@/types/log"; +import { Label } from "../ui/label"; +import { Switch } from "../ui/switch"; +import { DropdownMenuSeparator } from "../ui/dropdown-menu"; + +type LogLevelFilterButtonProps = { + selectedLabels?: LogSeverity[]; + updateLabelFilter: (labels: LogSeverity[] | undefined) => void; +}; +export function LogLevelFilterButton({ + selectedLabels, + updateLabelFilter, +}: LogLevelFilterButtonProps) { + const trigger = ( + + ); + const content = ( + + ); + + if (isMobile) { + return ( + + {trigger} + + {content} + + + ); + } + + return ( + + {trigger} + {content} + + ); +} + +type GeneralFilterContentProps = { + selectedLabels: LogSeverity[] | undefined; + updateLabelFilter: (labels: LogSeverity[] | undefined) => void; +}; +export function GeneralFilterContent({ + selectedLabels, + updateLabelFilter, +}: GeneralFilterContentProps) { + return ( + <> +
+
+ + { + if (isChecked) { + updateLabelFilter(undefined); + } + }} + /> +
+ +
+ {["debug", "info", "warning", "error"].map((item) => ( +
+ + { + if (isChecked) { + const updatedLabels = selectedLabels + ? [...selectedLabels] + : []; + + updatedLabels.push(item as LogSeverity); + updateLabelFilter(updatedLabels); + } else { + const updatedLabels = selectedLabels + ? [...selectedLabels] + : []; + + // can not deselect the last item + if (updatedLabels.length > 1) { + updatedLabels.splice( + updatedLabels.indexOf(item as LogSeverity), + 1, + ); + updateLabelFilter(updatedLabels); + } + } + }} + /> +
+ ))} +
+
+ + + ); +} diff --git a/web/src/components/filter/ReviewFilterGroup.tsx b/web/src/components/filter/ReviewFilterGroup.tsx index a3c3fadbc..91e390847 100644 --- a/web/src/components/filter/ReviewFilterGroup.tsx +++ b/web/src/components/filter/ReviewFilterGroup.tsx @@ -567,7 +567,7 @@ export function GeneralFilterContent({ {allLabels.map((item) => (