mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-06-21 03:41:55 +03:00
Tweaks (#23367)
Some checks are pending
CI / AMD64 Build (push) Waiting to run
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
Some checks are pending
CI / AMD64 Build (push) Waiting to run
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
* add ptz presets and default role widgets * language tweaks * fix width in triggers view * tweak iOS PWA message in notifications settings * deprecate ui.date_style and ui.time_style these have been unused since date/time formatting has been pushed to i18n * add config migrator to remove date_style and time_style * remove date_style and time_style from reference config * fix camera list scrolling in state classification wizard on mobile
This commit is contained in:
parent
ae60197cb0
commit
47a06c8b30
@ -1083,22 +1083,6 @@ ui:
|
|||||||
# Optional: Set the time format used.
|
# Optional: Set the time format used.
|
||||||
# Options are browser, 12hour, or 24hour (default: shown below)
|
# Options are browser, 12hour, or 24hour (default: shown below)
|
||||||
time_format: browser
|
time_format: browser
|
||||||
# Optional: Set the date style for a specified length.
|
|
||||||
# Options are: full, long, medium, short
|
|
||||||
# Examples:
|
|
||||||
# short: 2/11/23
|
|
||||||
# medium: Feb 11, 2023
|
|
||||||
# full: Saturday, February 11, 2023
|
|
||||||
# (default: shown below).
|
|
||||||
date_style: short
|
|
||||||
# Optional: Set the time style for a specified length.
|
|
||||||
# Options are: full, long, medium, short
|
|
||||||
# Examples:
|
|
||||||
# short: 8:14 PM
|
|
||||||
# medium: 8:15:22 PM
|
|
||||||
# full: 8:15:22 PM Mountain Standard Time
|
|
||||||
# (default: shown below).
|
|
||||||
time_style: medium
|
|
||||||
# Optional: Set the unit system to either "imperial" or "metric" (default: metric)
|
# Optional: Set the unit system to either "imperial" or "metric" (default: metric)
|
||||||
# Used in the UI and in MQTT topics
|
# Used in the UI and in MQTT topics
|
||||||
unit_system: metric
|
unit_system: metric
|
||||||
|
|||||||
@ -146,7 +146,7 @@ class CameraConfig(FrigateBaseModel):
|
|||||||
timestamp_style: TimestampStyleConfig = Field(
|
timestamp_style: TimestampStyleConfig = Field(
|
||||||
default_factory=TimestampStyleConfig,
|
default_factory=TimestampStyleConfig,
|
||||||
title="Timestamp style",
|
title="Timestamp style",
|
||||||
description="Styling options for in-feed timestamps applied to recordings and snapshots.",
|
description="Styling options for timestamps applied to snapshots and Debug view.",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Options without global fallback
|
# Options without global fallback
|
||||||
|
|||||||
@ -45,7 +45,7 @@ class ProxyConfig(FrigateBaseModel):
|
|||||||
default_role: Optional[str] = Field(
|
default_role: Optional[str] = Field(
|
||||||
default="viewer",
|
default="viewer",
|
||||||
title="Default role",
|
title="Default role",
|
||||||
description="Default role assigned to proxy-authenticated users when no role mapping applies (admin or viewer).",
|
description="Default role assigned to proxy-authenticated users when no role mapping applies.",
|
||||||
)
|
)
|
||||||
separator: Optional[str] = Field(
|
separator: Optional[str] = Field(
|
||||||
default=",",
|
default=",",
|
||||||
|
|||||||
@ -5,7 +5,7 @@ from pydantic import Field
|
|||||||
|
|
||||||
from .base import FrigateBaseModel
|
from .base import FrigateBaseModel
|
||||||
|
|
||||||
__all__ = ["TimeFormatEnum", "DateTimeStyleEnum", "UnitSystemEnum", "UIConfig"]
|
__all__ = ["TimeFormatEnum", "UnitSystemEnum", "UIConfig"]
|
||||||
|
|
||||||
|
|
||||||
class TimeFormatEnum(str, Enum):
|
class TimeFormatEnum(str, Enum):
|
||||||
@ -14,13 +14,6 @@ class TimeFormatEnum(str, Enum):
|
|||||||
hours24 = "24hour"
|
hours24 = "24hour"
|
||||||
|
|
||||||
|
|
||||||
class DateTimeStyleEnum(str, Enum):
|
|
||||||
full = "full"
|
|
||||||
long = "long"
|
|
||||||
medium = "medium"
|
|
||||||
short = "short"
|
|
||||||
|
|
||||||
|
|
||||||
class UnitSystemEnum(str, Enum):
|
class UnitSystemEnum(str, Enum):
|
||||||
imperial = "imperial"
|
imperial = "imperial"
|
||||||
metric = "metric"
|
metric = "metric"
|
||||||
@ -37,16 +30,6 @@ class UIConfig(FrigateBaseModel):
|
|||||||
title="Time format",
|
title="Time format",
|
||||||
description="Time format to use in the UI (browser, 12hour, or 24hour).",
|
description="Time format to use in the UI (browser, 12hour, or 24hour).",
|
||||||
)
|
)
|
||||||
date_style: DateTimeStyleEnum = Field(
|
|
||||||
default=DateTimeStyleEnum.short,
|
|
||||||
title="Date style",
|
|
||||||
description="Date style to use in the UI (full, long, medium, short).",
|
|
||||||
)
|
|
||||||
time_style: DateTimeStyleEnum = Field(
|
|
||||||
default=DateTimeStyleEnum.medium,
|
|
||||||
title="Time style",
|
|
||||||
description="Time style to use in the UI (full, long, medium, short).",
|
|
||||||
)
|
|
||||||
unit_system: UnitSystemEnum = Field(
|
unit_system: UnitSystemEnum = Field(
|
||||||
default=UnitSystemEnum.metric,
|
default=UnitSystemEnum.metric,
|
||||||
title="Unit system",
|
title="Unit system",
|
||||||
|
|||||||
@ -618,6 +618,16 @@ def migrate_018_0(config: dict[str, dict[str, Any]]) -> dict[str, dict[str, Any]
|
|||||||
|
|
||||||
new_config["cameras"][name] = camera_config
|
new_config["cameras"][name] = camera_config
|
||||||
|
|
||||||
|
# Remove deprecated date_style and time_style from global ui config
|
||||||
|
global_ui = new_config.get("ui", {})
|
||||||
|
if global_ui.get("date_style") is not None:
|
||||||
|
del new_config["ui"]["date_style"]
|
||||||
|
if global_ui.get("time_style") is not None:
|
||||||
|
del new_config["ui"]["time_style"]
|
||||||
|
# Remove ui section if empty
|
||||||
|
if "ui" in new_config and not new_config["ui"]:
|
||||||
|
del new_config["ui"]
|
||||||
|
|
||||||
new_config["version"] = "0.18-0"
|
new_config["version"] = "0.18-0"
|
||||||
return new_config
|
return new_config
|
||||||
|
|
||||||
|
|||||||
@ -682,7 +682,7 @@
|
|||||||
},
|
},
|
||||||
"timestamp_style": {
|
"timestamp_style": {
|
||||||
"label": "Timestamp style",
|
"label": "Timestamp style",
|
||||||
"description": "Styling options for in-feed timestamps applied to recordings and snapshots.",
|
"description": "Styling options for timestamps applied to snapshots and Debug view.",
|
||||||
"position": {
|
"position": {
|
||||||
"label": "Timestamp position",
|
"label": "Timestamp position",
|
||||||
"description": "Position of the timestamp on the image (tl/tr/bl/br)."
|
"description": "Position of the timestamp on the image (tl/tr/bl/br)."
|
||||||
|
|||||||
@ -212,7 +212,7 @@
|
|||||||
},
|
},
|
||||||
"default_role": {
|
"default_role": {
|
||||||
"label": "Default role",
|
"label": "Default role",
|
||||||
"description": "Default role assigned to proxy-authenticated users when no role mapping applies (admin or viewer)."
|
"description": "Default role assigned to proxy-authenticated users when no role mapping applies."
|
||||||
},
|
},
|
||||||
"separator": {
|
"separator": {
|
||||||
"label": "Separator character",
|
"label": "Separator character",
|
||||||
@ -270,14 +270,6 @@
|
|||||||
"label": "Time format",
|
"label": "Time format",
|
||||||
"description": "Time format to use in the UI (browser, 12hour, or 24hour)."
|
"description": "Time format to use in the UI (browser, 12hour, or 24hour)."
|
||||||
},
|
},
|
||||||
"date_style": {
|
|
||||||
"label": "Date style",
|
|
||||||
"description": "Date style to use in the UI (full, long, medium, short)."
|
|
||||||
},
|
|
||||||
"time_style": {
|
|
||||||
"label": "Time style",
|
|
||||||
"description": "Time style to use in the UI (full, long, medium, short)."
|
|
||||||
},
|
|
||||||
"unit_system": {
|
"unit_system": {
|
||||||
"label": "Unit system",
|
"label": "Unit system",
|
||||||
"description": "Unit system for display (metric or imperial) used in the UI and MQTT."
|
"description": "Unit system for display (metric or imperial) used in the UI and MQTT."
|
||||||
|
|||||||
@ -1154,7 +1154,8 @@
|
|||||||
},
|
},
|
||||||
"notificationUnavailable": {
|
"notificationUnavailable": {
|
||||||
"title": "Notifications Unavailable",
|
"title": "Notifications Unavailable",
|
||||||
"desc": "Web push notifications require a secure context (<code>https://…</code>). This is a browser limitation. Access Frigate securely to use notifications."
|
"desc": "Web push notifications require a secure context (<code>https://…</code>). This is a browser limitation. Access Frigate securely to use notifications.",
|
||||||
|
"descPwa": "On iOS, web push notifications are only available when Frigate is installed to your Home Screen. Open the <strong>Share</strong> menu, choose <strong>Add to Home Screen</strong>, then open Frigate from the new icon to register this device for notifications."
|
||||||
},
|
},
|
||||||
"globalSettings": {
|
"globalSettings": {
|
||||||
"title": "Global Settings",
|
"title": "Global Settings",
|
||||||
@ -1674,6 +1675,17 @@
|
|||||||
"refresh": "Refresh models",
|
"refresh": "Refresh models",
|
||||||
"probeFailed": "Failed to probe models",
|
"probeFailed": "Failed to probe models",
|
||||||
"fetchedModels": "Successfully fetched model list"
|
"fetchedModels": "Successfully fetched model list"
|
||||||
|
},
|
||||||
|
"ptzPresets": {
|
||||||
|
"placeholder": "Select or enter a preset...",
|
||||||
|
"search": "Search or enter a preset...",
|
||||||
|
"noPresets": "No presets available",
|
||||||
|
"available": "Camera presets",
|
||||||
|
"useCustom": "Use \"{{value}}\""
|
||||||
|
},
|
||||||
|
"defaultRole": {
|
||||||
|
"admin": "Admin",
|
||||||
|
"viewer": "Viewer"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"globalConfig": {
|
"globalConfig": {
|
||||||
@ -1763,7 +1775,7 @@
|
|||||||
"addStream": "Add stream",
|
"addStream": "Add stream",
|
||||||
"addStreamDesc": "Enter a name for the new stream. This name will be used to reference the stream in your camera configuration.",
|
"addStreamDesc": "Enter a name for the new stream. This name will be used to reference the stream in your camera configuration.",
|
||||||
"addUrl": "Add URL",
|
"addUrl": "Add URL",
|
||||||
"streamNumber": "Stream {{index}}",
|
"sourceNumber": "Source {{index}}",
|
||||||
"streamName": "Stream name",
|
"streamName": "Stream name",
|
||||||
"streamNamePlaceholder": "e.g., front_door",
|
"streamNamePlaceholder": "e.g., front_door",
|
||||||
"streamUrlPlaceholder": "e.g., rtsp://user:pass@192.168.1.100/stream",
|
"streamUrlPlaceholder": "e.g., rtsp://user:pass@192.168.1.100/stream",
|
||||||
@ -1840,12 +1852,6 @@
|
|||||||
"12hour": "12 hour",
|
"12hour": "12 hour",
|
||||||
"24hour": "24 hour"
|
"24hour": "24 hour"
|
||||||
},
|
},
|
||||||
"TimeOrDateStyle": {
|
|
||||||
"full": "Full",
|
|
||||||
"long": "Long",
|
|
||||||
"medium": "Medium",
|
|
||||||
"short": "Short"
|
|
||||||
},
|
|
||||||
"unitSystem": {
|
"unitSystem": {
|
||||||
"metric": "Metric",
|
"metric": "Metric",
|
||||||
"imperial": "Imperial"
|
"imperial": "Imperial"
|
||||||
@ -1928,6 +1934,9 @@
|
|||||||
},
|
},
|
||||||
"semanticSearch": {
|
"semanticSearch": {
|
||||||
"jinav2SmallModelSize": "The 'small' size with the Jina V2 model has high RAM and inference cost. The 'large' model with a discrete GPU is recommended."
|
"jinav2SmallModelSize": "The 'small' size with the Jina V2 model has high RAM and inference cost. The 'large' model with a discrete GPU is recommended."
|
||||||
|
},
|
||||||
|
"onvif": {
|
||||||
|
"autotrackingNoZones": "Autotracking requires at least one zone. Define a zone for this camera in Masks / Zones, then set it as a required zone below."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,6 +51,7 @@ export default function Step2StateArea({
|
|||||||
const [imageLoaded, setImageLoaded] = useState(false);
|
const [imageLoaded, setImageLoaded] = useState(false);
|
||||||
|
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
|
const popoverContainerRef = useRef<HTMLDivElement>(null);
|
||||||
const imageRef = useRef<HTMLImageElement>(null);
|
const imageRef = useRef<HTMLImageElement>(null);
|
||||||
const stageRef = useRef<Konva.Stage>(null);
|
const stageRef = useRef<Konva.Stage>(null);
|
||||||
const rectRef = useRef<Konva.Rect>(null);
|
const rectRef = useRef<Konva.Rect>(null);
|
||||||
@ -224,7 +225,7 @@ export default function Step2StateArea({
|
|||||||
const canContinue = cameraAreas.length > 0;
|
const canContinue = cameraAreas.length > 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-4">
|
<div ref={popoverContainerRef} className="flex flex-col gap-4">
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex gap-4 overflow-hidden",
|
"flex gap-4 overflow-hidden",
|
||||||
@ -255,6 +256,7 @@ export default function Step2StateArea({
|
|||||||
className="scrollbar-container w-64 border bg-background p-3 shadow-lg"
|
className="scrollbar-container w-64 border bg-background p-3 shadow-lg"
|
||||||
align="start"
|
align="start"
|
||||||
sideOffset={5}
|
sideOffset={5}
|
||||||
|
container={popoverContainerRef.current}
|
||||||
onOpenAutoFocus={(e) => e.preventDefault()}
|
onOpenAutoFocus={(e) => e.preventDefault()}
|
||||||
>
|
>
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
|
|||||||
@ -25,6 +25,24 @@ const onvif: SectionConfigOverrides = {
|
|||||||
advancedFields: ["tls_insecure", "ignore_time_mismatch"],
|
advancedFields: ["tls_insecure", "ignore_time_mismatch"],
|
||||||
overrideFields: [],
|
overrideFields: [],
|
||||||
restartRequired: ["autotracking.calibrate_on_startup"],
|
restartRequired: ["autotracking.calibrate_on_startup"],
|
||||||
|
fieldMessages: [
|
||||||
|
{
|
||||||
|
key: "autotracking-no-zones",
|
||||||
|
field: "autotracking.required_zones",
|
||||||
|
messageKey: "configMessages.onvif.autotrackingNoZones",
|
||||||
|
severity: "error",
|
||||||
|
position: "before",
|
||||||
|
condition: (ctx) => {
|
||||||
|
if (ctx.level !== "camera") return false;
|
||||||
|
const zones = ctx.fullCameraConfig?.zones;
|
||||||
|
return (
|
||||||
|
!zones ||
|
||||||
|
typeof zones !== "object" ||
|
||||||
|
Object.keys(zones).length === 0
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
uiSchema: {
|
uiSchema: {
|
||||||
host: {
|
host: {
|
||||||
"ui:options": { size: "sm" },
|
"ui:options": { size: "sm" },
|
||||||
@ -39,11 +57,16 @@ const onvif: SectionConfigOverrides = {
|
|||||||
required_zones: {
|
required_zones: {
|
||||||
"ui:widget": "zoneNames",
|
"ui:widget": "zoneNames",
|
||||||
},
|
},
|
||||||
|
return_preset: {
|
||||||
|
"ui:options": { size: "sm" },
|
||||||
|
"ui:widget": "ptzPresets",
|
||||||
|
},
|
||||||
track: {
|
track: {
|
||||||
"ui:widget": "objectLabels",
|
"ui:widget": "objectLabels",
|
||||||
},
|
},
|
||||||
zooming: {
|
zooming: {
|
||||||
"ui:options": {
|
"ui:options": {
|
||||||
|
size: "xs",
|
||||||
enumI18nPrefix: "onvif.autotracking.zooming",
|
enumI18nPrefix: "onvif.autotracking.zooming",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -21,6 +21,10 @@ const proxy: SectionConfigOverrides = {
|
|||||||
"ui:widget": "password",
|
"ui:widget": "password",
|
||||||
"ui:options": { size: "md" },
|
"ui:options": { size: "md" },
|
||||||
},
|
},
|
||||||
|
default_role: {
|
||||||
|
"ui:widget": "defaultRole",
|
||||||
|
"ui:options": { size: "sm" },
|
||||||
|
},
|
||||||
header_map: {
|
header_map: {
|
||||||
"ui:after": { render: "ProxyRoleMap" },
|
"ui:after": { render: "ProxyRoleMap" },
|
||||||
},
|
},
|
||||||
|
|||||||
@ -10,13 +10,7 @@ const ui: SectionConfigOverrides = {
|
|||||||
overrideFields: [],
|
overrideFields: [],
|
||||||
},
|
},
|
||||||
global: {
|
global: {
|
||||||
fieldOrder: [
|
fieldOrder: ["timezone", "time_format", "unit_system"],
|
||||||
"timezone",
|
|
||||||
"time_format",
|
|
||||||
"date_style",
|
|
||||||
"time_style",
|
|
||||||
"unit_system",
|
|
||||||
],
|
|
||||||
advancedFields: [],
|
advancedFields: [],
|
||||||
restartRequired: ["unit_system"],
|
restartRequired: ["unit_system"],
|
||||||
uiSchema: {
|
uiSchema: {
|
||||||
@ -26,12 +20,6 @@ const ui: SectionConfigOverrides = {
|
|||||||
time_format: {
|
time_format: {
|
||||||
"ui:options": { enumI18nPrefix: "ui.timeFormat" },
|
"ui:options": { enumI18nPrefix: "ui.timeFormat" },
|
||||||
},
|
},
|
||||||
date_style: {
|
|
||||||
"ui:options": { enumI18nPrefix: "ui.TimeOrDateStyle" },
|
|
||||||
},
|
|
||||||
time_style: {
|
|
||||||
"ui:options": { enumI18nPrefix: "ui.TimeOrDateStyle" },
|
|
||||||
},
|
|
||||||
unit_system: {
|
unit_system: {
|
||||||
"ui:options": { enumI18nPrefix: "ui.unitSystem" },
|
"ui:options": { enumI18nPrefix: "ui.unitSystem" },
|
||||||
},
|
},
|
||||||
|
|||||||
@ -48,6 +48,8 @@ import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
|||||||
import { Trans, useTranslation } from "react-i18next";
|
import { Trans, useTranslation } from "react-i18next";
|
||||||
import { useDateLocale } from "@/hooks/use-date-locale";
|
import { useDateLocale } from "@/hooks/use-date-locale";
|
||||||
import { useDocDomain } from "@/hooks/use-doc-domain";
|
import { useDocDomain } from "@/hooks/use-doc-domain";
|
||||||
|
import { isPWA } from "@/utils/isPWA";
|
||||||
|
import { isIOS } from "react-device-detect";
|
||||||
import { CameraNameLabel } from "@/components/camera/FriendlyNameLabel";
|
import { CameraNameLabel } from "@/components/camera/FriendlyNameLabel";
|
||||||
import { useIsAdmin } from "@/hooks/use-is-admin";
|
import { useIsAdmin } from "@/hooks/use-is-admin";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
@ -437,6 +439,12 @@ export default function NotificationsSettingsExtras({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!("Notification" in window) || !window.isSecureContext) {
|
if (!("Notification" in window) || !window.isSecureContext) {
|
||||||
|
// iOS only exposes web push to apps installed to the Home Screen, so a
|
||||||
|
// secure-context iOS browser tab that isn't an installed PWA has no
|
||||||
|
// Notification API. Android supports web push in a normal tab, so it never
|
||||||
|
// reaches this case and keeps the generic secure-context message.
|
||||||
|
const requiresPwaInstall = isIOS && window.isSecureContext && !isPWA;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="scrollbar-container order-last mb-2 mt-2 flex h-full w-full flex-col overflow-y-auto pb-2 md:order-none">
|
<div className="scrollbar-container order-last mb-2 mt-2 flex h-full w-full flex-col overflow-y-auto pb-2 md:order-none">
|
||||||
<div className="w-full max-w-5xl">
|
<div className="w-full max-w-5xl">
|
||||||
@ -465,12 +473,21 @@ export default function NotificationsSettingsExtras({
|
|||||||
{t("notification.notificationUnavailable.title")}
|
{t("notification.notificationUnavailable.title")}
|
||||||
</AlertTitle>
|
</AlertTitle>
|
||||||
<AlertDescription>
|
<AlertDescription>
|
||||||
<Trans ns="views/settings">
|
<Trans
|
||||||
notification.notificationUnavailable.desc
|
ns="views/settings"
|
||||||
</Trans>
|
i18nKey={
|
||||||
|
requiresPwaInstall
|
||||||
|
? "notification.notificationUnavailable.descPwa"
|
||||||
|
: "notification.notificationUnavailable.desc"
|
||||||
|
}
|
||||||
|
/>
|
||||||
<div className="mt-3 flex items-center">
|
<div className="mt-3 flex items-center">
|
||||||
<Link
|
<Link
|
||||||
to={getLocaleDocUrl("configuration/authentication")}
|
to={getLocaleDocUrl(
|
||||||
|
requiresPwaInstall
|
||||||
|
? "configuration/notifications"
|
||||||
|
: "configuration/authentication",
|
||||||
|
)}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="inline"
|
className="inline"
|
||||||
|
|||||||
@ -33,6 +33,8 @@ import { OptionalFieldWidget } from "./widgets/OptionalFieldWidget";
|
|||||||
import { SemanticSearchModelWidget } from "./widgets/SemanticSearchModelWidget";
|
import { SemanticSearchModelWidget } from "./widgets/SemanticSearchModelWidget";
|
||||||
import { SemanticSearchModelSizeWidget } from "./widgets/SemanticSearchModelSizeWidget";
|
import { SemanticSearchModelSizeWidget } from "./widgets/SemanticSearchModelSizeWidget";
|
||||||
import { OnvifProfileWidget } from "./widgets/OnvifProfileWidget";
|
import { OnvifProfileWidget } from "./widgets/OnvifProfileWidget";
|
||||||
|
import { PTZPresetsWidget } from "./widgets/PTZPresetsWidget";
|
||||||
|
import { DefaultRoleWidget } from "./widgets/DefaultRoleWidget";
|
||||||
|
|
||||||
import { FieldTemplate } from "./templates/FieldTemplate";
|
import { FieldTemplate } from "./templates/FieldTemplate";
|
||||||
import { ObjectFieldTemplate } from "./templates/ObjectFieldTemplate";
|
import { ObjectFieldTemplate } from "./templates/ObjectFieldTemplate";
|
||||||
@ -90,6 +92,8 @@ export const frigateTheme: FrigateTheme = {
|
|||||||
semanticSearchModel: SemanticSearchModelWidget,
|
semanticSearchModel: SemanticSearchModelWidget,
|
||||||
semanticSearchModelSize: SemanticSearchModelSizeWidget,
|
semanticSearchModelSize: SemanticSearchModelSizeWidget,
|
||||||
onvifProfile: OnvifProfileWidget,
|
onvifProfile: OnvifProfileWidget,
|
||||||
|
ptzPresets: PTZPresetsWidget,
|
||||||
|
defaultRole: DefaultRoleWidget,
|
||||||
},
|
},
|
||||||
templates: {
|
templates: {
|
||||||
FieldTemplate: FieldTemplate as React.ComponentType<FieldTemplateProps>,
|
FieldTemplate: FieldTemplate as React.ComponentType<FieldTemplateProps>,
|
||||||
|
|||||||
@ -0,0 +1,56 @@
|
|||||||
|
import { useMemo } from "react";
|
||||||
|
import type { WidgetProps } from "@rjsf/utils";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from "@/components/ui/select";
|
||||||
|
import type { ConfigFormContext } from "@/types/configForm";
|
||||||
|
import { getSizedFieldClassName } from "../utils";
|
||||||
|
|
||||||
|
const BUILT_IN_ROLES = ["admin", "viewer"];
|
||||||
|
|
||||||
|
export function DefaultRoleWidget(props: WidgetProps) {
|
||||||
|
const { id, value, disabled, readonly, onChange, schema, options, registry } =
|
||||||
|
props;
|
||||||
|
const { t } = useTranslation(["views/settings"]);
|
||||||
|
|
||||||
|
const fieldClassName = getSizedFieldClassName(options, "sm");
|
||||||
|
|
||||||
|
const formContext = registry?.formContext as ConfigFormContext | undefined;
|
||||||
|
const roles = useMemo<string[]>(() => {
|
||||||
|
const configured = Object.keys(formContext?.fullConfig?.auth?.roles ?? {});
|
||||||
|
// Keep admin/viewer first, then any custom roles in config order.
|
||||||
|
const custom = configured.filter((r) => !BUILT_IN_ROLES.includes(r));
|
||||||
|
return [...BUILT_IN_ROLES, ...custom];
|
||||||
|
}, [formContext]);
|
||||||
|
|
||||||
|
const selectedValue = typeof value === "string" && value ? value : "viewer";
|
||||||
|
|
||||||
|
const getLabel = (role: string) =>
|
||||||
|
BUILT_IN_ROLES.includes(role) ? t(`configForm.defaultRole.${role}`) : role;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Select
|
||||||
|
value={selectedValue}
|
||||||
|
onValueChange={onChange}
|
||||||
|
disabled={disabled || readonly}
|
||||||
|
>
|
||||||
|
<SelectTrigger id={id} className={fieldClassName}>
|
||||||
|
<SelectValue placeholder={schema.title} />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{roles.map((role) => (
|
||||||
|
<SelectItem key={role} value={role}>
|
||||||
|
{getLabel(role)}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DefaultRoleWidget;
|
||||||
@ -0,0 +1,151 @@
|
|||||||
|
// Combobox widget for ONVIF PTZ preset fields (e.g. autotracking.return_preset).
|
||||||
|
// Fetches the camera's PTZ presets and shows them in a dropdown, while still
|
||||||
|
// allowing a typed custom value so existing presets that the camera does not
|
||||||
|
// report (such as "home") are preserved.
|
||||||
|
import { useState, useMemo } from "react";
|
||||||
|
import type { WidgetProps } from "@rjsf/utils";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import useSWR from "swr";
|
||||||
|
import { Check, ChevronsUpDown, Plus } from "lucide-react";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
Command,
|
||||||
|
CommandGroup,
|
||||||
|
CommandInput,
|
||||||
|
CommandItem,
|
||||||
|
CommandList,
|
||||||
|
} from "@/components/ui/command";
|
||||||
|
import {
|
||||||
|
Popover,
|
||||||
|
PopoverContent,
|
||||||
|
PopoverTrigger,
|
||||||
|
} from "@/components/ui/popover";
|
||||||
|
import type { ConfigFormContext } from "@/types/configForm";
|
||||||
|
import type { CameraPtzInfo } from "@/types/ptz";
|
||||||
|
import { getSizedFieldClassName } from "../utils";
|
||||||
|
|
||||||
|
export function PTZPresetsWidget(props: WidgetProps) {
|
||||||
|
const { id, value, disabled, readonly, onChange, options, registry } = props;
|
||||||
|
const { t } = useTranslation(["views/settings"]);
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const [searchValue, setSearchValue] = useState("");
|
||||||
|
|
||||||
|
const fieldClassName = getSizedFieldClassName(options, "md");
|
||||||
|
|
||||||
|
const formContext = registry?.formContext as ConfigFormContext | undefined;
|
||||||
|
const cameraName = formContext?.cameraName;
|
||||||
|
const isCameraLevel = formContext?.level === "camera";
|
||||||
|
const hasOnvifHost = !!formContext?.fullCameraConfig?.onvif?.host;
|
||||||
|
|
||||||
|
const { data: ptzInfo } = useSWR<CameraPtzInfo>(
|
||||||
|
isCameraLevel && cameraName && hasOnvifHost
|
||||||
|
? `${cameraName}/ptz/info`
|
||||||
|
: null,
|
||||||
|
{
|
||||||
|
// ONVIF may not be initialized yet when the settings page loads,
|
||||||
|
// so retry until presets become available
|
||||||
|
refreshInterval: (data) =>
|
||||||
|
data?.presets && data.presets.length > 0 ? 0 : 5000,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const presets = useMemo<string[]>(() => ptzInfo?.presets ?? [], [ptzInfo]);
|
||||||
|
|
||||||
|
const trimmedSearch = searchValue.trim();
|
||||||
|
const matchesPreset = useMemo(
|
||||||
|
() => presets.some((p) => p.toLowerCase() === trimmedSearch.toLowerCase()),
|
||||||
|
[presets, trimmedSearch],
|
||||||
|
);
|
||||||
|
const showCustomOption = trimmedSearch.length > 0 && !matchesPreset;
|
||||||
|
|
||||||
|
const commit = (next: string) => {
|
||||||
|
onChange(next);
|
||||||
|
setSearchValue("");
|
||||||
|
setOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const currentLabel = typeof value === "string" && value ? value : undefined;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Popover
|
||||||
|
open={open}
|
||||||
|
onOpenChange={(next) => {
|
||||||
|
setOpen(next);
|
||||||
|
if (!next) setSearchValue("");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PopoverTrigger asChild>
|
||||||
|
<Button
|
||||||
|
id={id}
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
role="combobox"
|
||||||
|
aria-expanded={open}
|
||||||
|
disabled={disabled || readonly}
|
||||||
|
className={cn(
|
||||||
|
"justify-between font-normal",
|
||||||
|
!currentLabel && "text-muted-foreground",
|
||||||
|
fieldClassName,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{currentLabel ?? t("configForm.ptzPresets.placeholder")}
|
||||||
|
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
||||||
|
</Button>
|
||||||
|
</PopoverTrigger>
|
||||||
|
<PopoverContent className="w-[--radix-popover-trigger-width] p-0">
|
||||||
|
<Command>
|
||||||
|
<CommandInput
|
||||||
|
placeholder={t("configForm.ptzPresets.search")}
|
||||||
|
value={searchValue}
|
||||||
|
onValueChange={setSearchValue}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === "Enter" && showCustomOption) {
|
||||||
|
e.preventDefault();
|
||||||
|
commit(trimmedSearch);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<CommandList>
|
||||||
|
{showCustomOption && (
|
||||||
|
<CommandGroup>
|
||||||
|
<CommandItem
|
||||||
|
value={trimmedSearch}
|
||||||
|
onSelect={() => commit(trimmedSearch)}
|
||||||
|
>
|
||||||
|
<Plus className="mr-2 h-4 w-4" />
|
||||||
|
{t("configForm.ptzPresets.useCustom", {
|
||||||
|
value: trimmedSearch,
|
||||||
|
})}
|
||||||
|
</CommandItem>
|
||||||
|
</CommandGroup>
|
||||||
|
)}
|
||||||
|
{presets.length > 0 ? (
|
||||||
|
<CommandGroup heading={t("configForm.ptzPresets.available")}>
|
||||||
|
{presets.map((preset) => (
|
||||||
|
<CommandItem
|
||||||
|
key={preset}
|
||||||
|
value={preset}
|
||||||
|
onSelect={() => commit(preset)}
|
||||||
|
>
|
||||||
|
<Check
|
||||||
|
className={cn(
|
||||||
|
"mr-2 h-4 w-4",
|
||||||
|
value === preset ? "opacity-100" : "opacity-0",
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
{preset}
|
||||||
|
</CommandItem>
|
||||||
|
))}
|
||||||
|
</CommandGroup>
|
||||||
|
) : !showCustomOption ? (
|
||||||
|
<div className="p-4 text-center text-sm text-muted-foreground">
|
||||||
|
{t("configForm.ptzPresets.noPresets")}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</CommandList>
|
||||||
|
</Command>
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -4,8 +4,6 @@ import { TriggerAction, TriggerType } from "./trigger";
|
|||||||
export interface UiConfig {
|
export interface UiConfig {
|
||||||
timezone?: string;
|
timezone?: string;
|
||||||
time_format?: "browser" | "12hour" | "24hour";
|
time_format?: "browser" | "12hour" | "24hour";
|
||||||
date_style?: "full" | "long" | "medium" | "short";
|
|
||||||
time_style?: "full" | "long" | "medium" | "short";
|
|
||||||
dashboard: boolean;
|
dashboard: boolean;
|
||||||
order: number;
|
order: number;
|
||||||
unit_system?: "metric" | "imperial";
|
unit_system?: "metric" | "imperial";
|
||||||
|
|||||||
@ -902,7 +902,7 @@ function StreamUrlEntry({
|
|||||||
return (
|
return (
|
||||||
<div className="pb-4">
|
<div className="pb-4">
|
||||||
<div className="flex h-7 flex-row items-center justify-start gap-2 text-sm text-primary-variant">
|
<div className="flex h-7 flex-row items-center justify-start gap-2 text-sm text-primary-variant">
|
||||||
{t("go2rtcStreams.streamNumber", { index: urlIndex + 1 })}
|
{t("go2rtcStreams.sourceNumber", { index: urlIndex + 1 })}
|
||||||
{canRemove && (
|
{canRemove && (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
|
|||||||
@ -484,7 +484,7 @@ export default function TriggerView({
|
|||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<div className="mb-5 flex flex-row items-center justify-between gap-2">
|
<div className="mb-5 flex flex-row items-center justify-between gap-2">
|
||||||
<div className="flex flex-col items-start">
|
<div className="flex max-w-5xl flex-col items-start">
|
||||||
<Heading as="h4" className="mb-1">
|
<Heading as="h4" className="mb-1">
|
||||||
{t("triggers.management.title")}
|
{t("triggers.management.title")}
|
||||||
</Heading>
|
</Heading>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user