mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-09-26 07:38:59 +03:00
* Implement hardware detection and UI management * Cleanup Frigate+ detection * Don't count model as changed * Fixes for audio map error * Add descriptions * Enforce that all model must exist * Fix hardware picking * Docs fixes * WebUI cleanup * Cleanup handling of scenes * UI refinement * Cleanup recommended UI * test fixews
32 lines
921 B
TypeScript
32 lines
921 B
TypeScript
import type { FormValidation } from "@rjsf/utils";
|
|
import type { TFunction } from "i18next";
|
|
import { isJsonObject } from "@/lib/utils";
|
|
|
|
const DEFAULT_SCENE = "all";
|
|
|
|
/**
|
|
* A camera that names no scene runs the model whose scene is `all`. Without one
|
|
* the backend rejects the config outright once a second model exists, and with
|
|
* a single model it silently runs every camera on whatever that model is. Both
|
|
* are surprising, so require the default to be present.
|
|
*/
|
|
export function validateDefaultModelExists(
|
|
formData: unknown,
|
|
errors: FormValidation,
|
|
t: TFunction,
|
|
): FormValidation {
|
|
if (!Array.isArray(formData) || formData.length === 0) {
|
|
return errors;
|
|
}
|
|
|
|
const hasDefault = formData.some(
|
|
(model) => isJsonObject(model) && model.scene === DEFAULT_SCENE,
|
|
);
|
|
|
|
if (!hasDefault) {
|
|
errors.addError?.(t("models.defaultRequired", { ns: "config/validation" }));
|
|
}
|
|
|
|
return errors;
|
|
}
|