mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 17:25:22 +03:00
Fix after rebase & add UI option for showing confirmation prompts
This commit is contained in:
parent
5ffc06f96f
commit
897afd96d4
@ -46,6 +46,9 @@ class DetectorConfig(FrigateBaseModel):
|
|||||||
|
|
||||||
class UIConfig(FrigateBaseModel):
|
class UIConfig(FrigateBaseModel):
|
||||||
use_experimental: bool = Field(default=False, title="Experimental UI")
|
use_experimental: bool = Field(default=False, title="Experimental UI")
|
||||||
|
show_confirmation_prompts: bool = Field(
|
||||||
|
default=False, title="Show confirmation prompts"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class MqttConfig(FrigateBaseModel):
|
class MqttConfig(FrigateBaseModel):
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import CameraImage from '../components/CameraImage';
|
|||||||
import ClipIcon from '../icons/Clip';
|
import ClipIcon from '../icons/Clip';
|
||||||
import MotionIcon from '../icons/Motion';
|
import MotionIcon from '../icons/Motion';
|
||||||
import SnapshotIcon from '../icons/Snapshot';
|
import SnapshotIcon from '../icons/Snapshot';
|
||||||
import Dialog from '../components/Dialog';
|
import Prompt from '../components/Prompt';
|
||||||
import { useDetectState, useRecordingsState, useSnapshotsState } from '../api/mqtt';
|
import { useDetectState, useRecordingsState, useSnapshotsState } from '../api/mqtt';
|
||||||
import { useMemo, useState } from 'preact/hooks';
|
import { useMemo, useState } from 'preact/hooks';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
@ -40,6 +40,8 @@ function SortedCameras({ unsortedCameras }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Camera({ name }) {
|
function Camera({ name }) {
|
||||||
|
const {data: config} = useSWR('config');
|
||||||
|
const showConfirmationPrompts = config && config.ui.show_confirmation_prompts;
|
||||||
const { payload: detectValue, send: sendDetect } = useDetectState(name);
|
const { payload: detectValue, send: sendDetect } = useDetectState(name);
|
||||||
const [showToggleDetectDialog, setShowToggleDetectDialog] = useState(false);
|
const [showToggleDetectDialog, setShowToggleDetectDialog] = useState(false);
|
||||||
const { payload: recordValue, send: sendRecordings } = useRecordingsState(name);
|
const { payload: recordValue, send: sendRecordings } = useRecordingsState(name);
|
||||||
@ -60,7 +62,11 @@ function Camera({ name }) {
|
|||||||
icon: MotionIcon,
|
icon: MotionIcon,
|
||||||
color: detectValue === 'ON' ? 'blue' : 'gray',
|
color: detectValue === 'ON' ? 'blue' : 'gray',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
|
if (showConfirmationPrompts) {
|
||||||
setShowToggleDetectDialog(true);
|
setShowToggleDetectDialog(true);
|
||||||
|
} else {
|
||||||
|
sendDetect(recordValue === 'ON' ? 'OFF' : 'ON');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -68,7 +74,11 @@ function Camera({ name }) {
|
|||||||
icon: ClipIcon,
|
icon: ClipIcon,
|
||||||
color: recordValue === 'ON' ? 'blue' : 'gray',
|
color: recordValue === 'ON' ? 'blue' : 'gray',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
|
if (showConfirmationPrompts) {
|
||||||
setShowToggleRecordingDialog(true);
|
setShowToggleRecordingDialog(true);
|
||||||
|
} else {
|
||||||
|
sendRecordings(recordValue === 'ON' ? 'OFF' : 'ON');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -76,7 +86,11 @@ function Camera({ name }) {
|
|||||||
icon: SnapshotIcon,
|
icon: SnapshotIcon,
|
||||||
color: snapshotValue === 'ON' ? 'blue' : 'gray',
|
color: snapshotValue === 'ON' ? 'blue' : 'gray',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
|
if (showConfirmationPrompts) {
|
||||||
setShowToggleSnapshotDialog(true);
|
setShowToggleSnapshotDialog(true);
|
||||||
|
} else {
|
||||||
|
sendSnapshots(recordValue === 'ON' ? 'OFF' : 'ON');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -120,7 +134,7 @@ function Camera({ name }) {
|
|||||||
<Fragment>
|
<Fragment>
|
||||||
<Card buttons={buttons} href={href} header={name} icons={icons} media={<CameraImage camera={name} stretch />} />
|
<Card buttons={buttons} href={href} header={name} icons={icons} media={<CameraImage camera={name} stretch />} />
|
||||||
{dialogs.map(({showDialog, dismiss, title, callback}) =>
|
{dialogs.map(({showDialog, dismiss, title, callback}) =>
|
||||||
showDialog ? <Dialog
|
showDialog ? <Prompt
|
||||||
title={title}
|
title={title}
|
||||||
text="Are you sure?"
|
text="Are you sure?"
|
||||||
onDismiss={dismiss}
|
onDismiss={dismiss}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user