address feedback

This commit is contained in:
Nicolas Mowen 2024-04-03 21:21:45 -06:00
parent bfd078b80e
commit 6c3d820ff6
3 changed files with 14 additions and 4 deletions

View File

@ -1,7 +1,9 @@
import { useTheme } from "@/context/theme-provider"; import { useTheme } from "@/context/theme-provider";
import { FrigateConfig } from "@/types/frigateConfig";
import { Threshold } from "@/types/graph"; import { Threshold } from "@/types/graph";
import { useCallback, useEffect, useMemo } from "react"; import { useCallback, useEffect, useMemo } from "react";
import Chart from "react-apexcharts"; import Chart from "react-apexcharts";
import useSWR from "swr";
type SystemGraphProps = { type SystemGraphProps = {
graphId: string; graphId: string;
@ -19,6 +21,10 @@ export default function SystemGraph({
updateTimes, updateTimes,
data, data,
}: SystemGraphProps) { }: SystemGraphProps) {
const { data: config } = useSWR<FrigateConfig>("config", {
revalidateOnFocus: false,
});
const lastValue = useMemo<number>( const lastValue = useMemo<number>(
// @ts-expect-error y is valid // @ts-expect-error y is valid
() => data[0].data[data[0].data.length - 1]?.y ?? 0, () => data[0].data[data[0].data.length - 1]?.y ?? 0,
@ -30,9 +36,13 @@ export default function SystemGraph({
const formatTime = useCallback( const formatTime = useCallback(
(val: unknown) => { (val: unknown) => {
const date = new Date(updateTimes[Math.round(val as number)] * 1000); const date = new Date(updateTimes[Math.round(val as number)] * 1000);
return `${date.getHours() > 12 ? date.getHours() - 12 : date.getHours()}:${date.getMinutes()}`; return date.toLocaleTimeString([], {
hour12: config?.ui.time_format != "24hour",
hour: "2-digit",
minute: "2-digit",
});
}, },
[updateTimes], [config, updateTimes],
); );
const options = useMemo(() => { const options = useMemo(() => {

View File

@ -283,7 +283,7 @@ function Logs() {
<div className="size-full p-2 flex flex-col"> <div className="size-full p-2 flex flex-col">
<div className="flex justify-between items-center"> <div className="flex justify-between items-center">
<ToggleGroup <ToggleGroup
className="*:px-3 *:py-4 *:rounded-2xl" className="*:px-3 *:py-4 *:rounded-md"
type="single" type="single"
size="sm" size="sm"
value={logService} value={logService}

View File

@ -34,7 +34,7 @@ function System() {
<div className="size-full p-2 flex flex-col"> <div className="size-full p-2 flex flex-col">
<div className="w-full h-8 flex justify-between items-center"> <div className="w-full h-8 flex justify-between items-center">
<ToggleGroup <ToggleGroup
className="*:px-3 *:py-4 *:rounded-2xl" className="*:px-3 *:py-4 *:rounded-md"
type="single" type="single"
size="sm" size="sm"
value={page} value={page}