read from config instead of stats

This commit is contained in:
leccelecce 2025-03-31 22:04:41 +01:00
parent 281122e8f3
commit d6409ae1cb
3 changed files with 7 additions and 8 deletions

View File

@ -82,8 +82,6 @@ class StorageMaintainer(threading.Thread):
"bandwidth": self.camera_storage_stats.get(camera, {}).get( "bandwidth": self.camera_storage_stats.get(camera, {}).get(
"bandwidth", 0 "bandwidth", 0
), ),
"record_retain_mode": self.config.cameras[camera].record.retain.mode,
"record_retain_days": self.config.cameras[camera].record.retain.days,
} }
return usages return usages

View File

@ -1,4 +1,5 @@
import { useTheme } from "@/context/theme-provider"; import { useTheme } from "@/context/theme-provider";
import { FrigateConfig } from "@/types/frigateConfig";
import { generateColors } from "@/utils/colorUtil"; import { generateColors } from "@/utils/colorUtil";
import { useEffect, useMemo } from "react"; import { useEffect, useMemo } from "react";
import Chart from "react-apexcharts"; import Chart from "react-apexcharts";
@ -19,14 +20,13 @@ import { getUnitSize } from "@/utils/storageUtil";
import { CiCircleAlert } from "react-icons/ci"; import { CiCircleAlert } from "react-icons/ci";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import useSWR from "swr";
type CameraStorage = { type CameraStorage = {
[key: string]: { [key: string]: {
bandwidth: number; bandwidth: number;
usage: number; usage: number;
usage_percent: number; usage_percent: number;
record_retain_mode: string;
record_retain_days: number;
}; };
}; };
@ -45,6 +45,9 @@ export function CombinedStorageGraph({
cameraStorage, cameraStorage,
totalStorage, totalStorage,
}: CombinedStorageGraphProps) { }: CombinedStorageGraphProps) {
const { data: config } = useSWR<FrigateConfig>("config", {
revalidateOnFocus: false,
});
const { t } = useTranslation(["views/system"]); const { t } = useTranslation(["views/system"]);
const { theme, systemTheme } = useTheme(); const { theme, systemTheme } = useTheme();
@ -58,8 +61,8 @@ export function CombinedStorageGraph({
usage: cameraStorage[entity].usage, usage: cameraStorage[entity].usage,
bandwidth: cameraStorage[entity].bandwidth, bandwidth: cameraStorage[entity].bandwidth,
color: colors[index], // Assign the corresponding color color: colors[index], // Assign the corresponding color
retentionMode: cameraStorage[entity].record_retain_mode, retentionMode: config?.cameras[entity].record.retain.mode,
retentionDays: cameraStorage[entity].record_retain_days, retentionDays: config?.cameras[entity].record.retain.days,
})); }));
// Add the unused percentage to the series // Add the unused percentage to the series

View File

@ -20,8 +20,6 @@ type CameraStorage = {
bandwidth: number; bandwidth: number;
usage: number; usage: number;
usage_percent: number; usage_percent: number;
record_retain_mode: string;
record_retain_days: number;
}; };
}; };