mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-15 11:32:09 +03:00
limit cameras in explore
This commit is contained in:
parent
0561a78bc9
commit
0148e91544
@ -24,9 +24,9 @@ import PlatformAwareDialog from "../overlay/dialog/PlatformAwareDialog";
|
|||||||
import SearchFilterDialog from "../overlay/dialog/SearchFilterDialog";
|
import SearchFilterDialog from "../overlay/dialog/SearchFilterDialog";
|
||||||
import { CalendarRangeFilterButton } from "./CalendarFilterButton";
|
import { CalendarRangeFilterButton } from "./CalendarFilterButton";
|
||||||
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
||||||
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { getTranslatedLabel } from "@/utils/i18n";
|
import { getTranslatedLabel } from "@/utils/i18n";
|
||||||
|
import { useAllowedCameras } from "@/hooks/use-allowed-cameras";
|
||||||
|
|
||||||
type SearchFilterGroupProps = {
|
type SearchFilterGroupProps = {
|
||||||
className: string;
|
className: string;
|
||||||
@ -46,6 +46,7 @@ export default function SearchFilterGroup({
|
|||||||
const { data: config } = useSWR<FrigateConfig>("config", {
|
const { data: config } = useSWR<FrigateConfig>("config", {
|
||||||
revalidateOnFocus: false,
|
revalidateOnFocus: false,
|
||||||
});
|
});
|
||||||
|
const allowedCameras = useAllowedCameras();
|
||||||
|
|
||||||
const allLabels = useMemo<string[]>(() => {
|
const allLabels = useMemo<string[]>(() => {
|
||||||
if (filterList?.labels) {
|
if (filterList?.labels) {
|
||||||
@ -57,7 +58,9 @@ export default function SearchFilterGroup({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const labels = new Set<string>();
|
const labels = new Set<string>();
|
||||||
const cameras = filter?.cameras || Object.keys(config.cameras);
|
const cameras = (filter?.cameras || allowedCameras).filter((camera) =>
|
||||||
|
allowedCameras.includes(camera),
|
||||||
|
);
|
||||||
|
|
||||||
cameras.forEach((camera) => {
|
cameras.forEach((camera) => {
|
||||||
if (camera == "birdseye") {
|
if (camera == "birdseye") {
|
||||||
@ -87,7 +90,7 @@ export default function SearchFilterGroup({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return [...labels].sort();
|
return [...labels].sort();
|
||||||
}, [config, filterList, filter]);
|
}, [config, filterList, filter, allowedCameras]);
|
||||||
|
|
||||||
const allZones = useMemo<string[]>(() => {
|
const allZones = useMemo<string[]>(() => {
|
||||||
if (filterList?.zones) {
|
if (filterList?.zones) {
|
||||||
@ -99,7 +102,9 @@ export default function SearchFilterGroup({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const zones = new Set<string>();
|
const zones = new Set<string>();
|
||||||
const cameras = filter?.cameras || Object.keys(config.cameras);
|
const cameras = (filter?.cameras || allowedCameras).filter((camera) =>
|
||||||
|
allowedCameras.includes(camera),
|
||||||
|
);
|
||||||
|
|
||||||
cameras.forEach((camera) => {
|
cameras.forEach((camera) => {
|
||||||
if (camera == "birdseye") {
|
if (camera == "birdseye") {
|
||||||
@ -118,16 +123,16 @@ export default function SearchFilterGroup({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return [...zones].sort();
|
return [...zones].sort();
|
||||||
}, [config, filterList, filter]);
|
}, [config, filterList, filter, allowedCameras]);
|
||||||
|
|
||||||
const filterValues = useMemo(
|
const filterValues = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
cameras: Object.keys(config?.cameras || {}),
|
cameras: allowedCameras,
|
||||||
labels: Object.values(allLabels || {}),
|
labels: Object.values(allLabels || {}),
|
||||||
zones: Object.values(allZones || {}),
|
zones: Object.values(allZones || {}),
|
||||||
search_type: ["thumbnail", "description"] as SearchSource[],
|
search_type: ["thumbnail", "description"] as SearchSource[],
|
||||||
}),
|
}),
|
||||||
[config, allLabels, allZones],
|
[allLabels, allZones, allowedCameras],
|
||||||
);
|
);
|
||||||
|
|
||||||
const availableSortTypes = useMemo(() => {
|
const availableSortTypes = useMemo(() => {
|
||||||
|
|||||||
@ -33,6 +33,7 @@ import { TooltipPortal } from "@radix-ui/react-tooltip";
|
|||||||
import SearchActionGroup from "@/components/filter/SearchActionGroup";
|
import SearchActionGroup from "@/components/filter/SearchActionGroup";
|
||||||
import { Trans, useTranslation } from "react-i18next";
|
import { Trans, useTranslation } from "react-i18next";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
import { useAllowedCameras } from "@/hooks/use-allowed-cameras";
|
||||||
|
|
||||||
type SearchViewProps = {
|
type SearchViewProps = {
|
||||||
search: string;
|
search: string;
|
||||||
@ -96,6 +97,7 @@ export default function SearchView({
|
|||||||
);
|
);
|
||||||
|
|
||||||
// suggestions values
|
// suggestions values
|
||||||
|
const allowedCameras = useAllowedCameras();
|
||||||
|
|
||||||
const allLabels = useMemo<string[]>(() => {
|
const allLabels = useMemo<string[]>(() => {
|
||||||
if (!config) {
|
if (!config) {
|
||||||
@ -103,7 +105,9 @@ export default function SearchView({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const labels = new Set<string>();
|
const labels = new Set<string>();
|
||||||
const cameras = searchFilter?.cameras || Object.keys(config.cameras);
|
const cameras = (searchFilter?.cameras || allowedCameras).filter((camera) =>
|
||||||
|
allowedCameras.includes(camera),
|
||||||
|
);
|
||||||
|
|
||||||
cameras.forEach((camera) => {
|
cameras.forEach((camera) => {
|
||||||
if (camera == "birdseye") {
|
if (camera == "birdseye") {
|
||||||
@ -128,7 +132,7 @@ export default function SearchView({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return [...labels].sort();
|
return [...labels].sort();
|
||||||
}, [config, searchFilter]);
|
}, [config, searchFilter, allowedCameras]);
|
||||||
|
|
||||||
const { data: allSubLabels } = useSWR("sub_labels");
|
const { data: allSubLabels } = useSWR("sub_labels");
|
||||||
const { data: allRecognizedLicensePlates } = useSWR(
|
const { data: allRecognizedLicensePlates } = useSWR(
|
||||||
@ -141,7 +145,9 @@ export default function SearchView({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const zones = new Set<string>();
|
const zones = new Set<string>();
|
||||||
const cameras = searchFilter?.cameras || Object.keys(config.cameras);
|
const cameras = (searchFilter?.cameras || allowedCameras).filter((camera) =>
|
||||||
|
allowedCameras.includes(camera),
|
||||||
|
);
|
||||||
|
|
||||||
cameras.forEach((camera) => {
|
cameras.forEach((camera) => {
|
||||||
if (camera == "birdseye") {
|
if (camera == "birdseye") {
|
||||||
@ -160,11 +166,11 @@ export default function SearchView({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return [...zones].sort();
|
return [...zones].sort();
|
||||||
}, [config, searchFilter]);
|
}, [config, searchFilter, allowedCameras]);
|
||||||
|
|
||||||
const suggestionsValues = useMemo(
|
const suggestionsValues = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
cameras: Object.keys(config?.cameras || {}),
|
cameras: allowedCameras,
|
||||||
labels: Object.values(allLabels || {}),
|
labels: Object.values(allLabels || {}),
|
||||||
zones: Object.values(allZones || {}),
|
zones: Object.values(allZones || {}),
|
||||||
sub_labels: allSubLabels,
|
sub_labels: allSubLabels,
|
||||||
@ -192,6 +198,7 @@ export default function SearchView({
|
|||||||
allSubLabels,
|
allSubLabels,
|
||||||
allRecognizedLicensePlates,
|
allRecognizedLicensePlates,
|
||||||
searchFilter,
|
searchFilter,
|
||||||
|
allowedCameras,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user