mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-09 15:05:26 +03:00
Compare commits
22 Commits
d218f54b0b
...
a5c699393a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5c699393a | ||
|
|
16b4eec91d | ||
|
|
37599e1641 | ||
|
|
98a9c50dd9 | ||
|
|
250a68947b | ||
|
|
e6d4f71f76 | ||
|
|
826456dd4f | ||
|
|
30840b5e0e | ||
|
|
ad8ce46dfb | ||
|
|
7cf336d373 | ||
|
|
22fa876340 | ||
|
|
7573f97174 | ||
|
|
eafc08e3de | ||
|
|
6d6fa303b8 | ||
|
|
725f211c63 | ||
|
|
8a17fad2fb | ||
|
|
d7b91ff320 | ||
|
|
3e526febe3 | ||
|
|
ababc2deba | ||
|
|
209e48e579 | ||
|
|
3aab79b435 | ||
|
|
4171efcd79 |
@ -40,7 +40,7 @@ logger = logging.getLogger(__name__)
|
|||||||
RECORDING_BUFFER_EXTENSION_PERCENT = 0.10
|
RECORDING_BUFFER_EXTENSION_PERCENT = 0.10
|
||||||
MIN_RECORDING_DURATION = 10
|
MIN_RECORDING_DURATION = 10
|
||||||
MAX_IMAGE_TOKENS = 24000
|
MAX_IMAGE_TOKENS = 24000
|
||||||
MAX_FRAMES_PER_SECOND = 2
|
MAX_FRAMES_PER_SECOND = 1
|
||||||
|
|
||||||
|
|
||||||
class ReviewDescriptionProcessor(PostProcessorApi):
|
class ReviewDescriptionProcessor(PostProcessorApi):
|
||||||
|
|||||||
@ -1,25 +1,48 @@
|
|||||||
from pydantic import BaseModel, ConfigDict, Field
|
from typing import Annotated
|
||||||
|
|
||||||
|
from pydantic import BaseModel, ConfigDict, Field, StringConstraints
|
||||||
|
|
||||||
|
ObservationItem = Annotated[str, StringConstraints(min_length=20, max_length=160)]
|
||||||
|
|
||||||
|
|
||||||
class ReviewMetadata(BaseModel):
|
class ReviewMetadata(BaseModel):
|
||||||
model_config = ConfigDict(extra="ignore", protected_namespaces=())
|
model_config = ConfigDict(extra="ignore", protected_namespaces=())
|
||||||
|
|
||||||
observations: list[str] = Field(
|
observations: list[ObservationItem] = Field(
|
||||||
default_factory=list,
|
...,
|
||||||
description="Chronological list of significant observations from the frames, written before the scene narrative is composed.",
|
min_length=3,
|
||||||
|
max_length=15,
|
||||||
|
description=(
|
||||||
|
"Enumerate the significant observations across all frames, in "
|
||||||
|
"chronological order, BEFORE composing the scene narrative. "
|
||||||
|
"Include the very start of the activity — for example, a vehicle "
|
||||||
|
"entering the frame or pulling into the driveway — even if it "
|
||||||
|
"lasts only a few frames and the rest of the clip is dominated "
|
||||||
|
"by a longer activity. Include each arrival, departure, motion "
|
||||||
|
"event, object handled, and notable change in position or state. "
|
||||||
|
"Each item is a single concrete fact written as a complete "
|
||||||
|
"sentence. Do not summarize, interpret, or assign meaning here — "
|
||||||
|
"that belongs in the scene field."
|
||||||
|
),
|
||||||
)
|
)
|
||||||
title: str = Field(
|
title: str = Field(
|
||||||
description="A short title characterizing what took place and where, under 10 words."
|
max_length=80,
|
||||||
|
description="A short title characterizing what took place and where, under 10 words.",
|
||||||
)
|
)
|
||||||
scene: str = Field(
|
scene: str = Field(
|
||||||
description="A chronological narrative of what happens from start to finish.",
|
min_length=150,
|
||||||
|
max_length=600,
|
||||||
|
description="A chronological narrative of what happens from start to finish, drawing directly from the items in observations.",
|
||||||
)
|
)
|
||||||
shortSummary: str = Field(
|
shortSummary: str = Field(
|
||||||
description="A brief 2-sentence summary of the scene, suitable for notifications."
|
min_length=70,
|
||||||
|
max_length=100,
|
||||||
|
description="A brief 2-sentence summary of the scene, suitable for notifications.",
|
||||||
)
|
)
|
||||||
confidence: float = Field(
|
confidence: float = Field(
|
||||||
ge=0.0,
|
ge=0.0,
|
||||||
description="Confidence in the analysis, from 0 to 1.",
|
le=1.0,
|
||||||
|
description="Confidence in the analysis as a decimal between 0.0 and 1.0, where 0.0 means no confidence and 1.0 means complete confidence. Express ONLY as a decimal.",
|
||||||
)
|
)
|
||||||
potential_threat_level: int = Field(
|
potential_threat_level: int = Field(
|
||||||
ge=0,
|
ge=0,
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import importlib
|
import importlib
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -9,6 +10,7 @@ from typing import Any, Callable, Optional
|
|||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from playhouse.shortcuts import model_to_dict
|
from playhouse.shortcuts import model_to_dict
|
||||||
|
from pydantic import ValidationError
|
||||||
|
|
||||||
from frigate.config import CameraConfig, GenAIConfig, GenAIProviderEnum
|
from frigate.config import CameraConfig, GenAIConfig, GenAIProviderEnum
|
||||||
from frigate.const import CLIPS_DIR
|
from frigate.const import CLIPS_DIR
|
||||||
@ -151,50 +153,6 @@ Each line represents a detection state, not necessarily unique individuals. The
|
|||||||
if "other_concerns" in schema.get("required", []):
|
if "other_concerns" in schema.get("required", []):
|
||||||
schema["required"].remove("other_concerns")
|
schema["required"].remove("other_concerns")
|
||||||
|
|
||||||
# Length hints injected into the schema as suggestions to the model
|
|
||||||
# (enforced by grammar-based providers like llama.cpp) but kept off the
|
|
||||||
# Pydantic model so a non-compliant response does not fail validation.
|
|
||||||
length_hints = {
|
|
||||||
"scene": {"minLength": 120, "maxLength": 600},
|
|
||||||
"shortSummary": {"minLength": 70, "maxLength": 100},
|
|
||||||
}
|
|
||||||
for field, hints in length_hints.items():
|
|
||||||
prop = schema.get("properties", {}).get(field)
|
|
||||||
if prop is not None:
|
|
||||||
prop.update(hints)
|
|
||||||
|
|
||||||
# observations is a chain-of-thought-by-schema field: forcing the model
|
|
||||||
# to enumerate concrete facts before writing scene/title surfaces details
|
|
||||||
# the narrative would otherwise gloss past (e.g. brief vehicle arrivals
|
|
||||||
# overshadowed by a longer activity). The minItems floor scales with
|
|
||||||
# event duration so longer clips get more observations.
|
|
||||||
observations_prop = schema.get("properties", {}).get("observations")
|
|
||||||
if observations_prop is not None:
|
|
||||||
duration_seconds = float(review_data.get("duration") or 0)
|
|
||||||
min_observations = max(3, round(duration_seconds / 5))
|
|
||||||
max_observations = min_observations + 8
|
|
||||||
observations_prop["description"] = (
|
|
||||||
"Enumerate the significant observations across all frames, in "
|
|
||||||
"chronological order, BEFORE composing the scene narrative. "
|
|
||||||
"Include the very start of the activity — for example, a "
|
|
||||||
"vehicle entering the frame or pulling into the driveway — "
|
|
||||||
"even if it lasts only a few frames and the rest of the clip "
|
|
||||||
"is dominated by a longer activity. Include each arrival, "
|
|
||||||
"departure, motion event, object handled, and notable change "
|
|
||||||
"in position or state. Each item is a single concrete fact "
|
|
||||||
"written as a complete sentence (e.g., 'A blue sedan turns "
|
|
||||||
"from the street into the driveway', 'Nick exits the driver "
|
|
||||||
"side carrying a plant pot'). Do not summarize, interpret, or "
|
|
||||||
"assign meaning here — that belongs in the scene field."
|
|
||||||
)
|
|
||||||
observations_prop["minItems"] = min_observations
|
|
||||||
observations_prop["maxItems"] = max_observations
|
|
||||||
observations_prop["items"] = {"type": "string", "minLength": 20}
|
|
||||||
|
|
||||||
required = schema.setdefault("required", [])
|
|
||||||
if "observations" not in required:
|
|
||||||
required.append("observations")
|
|
||||||
|
|
||||||
# OpenAI strict mode requires additionalProperties: false on all objects
|
# OpenAI strict mode requires additionalProperties: false on all objects
|
||||||
schema["additionalProperties"] = False
|
schema["additionalProperties"] = False
|
||||||
|
|
||||||
@ -225,7 +183,35 @@ Each line represents a detection state, not necessarily unique individuals. The
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
metadata = ReviewMetadata.model_validate_json(clean_json)
|
metadata = ReviewMetadata.model_validate_json(clean_json)
|
||||||
|
except ValidationError as ve:
|
||||||
|
# Constraint violations (length, item count, ranges) are logged
|
||||||
|
# at debug and the response is kept anyway — a slightly
|
||||||
|
# off-spec answer is still usable, and dropping the whole
|
||||||
|
# response loses the narrative content the model produced.
|
||||||
|
for err in ve.errors():
|
||||||
|
loc = ".".join(str(p) for p in err["loc"]) or "<root>"
|
||||||
|
logger.debug(
|
||||||
|
"Review metadata soft validation: %s — %s (input: %r)",
|
||||||
|
loc,
|
||||||
|
err["msg"],
|
||||||
|
err.get("input"),
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
raw = json.loads(clean_json)
|
||||||
|
except json.JSONDecodeError as je:
|
||||||
|
logger.error("Failed to parse review description JSON: %s", je)
|
||||||
|
return None
|
||||||
|
# observations is required on the model; fill an empty default
|
||||||
|
# if the response omitted it so attribute access stays safe.
|
||||||
|
raw.setdefault("observations", [])
|
||||||
|
metadata = ReviewMetadata.model_construct(**raw)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(
|
||||||
|
f"Failed to parse review description as the response did not match expected format. {e}"
|
||||||
|
)
|
||||||
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
# Normalize confidence if model returned a percentage (e.g. 85 instead of 0.85)
|
# Normalize confidence if model returned a percentage (e.g. 85 instead of 0.85)
|
||||||
if metadata.confidence > 1.0:
|
if metadata.confidence > 1.0:
|
||||||
metadata.confidence = min(metadata.confidence / 100.0, 1.0)
|
metadata.confidence = min(metadata.confidence / 100.0, 1.0)
|
||||||
@ -238,10 +224,7 @@ Each line represents a detection state, not necessarily unique individuals. The
|
|||||||
metadata.time = review_data["start"]
|
metadata.time = review_data["start"]
|
||||||
return metadata
|
return metadata
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# rarely LLMs can fail to follow directions on output format
|
logger.error(f"Failed to post-process review metadata: {e}")
|
||||||
logger.warning(
|
|
||||||
f"Failed to parse review description as the response did not match expected format. {e}"
|
|
||||||
)
|
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
|
|||||||
@ -1 +1,8 @@
|
|||||||
{}
|
{
|
||||||
|
"auth": {
|
||||||
|
"label": "Автентикация",
|
||||||
|
"session_length": {
|
||||||
|
"label": "Продължителност на сесията"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -109,7 +109,8 @@
|
|||||||
"classification": "Classificació",
|
"classification": "Classificació",
|
||||||
"chat": "Xat",
|
"chat": "Xat",
|
||||||
"actions": "Accions",
|
"actions": "Accions",
|
||||||
"profiles": "Perfils"
|
"profiles": "Perfils",
|
||||||
|
"features": "Característiques"
|
||||||
},
|
},
|
||||||
"pagination": {
|
"pagination": {
|
||||||
"previous": {
|
"previous": {
|
||||||
|
|||||||
@ -1298,7 +1298,13 @@
|
|||||||
"enableDesc": "Inhabilita temporalment una càmera habilitada fins que es reiniciï Frigate. La inhabilitació d'una càmera atura completament el processament de Frigate dels fluxos d'aquesta càmera. La detecció, l'enregistrament i la depuració no estaran disponibles.<br /> <em>Nota: això no desactiva les retransmissions de go2rtc.</em>",
|
"enableDesc": "Inhabilita temporalment una càmera habilitada fins que es reiniciï Frigate. La inhabilitació d'una càmera atura completament el processament de Frigate dels fluxos d'aquesta càmera. La detecció, l'enregistrament i la depuració no estaran disponibles.<br /> <em>Nota: això no desactiva les retransmissions de go2rtc.</em>",
|
||||||
"disableLabel": "Càmeres inhabilitades",
|
"disableLabel": "Càmeres inhabilitades",
|
||||||
"disableDesc": "Habilita una càmera que actualment no és visible a la interfície d'usuari i està desactivada a la configuració. Es requereix un reinici de Frigate després d'activar-la.",
|
"disableDesc": "Habilita una càmera que actualment no és visible a la interfície d'usuari i està desactivada a la configuració. Es requereix un reinici de Frigate després d'activar-la.",
|
||||||
"enableSuccess": "{{cameraName}} activat a la configuració. Reinicia Frigate per aplicar els canvis."
|
"enableSuccess": "{{cameraName}} activat a la configuració. Reinicia Frigate per aplicar els canvis.",
|
||||||
|
"friendlyName": {
|
||||||
|
"edit": "Edita el nom de la pantalla de la càmera",
|
||||||
|
"title": "Edita el nom de la pantalla",
|
||||||
|
"description": "Estableix el nom amigable que es mostra per a aquesta càmera a tota la interfície d'usuari de la Fragata. Deixeu-ho en blanc per utilitzar l'ID de la càmera.",
|
||||||
|
"rename": "Canvia el nom"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"cameraConfig": {
|
"cameraConfig": {
|
||||||
"add": "Afegeix una càmera",
|
"add": "Afegeix una càmera",
|
||||||
|
|||||||
@ -457,7 +457,13 @@
|
|||||||
"enableDesc": "Temporarily disable an enabled camera until Frigate restarts. Disabling a camera completely stops Frigate's processing of this camera's streams. Detection, recording, and debugging will be unavailable.<br /> <em>Note: This does not disable go2rtc restreams.</em>",
|
"enableDesc": "Temporarily disable an enabled camera until Frigate restarts. Disabling a camera completely stops Frigate's processing of this camera's streams. Detection, recording, and debugging will be unavailable.<br /> <em>Note: This does not disable go2rtc restreams.</em>",
|
||||||
"disableLabel": "Disabled cameras",
|
"disableLabel": "Disabled cameras",
|
||||||
"disableDesc": "Enable a camera that is currently not visible in the UI and disabled in the configuration. A restart of Frigate is required after enabling.",
|
"disableDesc": "Enable a camera that is currently not visible in the UI and disabled in the configuration. A restart of Frigate is required after enabling.",
|
||||||
"enableSuccess": "Enabled {{cameraName}} in configuration. Restart Frigate to apply the changes."
|
"enableSuccess": "Enabled {{cameraName}} in configuration. Restart Frigate to apply the changes.",
|
||||||
|
"friendlyName": {
|
||||||
|
"edit": "Edit camera display name",
|
||||||
|
"title": "Edit Display Name",
|
||||||
|
"description": "Set the friendly name shown for this camera throughout the Frigate UI. Leave blank to use the camera ID.",
|
||||||
|
"rename": "Rename"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"cameraConfig": {
|
"cameraConfig": {
|
||||||
"add": "Add Camera",
|
"add": "Add Camera",
|
||||||
|
|||||||
@ -181,7 +181,8 @@
|
|||||||
"classification": "Klassifikatsioon",
|
"classification": "Klassifikatsioon",
|
||||||
"chat": "Vestlus",
|
"chat": "Vestlus",
|
||||||
"actions": "Tegevused",
|
"actions": "Tegevused",
|
||||||
"profiles": "Profiilid"
|
"profiles": "Profiilid",
|
||||||
|
"features": "Funktsionaalsused"
|
||||||
},
|
},
|
||||||
"unit": {
|
"unit": {
|
||||||
"speed": {
|
"speed": {
|
||||||
|
|||||||
@ -42,7 +42,8 @@
|
|||||||
"second_other": "{{time}}sekunttia",
|
"second_other": "{{time}}sekunttia",
|
||||||
"formattedTimestampHourMinute": {
|
"formattedTimestampHourMinute": {
|
||||||
"24hour": "HH:mm"
|
"24hour": "HH:mm"
|
||||||
}
|
},
|
||||||
|
"never": "Ei koskaan"
|
||||||
},
|
},
|
||||||
"pagination": {
|
"pagination": {
|
||||||
"next": {
|
"next": {
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
"loginFailed": "Kirjautuminen epäonnistui",
|
"loginFailed": "Kirjautuminen epäonnistui",
|
||||||
"unknownError": "Tuntematon virhe. Tarkista logit.",
|
"unknownError": "Tuntematon virhe. Tarkista logit.",
|
||||||
"webUnknownError": "Tuntematon virhe. Tarkista konsolilogi."
|
"webUnknownError": "Tuntematon virhe. Tarkista konsolilogi."
|
||||||
}
|
},
|
||||||
|
"firstTimeLogin": "Ensimmäistä kertaa kirjautumassa sisään? Tunnukset löytyvät Frigaten lokista."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,8 @@
|
|||||||
"title": "Fregatti käynnistyy uudelleen",
|
"title": "Fregatti käynnistyy uudelleen",
|
||||||
"content": "Tämä sivu latautuu uudelleen {{countdown}} sekunnin kuluttua.",
|
"content": "Tämä sivu latautuu uudelleen {{countdown}} sekunnin kuluttua.",
|
||||||
"button": "Pakota uudelleenlataus nyt"
|
"button": "Pakota uudelleenlataus nyt"
|
||||||
}
|
},
|
||||||
|
"description": "Tämä sammuttaa Frigaten lyhyeksi aikaa uudelleenkäynnistyksen ajaksi."
|
||||||
},
|
},
|
||||||
"explore": {
|
"explore": {
|
||||||
"plus": {
|
"plus": {
|
||||||
|
|||||||
@ -4,7 +4,8 @@
|
|||||||
"noRecordingsFoundForThisTime": "Ei tallenteita valitulta ajalta",
|
"noRecordingsFoundForThisTime": "Ei tallenteita valitulta ajalta",
|
||||||
"submitFrigatePlus": {
|
"submitFrigatePlus": {
|
||||||
"title": "Lähetä tämä kuva Frigate+:aan?",
|
"title": "Lähetä tämä kuva Frigate+:aan?",
|
||||||
"submit": "Lähetä"
|
"submit": "Lähetä",
|
||||||
|
"previewError": "Pysäytyskuvan esikatselua ei voi ladata. Tallenne ei ole ehkä saatavissa tällä hetkellä."
|
||||||
},
|
},
|
||||||
"livePlayerRequiredIOSVersion": "iOS 17.1 tai uudempi vaaditaan tälle suoratoistotyypille.",
|
"livePlayerRequiredIOSVersion": "iOS 17.1 tai uudempi vaaditaan tälle suoratoistotyypille.",
|
||||||
"streamOffline": {
|
"streamOffline": {
|
||||||
|
|||||||
@ -1 +1,22 @@
|
|||||||
{}
|
{
|
||||||
|
"label": "Kamerakonfiguraatio",
|
||||||
|
"name": {
|
||||||
|
"label": "Kameran nimi",
|
||||||
|
"description": "Kameran nimi vaaditaan"
|
||||||
|
},
|
||||||
|
"friendly_name": {
|
||||||
|
"label": "Kutsumanimi",
|
||||||
|
"description": "Kameran kutsumanimeä käytetään Frigaten käyttöliittymässä"
|
||||||
|
},
|
||||||
|
"enabled": {
|
||||||
|
"description": "Käytössä"
|
||||||
|
},
|
||||||
|
"audio": {
|
||||||
|
"label": "Ääni tapahtumat",
|
||||||
|
"description": "Äänipohjaisen havaitsemisen asetukset tälle kameralle.",
|
||||||
|
"enabled": {
|
||||||
|
"label": "Ota ääni havainnointi käyttöön",
|
||||||
|
"description": "Ota tai poista käytöstä ääni tapahtuman havaiseminen tälle kameralle."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1 +1,21 @@
|
|||||||
{}
|
{
|
||||||
|
"version": {
|
||||||
|
"label": "Nykyinen konfigurointiversio"
|
||||||
|
},
|
||||||
|
"safe_mode": {
|
||||||
|
"label": "Vikasietotila",
|
||||||
|
"description": "Kun käytössä, käynnistä Frigate vikasietotilassa rajoitetuilla ominaisuuksilla vianselvitystä varten."
|
||||||
|
},
|
||||||
|
"logger": {
|
||||||
|
"label": "Lokitus",
|
||||||
|
"default": {
|
||||||
|
"label": "Lokituksen taso"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"audio": {
|
||||||
|
"label": "Ääni tapahtumat",
|
||||||
|
"enabled": {
|
||||||
|
"label": "Ota ääni havainnointi käyttöön"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1 +1,30 @@
|
|||||||
{}
|
{
|
||||||
|
"audio": {
|
||||||
|
"global": {
|
||||||
|
"detection": "Globaali tunnistus",
|
||||||
|
"sensitivity": "Globaali herkkyys"
|
||||||
|
},
|
||||||
|
"cameras": {
|
||||||
|
"detection": "Havaitseminen",
|
||||||
|
"sensitivity": "Herkkyys"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"timestamp_style": {
|
||||||
|
"global": {
|
||||||
|
"appearance": "Globaali vaikutelma"
|
||||||
|
},
|
||||||
|
"cameras": {
|
||||||
|
"appearance": "Vaikutelma"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"motion": {
|
||||||
|
"global": {
|
||||||
|
"sensitivity": "Globaali herkkyys",
|
||||||
|
"algorithm": "Globaali algoritmi"
|
||||||
|
},
|
||||||
|
"cameras": {
|
||||||
|
"sensitivity": "Herkkyys",
|
||||||
|
"algorithm": "Algoritmi"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1 +1,13 @@
|
|||||||
{}
|
{
|
||||||
|
"minimum": "Täytyy olla vähintään {{limit}}",
|
||||||
|
"maximum": "Täytyy olla korkeitaan {{limit}}",
|
||||||
|
"exclusiveMinimum": "Täytyy olla suurempi kuin {{limit}}",
|
||||||
|
"exclusiveMaximum": "Täytyy olla vähemmän kuin {{limit}}",
|
||||||
|
"minLength": "Täytyy olla vähintään {{limit}} merkkiä",
|
||||||
|
"maxLength": "Täytyy olla enintään {{limit}} merkkiä",
|
||||||
|
"minItems": "Täytyy olla vähintään {{limit}} kappaletta",
|
||||||
|
"maxItems": "Täytyy olla enintään {{limit}} kappaletta",
|
||||||
|
"pattern": "Väärä formaatti",
|
||||||
|
"required": "Tämä kenttä on pakollinen",
|
||||||
|
"type": "Väärä arvon tyyppi"
|
||||||
|
}
|
||||||
|
|||||||
@ -2,10 +2,16 @@
|
|||||||
"documentTitle": "Luokittelumallit - Frigate",
|
"documentTitle": "Luokittelumallit - Frigate",
|
||||||
"details": {
|
"details": {
|
||||||
"scoreInfo": "Pistemäärä edustaa tämän objektin kaikkien havaintojen keskimääräistä luokitteluvarmuutta.",
|
"scoreInfo": "Pistemäärä edustaa tämän objektin kaikkien havaintojen keskimääräistä luokitteluvarmuutta.",
|
||||||
"none": "Ei mitään"
|
"none": "Ei mitään",
|
||||||
|
"unknown": "Tuntematon"
|
||||||
},
|
},
|
||||||
"button": {
|
"button": {
|
||||||
"deleteImages": "Poista kuvat",
|
"deleteImages": "Poista kuvat",
|
||||||
"trainModel": "Kouluta malli"
|
"trainModel": "Kouluta malli",
|
||||||
|
"deleteClassificationAttempts": "Poista luokitellut kuvat",
|
||||||
|
"deleteCategory": "Poista luokka",
|
||||||
|
"addClassification": "Lisää luokitus",
|
||||||
|
"deleteModels": "Poista mallit",
|
||||||
|
"editModel": "Muokkaa mallia"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,10 @@
|
|||||||
"empty": {
|
"empty": {
|
||||||
"detection": "Ei havaintoja tarkastettavaksi",
|
"detection": "Ei havaintoja tarkastettavaksi",
|
||||||
"motion": "Ei liiketietoja",
|
"motion": "Ei liiketietoja",
|
||||||
"alert": "Ei hälyytyksiä tarkastettavaksi"
|
"alert": "Ei hälyytyksiä tarkastettavaksi",
|
||||||
|
"recordingsDisabled": {
|
||||||
|
"title": "Tallenteet täytyy ottaa käyttöön"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"detections": "Havainnot",
|
"detections": "Havainnot",
|
||||||
"motion": {
|
"motion": {
|
||||||
@ -11,7 +14,9 @@
|
|||||||
"only": "Vain liike"
|
"only": "Vain liike"
|
||||||
},
|
},
|
||||||
"allCameras": "Kaikki kamerat",
|
"allCameras": "Kaikki kamerat",
|
||||||
"timeline": "Aikajana",
|
"timeline": {
|
||||||
|
"label": "Aikajana"
|
||||||
|
},
|
||||||
"timeline.aria": "Valitse aikajana",
|
"timeline.aria": "Valitse aikajana",
|
||||||
"events": {
|
"events": {
|
||||||
"label": "Tapahtumat",
|
"label": "Tapahtumat",
|
||||||
|
|||||||
@ -8,13 +8,21 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"noExports": "Ei vietyjä kohteita",
|
"noExports": "Ei vietyjä kohteita",
|
||||||
"deleteExport": "Poista viety kohde",
|
"deleteExport": {
|
||||||
|
"label": "Poista vienti"
|
||||||
|
},
|
||||||
"editExport": {
|
"editExport": {
|
||||||
"title": "Nimeä uudelleen",
|
"title": "Nimeä uudelleen",
|
||||||
"desc": "Anna uusi nimi viedylle kohteelle.",
|
"desc": "Anna uusi nimi viedylle kohteelle.",
|
||||||
"saveExport": "Tallenna vienti"
|
"saveExport": "Tallenna vienti"
|
||||||
},
|
},
|
||||||
"tooltip": {
|
"tooltip": {
|
||||||
"editName": "Muokkaa nimeä"
|
"editName": "Muokkaa nimeä",
|
||||||
|
"shareExport": "Jaa vienti",
|
||||||
|
"downloadVideo": "Lataa video"
|
||||||
|
},
|
||||||
|
"headings": {
|
||||||
|
"cases": "Tapaukset",
|
||||||
|
"uncategorizedExports": "Kategorisoimattomat viennit"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,8 @@
|
|||||||
"description": {
|
"description": {
|
||||||
"addFace": "Opastus: Uuden kokoelman lisääminen Kasvokirjastoon.",
|
"addFace": "Opastus: Uuden kokoelman lisääminen Kasvokirjastoon.",
|
||||||
"invalidName": "Virheellinen nimi. Nimi voi sisältää vain merkkejä, numeroita, välejä, heittomerkkejä, alaviivoja ja väliviivoja.",
|
"invalidName": "Virheellinen nimi. Nimi voi sisältää vain merkkejä, numeroita, välejä, heittomerkkejä, alaviivoja ja väliviivoja.",
|
||||||
"placeholder": "Anna nimi kokoelmalle"
|
"placeholder": "Anna nimi kokoelmalle",
|
||||||
|
"nameCannotContainHash": "Nimi ei voi sisältää \"#\"."
|
||||||
},
|
},
|
||||||
"uploadFaceImage": {
|
"uploadFaceImage": {
|
||||||
"desc": "Lähetä kuva kasvojen tunnistukseen ja lisää se sivulle {{pageToggle}}",
|
"desc": "Lähetä kuva kasvojen tunnistukseen ja lisää se sivulle {{pageToggle}}",
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"documentTitle": "Suora - Frigate",
|
"documentTitle": {
|
||||||
|
"default": "Suora - Frigate"
|
||||||
|
},
|
||||||
"documentTitle.withCamera": "{{camera}} - Suora - Frigate",
|
"documentTitle.withCamera": "{{camera}} - Suora - Frigate",
|
||||||
"lowBandwidthMode": "Pienen kaistanleveyden tila",
|
"lowBandwidthMode": "Pienen kaistanleveyden tila",
|
||||||
"twoWayTalk": {
|
"twoWayTalk": {
|
||||||
|
|||||||
@ -11,7 +11,9 @@
|
|||||||
"authentication": "Autentikointiuasetukset - Frigate",
|
"authentication": "Autentikointiuasetukset - Frigate",
|
||||||
"notifications": "Ilmoitusasetukset - Frigate",
|
"notifications": "Ilmoitusasetukset - Frigate",
|
||||||
"enrichments": "Laajennusasetukset – Frigate",
|
"enrichments": "Laajennusasetukset – Frigate",
|
||||||
"cameraManagement": "Hallitse Kameroita - Frigate"
|
"cameraManagement": "Hallitse Kameroita - Frigate",
|
||||||
|
"globalConfig": "Globaali konfiguraatio - Frigate",
|
||||||
|
"cameraConfig": "Kamera konfiguraatio - Frigate"
|
||||||
},
|
},
|
||||||
"menu": {
|
"menu": {
|
||||||
"ui": "Käyttöliittymä",
|
"ui": "Käyttöliittymä",
|
||||||
|
|||||||
@ -20,6 +20,10 @@
|
|||||||
"fetchingLogsFailed": "Virhe noudettaessa lokeja: {{errorMessage}}",
|
"fetchingLogsFailed": "Virhe noudettaessa lokeja: {{errorMessage}}",
|
||||||
"whileStreamingLogs": "Virhe toistettaessa lokeja: {{errorMessage}}"
|
"whileStreamingLogs": "Virhe toistettaessa lokeja: {{errorMessage}}"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"websocket": {
|
||||||
|
"label": "Viestit",
|
||||||
|
"pause": "Pysäytä"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"documentTitle": {
|
"documentTitle": {
|
||||||
@ -30,7 +34,8 @@
|
|||||||
"logs": {
|
"logs": {
|
||||||
"frigate": "Frigaten lokit - Frigate",
|
"frigate": "Frigaten lokit - Frigate",
|
||||||
"go2rtc": "Go2RTC lokit - Frigate",
|
"go2rtc": "Go2RTC lokit - Frigate",
|
||||||
"nginx": "Nginx lokit - Frigate"
|
"nginx": "Nginx lokit - Frigate",
|
||||||
|
"websocket": "Viestilokit - Frigate"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"title": "Järjestelmä",
|
"title": "Järjestelmä",
|
||||||
|
|||||||
@ -4,7 +4,8 @@
|
|||||||
"noPreviewFound": "Aucun aperçu trouvé",
|
"noPreviewFound": "Aucun aperçu trouvé",
|
||||||
"submitFrigatePlus": {
|
"submitFrigatePlus": {
|
||||||
"title": "Soumettre cette image à Frigate+ ?",
|
"title": "Soumettre cette image à Frigate+ ?",
|
||||||
"submit": "Soumettre"
|
"submit": "Soumettre",
|
||||||
|
"previewError": "Impossible de télécharger le snapshot. L'enregistrement ne pas disponible sur cette période."
|
||||||
},
|
},
|
||||||
"streamOffline": {
|
"streamOffline": {
|
||||||
"title": "Flux hors ligne",
|
"title": "Flux hors ligne",
|
||||||
|
|||||||
@ -35,5 +35,10 @@
|
|||||||
"newCaseOption": "Créer un nouveau dossier",
|
"newCaseOption": "Créer un nouveau dossier",
|
||||||
"nameLabel": "Nom du dossier",
|
"nameLabel": "Nom du dossier",
|
||||||
"descriptionLabel": "Description"
|
"descriptionLabel": "Description"
|
||||||
|
},
|
||||||
|
"deleteCase": {
|
||||||
|
"desc": "Êtes-vous sûr de vouloir supprimer {{caseName}}?",
|
||||||
|
"descKeepExports": "Les exports seront disponibles comme exports non catégorisés.",
|
||||||
|
"deleteExports": "Supprimer aussi les exports"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -113,7 +113,7 @@
|
|||||||
"desc": "Frigate のセマンティック検索では、画像そのもの、ユーザー定義のテキスト説明、または自動生成された説明を用いて、レビュー項目内の追跡オブジェクトを検索できます。",
|
"desc": "Frigate のセマンティック検索では、画像そのもの、ユーザー定義のテキスト説明、または自動生成された説明を用いて、レビュー項目内の追跡オブジェクトを検索できます。",
|
||||||
"reindexNow": {
|
"reindexNow": {
|
||||||
"label": "今すぐ再インデックス",
|
"label": "今すぐ再インデックス",
|
||||||
"desc": "再インデックスは、すべての追跡オブジェクトの埋め込みを再生成します。バックグラウンドで実行され、追跡オブジェクト数によっては CPU を使い切り、相応の時間がかかる場合があります。",
|
"desc": "インデックスの再構築を行うと、追跡対象のすべてのオブジェクトの埋め込みが再生成されます。この処理はバックグラウンドで実行され、追跡対象のオブジェクトの数によってはCPU使用率が最大になり、かなりの時間がかかる場合があります。",
|
||||||
"confirmTitle": "再インデックスの確認",
|
"confirmTitle": "再インデックスの確認",
|
||||||
"confirmDesc": "すべての追跡オブジェクトの埋め込みを再インデックスしますか?この処理はバックグラウンドで実行されますが、CPU を使い切り、時間がかかる場合があります。進行状況は[探索]ページで確認できます。",
|
"confirmDesc": "すべての追跡オブジェクトの埋め込みを再インデックスしますか?この処理はバックグラウンドで実行されますが、CPU を使い切り、時間がかかる場合があります。進行状況は[探索]ページで確認できます。",
|
||||||
"confirmButton": "再インデックス",
|
"confirmButton": "再インデックス",
|
||||||
|
|||||||
@ -188,7 +188,8 @@
|
|||||||
"classification": "Clasificare",
|
"classification": "Clasificare",
|
||||||
"chat": "Chat",
|
"chat": "Chat",
|
||||||
"actions": "Acțiuni",
|
"actions": "Acțiuni",
|
||||||
"profiles": "Profile"
|
"profiles": "Profile",
|
||||||
|
"features": "Funcționalități"
|
||||||
},
|
},
|
||||||
"button": {
|
"button": {
|
||||||
"cameraAudio": "Sunet cameră",
|
"cameraAudio": "Sunet cameră",
|
||||||
|
|||||||
@ -273,7 +273,8 @@
|
|||||||
"classification": "目标分类",
|
"classification": "目标分类",
|
||||||
"actions": "操作",
|
"actions": "操作",
|
||||||
"chat": "聊天",
|
"chat": "聊天",
|
||||||
"profiles": "配置模板"
|
"profiles": "配置模板",
|
||||||
|
"features": "功能"
|
||||||
},
|
},
|
||||||
"toast": {
|
"toast": {
|
||||||
"copyUrlToClipboard": "已复制链接到剪贴板。",
|
"copyUrlToClipboard": "已复制链接到剪贴板。",
|
||||||
|
|||||||
@ -1356,7 +1356,13 @@
|
|||||||
"enableDesc": "暂时禁用已开启的摄像头,直到 Frigate 重启。禁用摄像头会完全停止 Frigate 对该摄像头视频流的处理。检测、录像和调试功能将不可用。<br /> <em>注意:这不会禁用 go2rtc 的转推流。</em>",
|
"enableDesc": "暂时禁用已开启的摄像头,直到 Frigate 重启。禁用摄像头会完全停止 Frigate 对该摄像头视频流的处理。检测、录像和调试功能将不可用。<br /> <em>注意:这不会禁用 go2rtc 的转推流。</em>",
|
||||||
"disableLabel": "关闭摄像头",
|
"disableLabel": "关闭摄像头",
|
||||||
"disableDesc": "开启在当前在界面中不可见且在配置中被禁用的摄像头。启用后需要重启 Frigate 才能生效。",
|
"disableDesc": "开启在当前在界面中不可见且在配置中被禁用的摄像头。启用后需要重启 Frigate 才能生效。",
|
||||||
"enableSuccess": "已在配置中启用 {{cameraName}}。请重启 Frigate 以应用更改。"
|
"enableSuccess": "已在配置中启用 {{cameraName}}。请重启 Frigate 以应用更改。",
|
||||||
|
"friendlyName": {
|
||||||
|
"edit": "修改摄像头显示名称",
|
||||||
|
"title": "修改显示名称",
|
||||||
|
"description": "设置该摄像机在 Frigate 用户界面中显示的名称。若留空,则使用摄像机 ID。",
|
||||||
|
"rename": "重命名"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"cameraConfig": {
|
"cameraConfig": {
|
||||||
"add": "添加摄像头",
|
"add": "添加摄像头",
|
||||||
|
|||||||
@ -65,10 +65,14 @@ import {
|
|||||||
globalCameraDefaultSections,
|
globalCameraDefaultSections,
|
||||||
buildOverrides,
|
buildOverrides,
|
||||||
buildConfigDataForPath,
|
buildConfigDataForPath,
|
||||||
|
flattenOverrides,
|
||||||
getBaseCameraSectionValue,
|
getBaseCameraSectionValue,
|
||||||
sanitizeSectionData as sharedSanitizeSectionData,
|
sanitizeSectionData as sharedSanitizeSectionData,
|
||||||
requiresRestartForOverrides as sharedRequiresRestartForOverrides,
|
requiresRestartForOverrides as sharedRequiresRestartForOverrides,
|
||||||
} from "@/utils/configUtil";
|
} from "@/utils/configUtil";
|
||||||
|
import SaveAllPreviewPopover, {
|
||||||
|
type SaveAllPreviewItem,
|
||||||
|
} from "@/components/overlay/detail/SaveAllPreviewPopover";
|
||||||
import RestartDialog from "@/components/overlay/dialog/RestartDialog";
|
import RestartDialog from "@/components/overlay/dialog/RestartDialog";
|
||||||
import { useRestart } from "@/api/ws";
|
import { useRestart } from "@/api/ws";
|
||||||
import type {
|
import type {
|
||||||
@ -913,6 +917,34 @@ export function ConfigSection({
|
|||||||
);
|
);
|
||||||
}, [sectionConfig?.renderers, sectionPath, cameraName, setPendingData]);
|
}, [sectionConfig?.renderers, sectionPath, cameraName, setPendingData]);
|
||||||
|
|
||||||
|
// Build a flat list of pending field changes for this section only.
|
||||||
|
// Mirrors the global Save All preview but scoped to the current section so
|
||||||
|
// users can inspect what will be saved without leaving the section.
|
||||||
|
const sectionPreviewItems = useMemo<SaveAllPreviewItem[]>(() => {
|
||||||
|
if (!hasChanges) return [];
|
||||||
|
if (!effectiveOverrides || typeof effectiveOverrides !== "object") {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
const flattened = flattenOverrides(effectiveOverrides as JsonValue);
|
||||||
|
return flattened.map(({ path, value }) => ({
|
||||||
|
scope: effectiveLevel,
|
||||||
|
cameraName,
|
||||||
|
profileName: profileName
|
||||||
|
? (profileFriendlyName ?? profileName)
|
||||||
|
: undefined,
|
||||||
|
fieldPath: path ? `${sectionPath}.${path}` : sectionPath,
|
||||||
|
value,
|
||||||
|
}));
|
||||||
|
}, [
|
||||||
|
hasChanges,
|
||||||
|
effectiveOverrides,
|
||||||
|
effectiveLevel,
|
||||||
|
cameraName,
|
||||||
|
profileName,
|
||||||
|
profileFriendlyName,
|
||||||
|
sectionPath,
|
||||||
|
]);
|
||||||
|
|
||||||
if (!modifiedSchema) {
|
if (!modifiedSchema) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -1018,6 +1050,12 @@ export function ConfigSection({
|
|||||||
defaultValue: "You have unsaved changes",
|
defaultValue: "You have unsaved changes",
|
||||||
})}
|
})}
|
||||||
</span>
|
</span>
|
||||||
|
<SaveAllPreviewPopover
|
||||||
|
items={sectionPreviewItems}
|
||||||
|
className="h-7 w-7"
|
||||||
|
align="start"
|
||||||
|
side="top"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="flex w-full flex-col gap-2 sm:flex-row sm:items-center md:w-auto">
|
<div className="flex w-full flex-col gap-2 sm:flex-row sm:items-center md:w-auto">
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import ActivityIndicator from "@/components/indicators/activity-indicator";
|
||||||
import TextEntry from "@/components/input/TextEntry";
|
import TextEntry from "@/components/input/TextEntry";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
@ -19,7 +20,9 @@ type TextEntryDialogProps = {
|
|||||||
setOpen: (open: boolean) => void;
|
setOpen: (open: boolean) => void;
|
||||||
onSave: (text: string) => void;
|
onSave: (text: string) => void;
|
||||||
defaultValue?: string;
|
defaultValue?: string;
|
||||||
|
placeholder?: string;
|
||||||
allowEmpty?: boolean;
|
allowEmpty?: boolean;
|
||||||
|
isSaving?: boolean;
|
||||||
regexPattern?: RegExp;
|
regexPattern?: RegExp;
|
||||||
regexErrorMessage?: string;
|
regexErrorMessage?: string;
|
||||||
forbiddenPattern?: RegExp;
|
forbiddenPattern?: RegExp;
|
||||||
@ -33,7 +36,9 @@ export default function TextEntryDialog({
|
|||||||
setOpen,
|
setOpen,
|
||||||
onSave,
|
onSave,
|
||||||
defaultValue = "",
|
defaultValue = "",
|
||||||
|
placeholder,
|
||||||
allowEmpty = false,
|
allowEmpty = false,
|
||||||
|
isSaving = false,
|
||||||
regexPattern,
|
regexPattern,
|
||||||
regexErrorMessage,
|
regexErrorMessage,
|
||||||
forbiddenPattern,
|
forbiddenPattern,
|
||||||
@ -50,6 +55,7 @@ export default function TextEntryDialog({
|
|||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<TextEntry
|
<TextEntry
|
||||||
defaultValue={defaultValue}
|
defaultValue={defaultValue}
|
||||||
|
placeholder={placeholder}
|
||||||
allowEmpty={allowEmpty}
|
allowEmpty={allowEmpty}
|
||||||
onSave={onSave}
|
onSave={onSave}
|
||||||
regexPattern={regexPattern}
|
regexPattern={regexPattern}
|
||||||
@ -58,11 +64,22 @@ export default function TextEntryDialog({
|
|||||||
forbiddenErrorMessage={forbiddenErrorMessage}
|
forbiddenErrorMessage={forbiddenErrorMessage}
|
||||||
>
|
>
|
||||||
<DialogFooter className={cn("pt-4", isMobile && "gap-2")}>
|
<DialogFooter className={cn("pt-4", isMobile && "gap-2")}>
|
||||||
<Button type="button" onClick={() => setOpen(false)}>
|
<Button
|
||||||
|
type="button"
|
||||||
|
disabled={isSaving}
|
||||||
|
onClick={() => setOpen(false)}
|
||||||
|
>
|
||||||
{t("button.cancel")}
|
{t("button.cancel")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="select" type="submit">
|
<Button variant="select" type="submit" disabled={isSaving}>
|
||||||
{t("button.save")}
|
{isSaving ? (
|
||||||
|
<div className="flex flex-row items-center gap-2">
|
||||||
|
<ActivityIndicator className="size-4" />
|
||||||
|
<span>{t("button.saving")}</span>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
t("button.save")
|
||||||
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
</TextEntry>
|
</TextEntry>
|
||||||
|
|||||||
@ -28,11 +28,7 @@ import useOptimisticState from "@/hooks/use-optimistic-state";
|
|||||||
import { isMobile } from "react-device-detect";
|
import { isMobile } from "react-device-detect";
|
||||||
import { FaVideo } from "react-icons/fa";
|
import { FaVideo } from "react-icons/fa";
|
||||||
import { CameraConfig, FrigateConfig } from "@/types/frigateConfig";
|
import { CameraConfig, FrigateConfig } from "@/types/frigateConfig";
|
||||||
import type {
|
import type { ConfigSectionData, JsonObject } from "@/types/configForm";
|
||||||
ConfigSectionData,
|
|
||||||
JsonObject,
|
|
||||||
JsonValue,
|
|
||||||
} from "@/types/configForm";
|
|
||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
import FilterSwitch from "@/components/filter/FilterSwitch";
|
import FilterSwitch from "@/components/filter/FilterSwitch";
|
||||||
import { ZoneMaskFilterButton } from "@/components/filter/ZoneMaskFilter";
|
import { ZoneMaskFilterButton } from "@/components/filter/ZoneMaskFilter";
|
||||||
@ -93,6 +89,7 @@ import { mutate } from "swr";
|
|||||||
import { RJSFSchema } from "@rjsf/utils";
|
import { RJSFSchema } from "@rjsf/utils";
|
||||||
import {
|
import {
|
||||||
buildConfigDataForPath,
|
buildConfigDataForPath,
|
||||||
|
flattenOverrides,
|
||||||
parseProfileFromSectionPath,
|
parseProfileFromSectionPath,
|
||||||
prepareSectionSavePayload,
|
prepareSectionSavePayload,
|
||||||
PROFILE_ELIGIBLE_SECTIONS,
|
PROFILE_ELIGIBLE_SECTIONS,
|
||||||
@ -190,25 +187,6 @@ const parsePendingDataKey = (pendingDataKey: string) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const flattenOverrides = (
|
|
||||||
value: JsonValue | undefined,
|
|
||||||
path: string[] = [],
|
|
||||||
): Array<{ path: string; value: JsonValue }> => {
|
|
||||||
if (value === undefined) return [];
|
|
||||||
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
||||||
return [{ path: path.join("."), value }];
|
|
||||||
}
|
|
||||||
|
|
||||||
const entries = Object.entries(value);
|
|
||||||
if (entries.length === 0) {
|
|
||||||
return [{ path: path.join("."), value: {} }];
|
|
||||||
}
|
|
||||||
|
|
||||||
return entries.flatMap(([key, entryValue]) =>
|
|
||||||
flattenOverrides(entryValue, [...path, key]),
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const createSectionPage = (
|
const createSectionPage = (
|
||||||
sectionKey: string,
|
sectionKey: string,
|
||||||
level: "global" | "camera",
|
level: "global" | "camera",
|
||||||
|
|||||||
@ -219,6 +219,32 @@ export function buildOverrides(
|
|||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// flattenOverrides — turn an overrides object into a list of leaf paths
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Walks a nested overrides value and produces a flat list of `{ path, value }`
|
||||||
|
// entries, one per leaf. Used by save/preview UIs to enumerate the individual
|
||||||
|
// fields that will be changed.
|
||||||
|
export function flattenOverrides(
|
||||||
|
value: JsonValue | undefined,
|
||||||
|
path: string[] = [],
|
||||||
|
): Array<{ path: string; value: JsonValue }> {
|
||||||
|
if (value === undefined) return [];
|
||||||
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
||||||
|
return [{ path: path.join("."), value }];
|
||||||
|
}
|
||||||
|
|
||||||
|
const entries = Object.entries(value);
|
||||||
|
if (entries.length === 0) {
|
||||||
|
return [{ path: path.join("."), value: {} }];
|
||||||
|
}
|
||||||
|
|
||||||
|
return entries.flatMap(([key, entryValue]) =>
|
||||||
|
flattenOverrides(entryValue, [...path, key]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// sanitizeSectionData — normalize config values and strip hidden fields
|
// sanitizeSectionData — normalize config values and strip hidden fields
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import { useTranslation } from "react-i18next";
|
|||||||
import CameraEditForm from "@/components/settings/CameraEditForm";
|
import CameraEditForm from "@/components/settings/CameraEditForm";
|
||||||
import CameraWizardDialog from "@/components/settings/CameraWizardDialog";
|
import CameraWizardDialog from "@/components/settings/CameraWizardDialog";
|
||||||
import DeleteCameraDialog from "@/components/overlay/dialog/DeleteCameraDialog";
|
import DeleteCameraDialog from "@/components/overlay/dialog/DeleteCameraDialog";
|
||||||
import { LuPlus, LuTrash2 } from "react-icons/lu";
|
import { LuPencil, LuPlus, LuTrash2 } from "react-icons/lu";
|
||||||
import { IoMdArrowRoundBack } from "react-icons/io";
|
import { IoMdArrowRoundBack } from "react-icons/io";
|
||||||
import { isDesktop } from "react-device-detect";
|
import { isDesktop } from "react-device-detect";
|
||||||
import { CameraNameLabel } from "@/components/camera/FriendlyNameLabel";
|
import { CameraNameLabel } from "@/components/camera/FriendlyNameLabel";
|
||||||
@ -26,6 +26,12 @@ import axios from "axios";
|
|||||||
import ActivityIndicator from "@/components/indicators/activity-indicator";
|
import ActivityIndicator from "@/components/indicators/activity-indicator";
|
||||||
import RestartDialog from "@/components/overlay/dialog/RestartDialog";
|
import RestartDialog from "@/components/overlay/dialog/RestartDialog";
|
||||||
import RestartRequiredIndicator from "@/components/indicators/RestartRequiredIndicator";
|
import RestartRequiredIndicator from "@/components/indicators/RestartRequiredIndicator";
|
||||||
|
import TextEntryDialog from "@/components/overlay/dialog/TextEntryDialog";
|
||||||
|
import {
|
||||||
|
Tooltip,
|
||||||
|
TooltipContent,
|
||||||
|
TooltipTrigger,
|
||||||
|
} from "@/components/ui/tooltip";
|
||||||
import type { ProfileState } from "@/types/profile";
|
import type { ProfileState } from "@/types/profile";
|
||||||
import { getProfileColor } from "@/utils/profileColors";
|
import { getProfileColor } from "@/utils/profileColors";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
@ -161,7 +167,13 @@ export default function CameraManagementView({
|
|||||||
key={camera}
|
key={camera}
|
||||||
className="flex flex-row items-center justify-between"
|
className="flex flex-row items-center justify-between"
|
||||||
>
|
>
|
||||||
<CameraNameLabel camera={camera} />
|
<div className="flex items-center gap-1">
|
||||||
|
<CameraNameLabel camera={camera} />
|
||||||
|
<CameraFriendlyNameEditor
|
||||||
|
cameraName={camera}
|
||||||
|
onConfigChanged={updateConfig}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<CameraEnableSwitch cameraName={camera} />
|
<CameraEnableSwitch cameraName={camera} />
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
@ -297,6 +309,103 @@ function CameraEnableSwitch({ cameraName }: CameraEnableSwitchProps) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CameraFriendlyNameEditorProps = {
|
||||||
|
cameraName: string;
|
||||||
|
onConfigChanged: () => Promise<unknown>;
|
||||||
|
};
|
||||||
|
|
||||||
|
function CameraFriendlyNameEditor({
|
||||||
|
cameraName,
|
||||||
|
onConfigChanged,
|
||||||
|
}: CameraFriendlyNameEditorProps) {
|
||||||
|
const { t } = useTranslation(["views/settings", "common"]);
|
||||||
|
const { data: config } = useSWR<FrigateConfig>("config");
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
|
|
||||||
|
const currentFriendlyName = config?.cameras?.[cameraName]?.friendly_name;
|
||||||
|
|
||||||
|
const onSave = useCallback(
|
||||||
|
async (text: string) => {
|
||||||
|
if (isSaving) return;
|
||||||
|
setIsSaving(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await axios.put("config/set", {
|
||||||
|
requires_restart: 0,
|
||||||
|
config_data: {
|
||||||
|
cameras: {
|
||||||
|
[cameraName]: {
|
||||||
|
friendly_name: text.trim() || null,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await onConfigChanged();
|
||||||
|
setOpen(false);
|
||||||
|
|
||||||
|
toast.success(t("toast.save.success", { ns: "common" }), {
|
||||||
|
position: "top-center",
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
const errorMessage =
|
||||||
|
axios.isAxiosError(error) &&
|
||||||
|
(error.response?.data?.message || error.response?.data?.detail)
|
||||||
|
? error.response?.data?.message || error.response?.data?.detail
|
||||||
|
: t("toast.save.error.noMessage", { ns: "common" });
|
||||||
|
|
||||||
|
toast.error(
|
||||||
|
t("toast.save.error.title", { errorMessage, ns: "common" }),
|
||||||
|
{ position: "top-center" },
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
setIsSaving(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[cameraName, isSaving, onConfigChanged, t],
|
||||||
|
);
|
||||||
|
|
||||||
|
const renameLabel = t("cameraManagement.streams.friendlyName.rename", {
|
||||||
|
ns: "views/settings",
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger asChild>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
className="size-7"
|
||||||
|
aria-label={renameLabel}
|
||||||
|
onClick={() => setOpen(true)}
|
||||||
|
disabled={isSaving}
|
||||||
|
>
|
||||||
|
<LuPencil className="size-3.5" />
|
||||||
|
</Button>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>{renameLabel}</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
<TextEntryDialog
|
||||||
|
open={open}
|
||||||
|
setOpen={setOpen}
|
||||||
|
title={t("cameraManagement.streams.friendlyName.title", {
|
||||||
|
ns: "views/settings",
|
||||||
|
})}
|
||||||
|
description={t("cameraManagement.streams.friendlyName.description", {
|
||||||
|
ns: "views/settings",
|
||||||
|
})}
|
||||||
|
defaultValue={currentFriendlyName ?? ""}
|
||||||
|
placeholder={currentFriendlyName ? undefined : cameraName}
|
||||||
|
allowEmpty
|
||||||
|
isSaving={isSaving}
|
||||||
|
onSave={onSave}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
type CameraConfigEnableSwitchProps = {
|
type CameraConfigEnableSwitchProps = {
|
||||||
cameraName: string;
|
cameraName: string;
|
||||||
setRestartDialogOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
setRestartDialogOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user