diff --git a/web/src/routes/Events.jsx b/web/src/routes/Events.jsx index c37a1b2f5..dc123696d 100644 --- a/web/src/routes/Events.jsx +++ b/web/src/routes/Events.jsx @@ -107,19 +107,22 @@ export default function Events({ path, ...props }) { const filterValues = useMemo( () => ({ cameras: Object.keys(config?.cameras || {}), - zones: Object.values(config?.cameras || {}) - .reduce((memo, camera) => { - memo = memo.concat(Object.keys(camera?.zones || {})); - return memo; - }, []) - .filter((value, i, self) => self.indexOf(value) === i), + zones: [ + ...Object.values(config?.cameras || {}) + .reduce((memo, camera) => { + memo = memo.concat(Object.keys(camera?.zones || {})); + return memo; + }, []) + .filter((value, i, self) => self.indexOf(value) === i), + 'None', + ], labels: Object.values(config?.cameras || {}) .reduce((memo, camera) => { memo = memo.concat(camera?.objects?.track || []); return memo; }, config?.objects?.track || []) .filter((value, i, self) => self.indexOf(value) === i), - sub_labels: Object.values(allSubLabels || []), + sub_labels: (allSubLabels || []).length > 0 ? [...Object.values(allSubLabels), "None"] : [], }), [config, allSubLabels] ); @@ -159,12 +162,12 @@ export default function Events({ path, ...props }) { // don't remove all if only one option if (currentItems.length > 1) { currentItems.splice(currentItems.indexOf(item), 1); - items = currentItems.join(","); + items = currentItems.join(','); } else { - items = ["all"]; + items = ['all']; } } else { - let currentItems = searchParams[name].length > 0 ? searchParams[name].split(",") : []; + let currentItems = searchParams[name].length > 0 ? searchParams[name].split(',') : []; if (currentItems.includes(item)) { // don't remove the last item in the filter list @@ -172,12 +175,12 @@ export default function Events({ path, ...props }) { currentItems.splice(currentItems.indexOf(item), 1); } - items = currentItems.join(","); - } else if ((currentItems.length + 1) == filterValues[name].length) { - items = ["all"]; + items = currentItems.join(','); + } else if (currentItems.length + 1 == filterValues[name].length) { + items = ['all']; } else { currentItems.push(item); - items = currentItems.join(","); + items = currentItems.join(','); } } @@ -301,47 +304,46 @@ export default function Events({ path, ...props }) { title="Cameras" options={filterValues.cameras} selection={searchParams.cameras} - onToggle={(item) => onToggleNamedFilter("cameras", item)} - onShowAll={() => onFilter("cameras", ["all"])} - onSelectSingle={(item) => onFilter("cameras", item)} + onToggle={(item) => onToggleNamedFilter('cameras', item)} + onShowAll={() => onFilter('cameras', ['all'])} + onSelectSingle={(item) => onFilter('cameras', item)} /> onToggleNamedFilter("labels", item) } - onShowAll={() => onFilter("labels", ["all"])} - onSelectSingle={(item) => onFilter("labels", item)} + onToggle={(item) => onToggleNamedFilter('labels', item)} + onShowAll={() => onFilter('labels', ['all'])} + onSelectSingle={(item) => onFilter('labels', item)} /> onToggleNamedFilter("zones", item) } - onShowAll={() => onFilter("zones", ["all"])} - onSelectSingle={(item) => onFilter("zones", item)} + onToggle={(item) => onToggleNamedFilter('zones', item)} + onShowAll={() => onFilter('zones', ['all'])} + onSelectSingle={(item) => onFilter('zones', item)} /> - { - filterValues.sub_labels.length > 0 && ( - onToggleNamedFilter("sub_labels", item) } - onShowAll={() => onFilter("sub_labels", ["all"])} - onSelectSingle={(item) => onFilter("sub_labels", item)} - /> - )} - + {filterValues.sub_labels.length > 0 && ( + onToggleNamedFilter('sub_labels', item)} + onShowAll={() => onFilter('sub_labels', ['all'])} + onSelectSingle={(item) => onFilter('sub_labels', item)} + /> + )} + onFilter("favorites", searchParams.favorites ? 0 : 1)} + onClick={() => onFilter('favorites', searchParams.favorites ? 0 : 1)} fill={searchParams.favorites == 1 ? 'currentColor' : 'none'} /> - +