mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-10-20 05:32:49 +03:00
show translated errors for motion search limits
This commit is contained in:
@@ -56,6 +56,9 @@
|
|||||||
"noROI": "Please draw a region of interest",
|
"noROI": "Please draw a region of interest",
|
||||||
"noTimeRange": "Please select a time range",
|
"noTimeRange": "Please select a time range",
|
||||||
"invalidTimeRange": "End time must be after start time",
|
"invalidTimeRange": "End time must be after start time",
|
||||||
|
"timeRangeTooLong": "Time range must be {{hours}} hours or less",
|
||||||
|
"alreadyRunning": "You already have a motion search running. Wait for it to finish or cancel it.",
|
||||||
|
"tooManySearches": "Too many motion searches are running. Try again when one finishes.",
|
||||||
"searchFailed": "Search failed: {{message}}",
|
"searchFailed": "Search failed: {{message}}",
|
||||||
"polygonTooSmall": "Polygon must have at least 3 points",
|
"polygonTooSmall": "Polygon must have at least 3 points",
|
||||||
"unknown": "Unknown error"
|
"unknown": "Unknown error"
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ type MotionSearchViewProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const DEFAULT_EXPORT_WINDOW_SECONDS = 60;
|
const DEFAULT_EXPORT_WINDOW_SECONDS = 60;
|
||||||
|
const MAX_SEARCH_RANGE_HOURS = 48;
|
||||||
const NO_REVIEW_EVENTS: ReviewSegment[] = [];
|
const NO_REVIEW_EVENTS: ReviewSegment[] = [];
|
||||||
|
|
||||||
export default function MotionSearchView({
|
export default function MotionSearchView({
|
||||||
@@ -860,6 +861,16 @@ export default function MotionSearchView({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
searchRange.before - searchRange.after >
|
||||||
|
MAX_SEARCH_RANGE_HOURS * 3600
|
||||||
|
) {
|
||||||
|
toast.error(
|
||||||
|
t("errors.timeRangeTooLong", { hours: MAX_SEARCH_RANGE_HOURS }),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setIsSearching(true);
|
setIsSearching(true);
|
||||||
setSearchResults([]);
|
setSearchResults([]);
|
||||||
setHasSearched(true);
|
setHasSearched(true);
|
||||||
@@ -892,6 +903,20 @@ export default function MotionSearchView({
|
|||||||
setIsSearching(false);
|
setIsSearching(false);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
const status = axios.isAxiosError(error)
|
||||||
|
? error.response?.status
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
if (status === 409 || status === 429) {
|
||||||
|
toast.error(
|
||||||
|
t(
|
||||||
|
status === 409 ? "errors.alreadyRunning" : "errors.tooManySearches",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
setIsSearching(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let errorMessage = t("errors.unknown");
|
let errorMessage = t("errors.unknown");
|
||||||
|
|
||||||
if (axios.isAxiosError<{ message?: string; detail?: string }>(error)) {
|
if (axios.isAxiosError<{ message?: string; detail?: string }>(error)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user