import useSWR from "swr"; import { FrigateStats } from "@/types/stats"; import { useEffect, useState } from "react"; import TimeAgo from "@/components/dynamic/TimeAgo"; import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"; import { isDesktop, isMobile } from "react-device-detect"; import GeneralMetrics from "@/views/system/GeneralMetrics"; import StorageMetrics from "@/views/system/StorageMetrics"; import { LuActivity, LuHardDrive } from "react-icons/lu"; import { FaVideo } from "react-icons/fa"; import Logo from "@/components/Logo"; import useOptimisticState from "@/hooks/use-optimistic-state"; import CameraMetrics from "@/views/system/CameraMetrics"; const metrics = ["general", "storage", "cameras"] as const; type SystemMetric = (typeof metrics)[number]; function System() { // stats page const [page, setPage] = useState("general"); const [pageToggle, setPageToggle] = useOptimisticState(page, setPage, 100); const [lastUpdated, setLastUpdated] = useState(Date.now() / 1000); useEffect(() => { document.title = `${pageToggle[0].toUpperCase()}${pageToggle.substring(1)} Stats - Frigate`; }, [pageToggle]); // stats collection const { data: statsSnapshot } = useSWR("stats", { revalidateOnFocus: false, }); return (
{isMobile && ( )} { if (value) { setPageToggle(value); } }} // don't allow the severity to be unselected > {Object.values(metrics).map((item) => ( {item == "general" && } {item == "storage" && } {item == "cameras" && } {isDesktop &&
{item}
}
))}
{lastUpdated && (
Last refreshed:
)}
System
{statsSnapshot && (
{statsSnapshot.service.version}
)}
{page == "general" && ( )} {page == "storage" && } {page == "cameras" && ( )}
); } export default System;