mirror of
				https://github.com/blakeblackshear/frigate.git
				synced 2025-10-27 10:52:11 +01:00 
			
		
		
		
	Don't show warning for disabled cameras (#10811)
This commit is contained in:
		
							parent
							
								
									59335c0628
								
							
						
					
					
						commit
						483d64e419
					
				@ -87,7 +87,10 @@ export default function Statusbar() {
 | 
				
			|||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
      <div className="h-full flex items-center gap-2">
 | 
					      <div className="h-full flex items-center gap-2">
 | 
				
			||||||
        {potentialProblems.map((prob) => (
 | 
					        {potentialProblems.map((prob) => (
 | 
				
			||||||
          <div className="flex items-center text-sm gap-2 capitalize">
 | 
					          <div
 | 
				
			||||||
 | 
					            key={prob.text}
 | 
				
			||||||
 | 
					            className="flex items-center text-sm gap-2 capitalize"
 | 
				
			||||||
 | 
					          >
 | 
				
			||||||
            <IoIosWarning className={`size-5 ${prob.color}`} />
 | 
					            <IoIosWarning className={`size-5 ${prob.color}`} />
 | 
				
			||||||
            {prob.text}
 | 
					            {prob.text}
 | 
				
			||||||
          </div>
 | 
					          </div>
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,11 @@
 | 
				
			|||||||
 | 
					import { FrigateConfig } from "@/types/frigateConfig";
 | 
				
			||||||
import { FrigateStats, PotentialProblem } from "@/types/stats";
 | 
					import { FrigateStats, PotentialProblem } from "@/types/stats";
 | 
				
			||||||
import { useMemo } from "react";
 | 
					import { useMemo } from "react";
 | 
				
			||||||
 | 
					import useSWR from "swr";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default function useStats(stats: FrigateStats | undefined) {
 | 
					export default function useStats(stats: FrigateStats | undefined) {
 | 
				
			||||||
 | 
					  const { data: config } = useSWR<FrigateConfig>("config");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const potentialProblems = useMemo<PotentialProblem[]>(() => {
 | 
					  const potentialProblems = useMemo<PotentialProblem[]>(() => {
 | 
				
			||||||
    const problems: PotentialProblem[] = [];
 | 
					    const problems: PotentialProblem[] = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -26,7 +30,11 @@ export default function useStats(stats: FrigateStats | undefined) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // check for offline cameras
 | 
					    // check for offline cameras
 | 
				
			||||||
    Object.entries(stats["cameras"]).forEach(([name, cam]) => {
 | 
					    Object.entries(stats["cameras"]).forEach(([name, cam]) => {
 | 
				
			||||||
      if (cam["camera_fps"] == 0) {
 | 
					      if (!config) {
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (config.cameras[name].enabled && cam["camera_fps"] == 0) {
 | 
				
			||||||
        problems.push({
 | 
					        problems.push({
 | 
				
			||||||
          text: `${name.replaceAll("_", " ")} is offline`,
 | 
					          text: `${name.replaceAll("_", " ")} is offline`,
 | 
				
			||||||
          color: "text-danger",
 | 
					          color: "text-danger",
 | 
				
			||||||
@ -59,7 +67,7 @@ export default function useStats(stats: FrigateStats | undefined) {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return problems;
 | 
					    return problems;
 | 
				
			||||||
  }, [stats]);
 | 
					  }, [config, stats]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return { potentialProblems };
 | 
					  return { potentialProblems };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user