From d6409ae1cbf542c6d0935cfd92237729944ceea7 Mon Sep 17 00:00:00 2001 From: leccelecce <24962424+leccelecce@users.noreply.github.com> Date: Mon, 31 Mar 2025 22:04:41 +0100 Subject: [PATCH] read from config instead of stats --- frigate/storage.py | 2 -- web/src/components/graph/CombinedStorageGraph.tsx | 11 +++++++---- web/src/views/system/StorageMetrics.tsx | 2 -- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/frigate/storage.py b/frigate/storage.py index ecff0234a..1c4650271 100644 --- a/frigate/storage.py +++ b/frigate/storage.py @@ -82,8 +82,6 @@ class StorageMaintainer(threading.Thread): "bandwidth": self.camera_storage_stats.get(camera, {}).get( "bandwidth", 0 ), - "record_retain_mode": self.config.cameras[camera].record.retain.mode, - "record_retain_days": self.config.cameras[camera].record.retain.days, } return usages diff --git a/web/src/components/graph/CombinedStorageGraph.tsx b/web/src/components/graph/CombinedStorageGraph.tsx index 731409b5e..83716d02a 100644 --- a/web/src/components/graph/CombinedStorageGraph.tsx +++ b/web/src/components/graph/CombinedStorageGraph.tsx @@ -1,4 +1,5 @@ import { useTheme } from "@/context/theme-provider"; +import { FrigateConfig } from "@/types/frigateConfig"; import { generateColors } from "@/utils/colorUtil"; import { useEffect, useMemo } from "react"; import Chart from "react-apexcharts"; @@ -19,14 +20,13 @@ import { getUnitSize } from "@/utils/storageUtil"; import { CiCircleAlert } from "react-icons/ci"; import { useTranslation } from "react-i18next"; +import useSWR from "swr"; type CameraStorage = { [key: string]: { bandwidth: number; usage: number; usage_percent: number; - record_retain_mode: string; - record_retain_days: number; }; }; @@ -45,6 +45,9 @@ export function CombinedStorageGraph({ cameraStorage, totalStorage, }: CombinedStorageGraphProps) { + const { data: config } = useSWR("config", { + revalidateOnFocus: false, + }); const { t } = useTranslation(["views/system"]); const { theme, systemTheme } = useTheme(); @@ -58,8 +61,8 @@ export function CombinedStorageGraph({ usage: cameraStorage[entity].usage, bandwidth: cameraStorage[entity].bandwidth, color: colors[index], // Assign the corresponding color - retentionMode: cameraStorage[entity].record_retain_mode, - retentionDays: cameraStorage[entity].record_retain_days, + retentionMode: config?.cameras[entity].record.retain.mode, + retentionDays: config?.cameras[entity].record.retain.days, })); // Add the unused percentage to the series diff --git a/web/src/views/system/StorageMetrics.tsx b/web/src/views/system/StorageMetrics.tsx index b4abe21be..4e7ff646d 100644 --- a/web/src/views/system/StorageMetrics.tsx +++ b/web/src/views/system/StorageMetrics.tsx @@ -20,8 +20,6 @@ type CameraStorage = { bandwidth: number; usage: number; usage_percent: number; - record_retain_mode: string; - record_retain_days: number; }; };