Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add camera bandwidth back in storage metrics #13436

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions web/src/components/graph/StorageGraph.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { useTheme } from "@/context/theme-provider";
import { useEffect, useMemo } from "react";
import Chart from "react-apexcharts";

const getUnitSize = (MB: number) => {
if (MB === null || isNaN(MB) || MB < 0) return "Invalid number";
if (MB < 1024) return `${MB.toFixed(2)} MiB`;
if (MB < 1048576) return `${(MB / 1024).toFixed(2)} GiB`;

return `${(MB / 1048576).toFixed(2)} TiB`;
};
import { getUnitSize } from "@/utils/storageUtil";

type StorageGraphProps = {
graphId: string;
Expand Down
7 changes: 7 additions & 0 deletions web/src/utils/storageUtil.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const getUnitSize = (MB: number) => {
if (MB === null || isNaN(MB) || MB < 0) return "Invalid number";
if (MB < 1024) return `${MB.toFixed(2)} MiB`;
if (MB < 1048576) return `${(MB / 1024).toFixed(2)} GiB`;

return `${(MB / 1048576).toFixed(2)} TiB`;
};
8 changes: 7 additions & 1 deletion web/src/views/system/StorageMetrics.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { StorageGraph } from "@/components/graph/StorageGraph";
import { FrigateStats } from "@/types/stats";
import { getUnitSize } from "@/utils/storageUtil";
import { useMemo } from "react";
import useSWR from "swr";

Expand Down Expand Up @@ -76,7 +77,12 @@ export default function StorageMetrics({
<div className="mt-4 grid grid-cols-1 gap-2 sm:grid-cols-3">
{Object.keys(cameraStorage).map((camera) => (
<div className="flex-col rounded-lg bg-background_alt p-2.5 md:rounded-2xl">
<div className="mb-5 capitalize">{camera.replaceAll("_", " ")}</div>
<div className="mb-5 flex flex-row items-center justify-between">
<div className="capitalize">{camera.replaceAll("_", " ")}</div>
<div className="text-xs text-muted-foreground">
{getUnitSize(cameraStorage[camera].bandwidth)} / hour
</div>
</div>
<StorageGraph
graphId={`${camera}-storage`}
used={cameraStorage[camera].usage}
Expand Down