mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-17 08:35:21 +03:00
use input for score filtering
This commit is contained in:
parent
fb0bbdf639
commit
b046783364
@ -201,10 +201,13 @@ export default function InputWithTags({
|
|||||||
allSuggestions[type as FilterType]?.includes(value) ||
|
allSuggestions[type as FilterType]?.includes(value) ||
|
||||||
type == "before" ||
|
type == "before" ||
|
||||||
type == "after" ||
|
type == "after" ||
|
||||||
type == "time_range"
|
type == "time_range" ||
|
||||||
|
type == "min_score" ||
|
||||||
|
type == "max_score"
|
||||||
) {
|
) {
|
||||||
const newFilters = { ...filters };
|
const newFilters = { ...filters };
|
||||||
let timestamp = 0;
|
let timestamp = 0;
|
||||||
|
let score = 0;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "before":
|
case "before":
|
||||||
@ -244,6 +247,40 @@ export default function InputWithTags({
|
|||||||
newFilters[type] = timestamp / 1000;
|
newFilters[type] = timestamp / 1000;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "min_score":
|
||||||
|
case "max_score":
|
||||||
|
score = parseInt(value);
|
||||||
|
if (score >= 0) {
|
||||||
|
// Check for conflicts between min_score and max_score
|
||||||
|
if (
|
||||||
|
type === "min_score" &&
|
||||||
|
filters.max_score !== undefined &&
|
||||||
|
score > filters.max_score * 100
|
||||||
|
) {
|
||||||
|
toast.error(
|
||||||
|
"The 'min_score' must be less than or equal to the 'max_score'.",
|
||||||
|
{
|
||||||
|
position: "top-center",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
type === "max_score" &&
|
||||||
|
filters.min_score !== undefined &&
|
||||||
|
score < filters.min_score * 100
|
||||||
|
) {
|
||||||
|
toast.error(
|
||||||
|
"The 'max_score' must be greater than or equal to the 'min_score'.",
|
||||||
|
{
|
||||||
|
position: "top-center",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
newFilters[type] = score / 100;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "time_range":
|
case "time_range":
|
||||||
newFilters[type] = value;
|
newFilters[type] = value;
|
||||||
break;
|
break;
|
||||||
@ -302,6 +339,8 @@ export default function InputWithTags({
|
|||||||
} - ${
|
} - ${
|
||||||
config?.ui.time_format === "24hour" ? endTime : convertTo12Hour(endTime)
|
config?.ui.time_format === "24hour" ? endTime : convertTo12Hour(endTime)
|
||||||
}`;
|
}`;
|
||||||
|
} else if (filterType === "min_score" || filterType === "max_score") {
|
||||||
|
return (Number(filterValues) * 100).toString() + "%";
|
||||||
} else {
|
} else {
|
||||||
return filterValues as string;
|
return filterValues as string;
|
||||||
}
|
}
|
||||||
@ -320,7 +359,11 @@ export default function InputWithTags({
|
|||||||
isValidTimeRange(
|
isValidTimeRange(
|
||||||
trimmedValue.replace("-", ","),
|
trimmedValue.replace("-", ","),
|
||||||
config?.ui.time_format,
|
config?.ui.time_format,
|
||||||
))
|
)) ||
|
||||||
|
((filterType === "min_score" || filterType === "max_score") &&
|
||||||
|
!isNaN(Number(trimmedValue)) &&
|
||||||
|
Number(trimmedValue) >= 50 &&
|
||||||
|
Number(trimmedValue) <= 100)
|
||||||
) {
|
) {
|
||||||
createFilter(
|
createFilter(
|
||||||
filterType,
|
filterType,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user