mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Show status when mask is saved (#7212)
This commit is contained in:
parent
bfa7a5cc60
commit
d30a738960
@ -1090,7 +1090,7 @@ def config_set():
|
|||||||
logging.error(f"Error updating config: {e}")
|
logging.error(f"Error updating config: {e}")
|
||||||
return "Error updating config", 500
|
return "Error updating config", 500
|
||||||
|
|
||||||
return "Config successfully updated", 200
|
return "Config successfully updated, restart to apply", 200
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/config/schema.json")
|
@bp.route("/config/schema.json")
|
||||||
|
@ -53,6 +53,8 @@ export default function CameraMasks({ camera }) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const [editing, setEditing] = useState({ set: motionMaskPoints, key: 0, fn: setMotionMaskPoints });
|
const [editing, setEditing] = useState({ set: motionMaskPoints, key: 0, fn: setMotionMaskPoints });
|
||||||
|
const [success, setSuccess] = useState();
|
||||||
|
const [error, setError] = useState();
|
||||||
|
|
||||||
const handleUpdateEditable = useCallback(
|
const handleUpdateEditable = useCallback(
|
||||||
(newPoints) => {
|
(newPoints) => {
|
||||||
@ -99,7 +101,7 @@ export default function CameraMasks({ camera }) {
|
|||||||
const textToCopy = ` motion:
|
const textToCopy = ` motion:
|
||||||
mask:
|
mask:
|
||||||
${motionMaskPoints.map((mask) => ` - ${polylinePointsToPolyline(mask)}`).join('\n')}`;
|
${motionMaskPoints.map((mask) => ` - ${polylinePointsToPolyline(mask)}`).join('\n')}`;
|
||||||
|
|
||||||
if (window.navigator.clipboard && window.navigator.clipboard.writeText) {
|
if (window.navigator.clipboard && window.navigator.clipboard.writeText) {
|
||||||
// Use Clipboard API if available
|
// Use Clipboard API if available
|
||||||
window.navigator.clipboard.writeText(textToCopy).catch((err) => {
|
window.navigator.clipboard.writeText(textToCopy).catch((err) => {
|
||||||
@ -111,7 +113,7 @@ export default function CameraMasks({ camera }) {
|
|||||||
textarea.value = textToCopy;
|
textarea.value = textToCopy;
|
||||||
document.body.appendChild(textarea);
|
document.body.appendChild(textarea);
|
||||||
textarea.select();
|
textarea.select();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const successful = document.execCommand('copy');
|
const successful = document.execCommand('copy');
|
||||||
if (!successful) {
|
if (!successful) {
|
||||||
@ -120,7 +122,7 @@ export default function CameraMasks({ camera }) {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error('Failed to copy text: ', err);
|
throw new Error('Failed to copy text: ', err);
|
||||||
}
|
}
|
||||||
|
|
||||||
document.body.removeChild(textarea);
|
document.body.removeChild(textarea);
|
||||||
}
|
}
|
||||||
}, [motionMaskPoints]);
|
}, [motionMaskPoints]);
|
||||||
@ -133,14 +135,17 @@ export default function CameraMasks({ camera }) {
|
|||||||
const endpoint = `config/set?${queryParameters}`;
|
const endpoint = `config/set?${queryParameters}`;
|
||||||
const response = await axios.put(endpoint);
|
const response = await axios.put(endpoint);
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
// handle successful response
|
setSuccess(response.data);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// handle error
|
if (error.response) {
|
||||||
//console.error(error);
|
setError(error.response.data.message);
|
||||||
|
} else {
|
||||||
|
setError(error.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [camera, motionMaskPoints]);
|
}, [camera, motionMaskPoints]);
|
||||||
|
|
||||||
|
|
||||||
// Zone methods
|
// Zone methods
|
||||||
const handleEditZone = useCallback(
|
const handleEditZone = useCallback(
|
||||||
@ -185,7 +190,7 @@ ${Object.keys(zonePoints)
|
|||||||
textarea.value = textToCopy;
|
textarea.value = textToCopy;
|
||||||
document.body.appendChild(textarea);
|
document.body.appendChild(textarea);
|
||||||
textarea.select();
|
textarea.select();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const successful = document.execCommand('copy');
|
const successful = document.execCommand('copy');
|
||||||
if (!successful) {
|
if (!successful) {
|
||||||
@ -194,7 +199,7 @@ ${Object.keys(zonePoints)
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error('Failed to copy text: ', err);
|
throw new Error('Failed to copy text: ', err);
|
||||||
}
|
}
|
||||||
|
|
||||||
document.body.removeChild(textarea);
|
document.body.removeChild(textarea);
|
||||||
}
|
}
|
||||||
}, [zonePoints]);
|
}, [zonePoints]);
|
||||||
@ -207,11 +212,14 @@ ${Object.keys(zonePoints)
|
|||||||
const endpoint = `config/set?${queryParameters}`;
|
const endpoint = `config/set?${queryParameters}`;
|
||||||
const response = await axios.put(endpoint);
|
const response = await axios.put(endpoint);
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
// handle successful response
|
setSuccess(response.data);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// handle error
|
if (error.response) {
|
||||||
//console.error(error);
|
setError(error.response.data.message);
|
||||||
|
} else {
|
||||||
|
setError(error.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [camera, zonePoints]);
|
}, [camera, zonePoints]);
|
||||||
|
|
||||||
@ -263,11 +271,14 @@ ${Object.keys(objectMaskPoints)
|
|||||||
const endpoint = `config/set?${queryParameters}`;
|
const endpoint = `config/set?${queryParameters}`;
|
||||||
const response = await axios.put(endpoint);
|
const response = await axios.put(endpoint);
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
// handle successful response
|
setSuccess(response.data);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// handle error
|
if (error.response) {
|
||||||
//console.error(error);
|
setError(error.response.data.message);
|
||||||
|
} else {
|
||||||
|
setError(error.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [camera, objectMaskPoints]);
|
}, [camera, objectMaskPoints]);
|
||||||
|
|
||||||
@ -320,6 +331,9 @@ ${Object.keys(objectMaskPoints)
|
|||||||
header="Warning"
|
header="Warning"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{success && <div className="max-h-20 text-green-500">{success}</div>}
|
||||||
|
{error && <div className="p-4 overflow-scroll text-red-500 whitespace-pre-wrap">{error}</div>}
|
||||||
|
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<img ref={imageRef} src={`${apiHost}/api/${camera}/latest.jpg`} />
|
<img ref={imageRef} src={`${apiHost}/api/${camera}/latest.jpg`} />
|
||||||
|
Loading…
Reference in New Issue
Block a user