fix lịch ghi hình và ngày lưu
This commit is contained in:
@@ -30,6 +30,7 @@ export default function Settings() {
|
||||
const [mediamtxApiPass, setMediamtxApiPass] = useState("");
|
||||
const [recordingsDir, setRecordingsDir] = useState("");
|
||||
const [apiPort, setApiPort] = useState("8008");
|
||||
const [recordDeleteAfterDays, setRecordDeleteAfterDays] = useState("7");
|
||||
|
||||
const loadMtx = async () => {
|
||||
setMtxBusy(true);
|
||||
@@ -37,6 +38,7 @@ export default function Settings() {
|
||||
try {
|
||||
const data = await apiJson<MediaMtxConfigView>("/mediamtx/config", { method: "GET" });
|
||||
setMtx(data);
|
||||
setRecordDeleteAfterDays(String(data.record_delete_after_days ?? 7));
|
||||
} catch (e) {
|
||||
if (typeof e === "object" && e && "status" in e) {
|
||||
const ex = e as { status: number; bodyText?: string };
|
||||
@@ -180,6 +182,28 @@ export default function Settings() {
|
||||
}
|
||||
};
|
||||
|
||||
const onChangeRecordDeleteAfter = async (days: number) => {
|
||||
setMtxBusy(true);
|
||||
setMtxError(null);
|
||||
try {
|
||||
const data = await apiJson<MediaMtxConfigView>("/mediamtx/record-delete-after", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ days }),
|
||||
});
|
||||
setMtx(data);
|
||||
setRecordDeleteAfterDays(String(data.record_delete_after_days ?? days));
|
||||
} catch (e) {
|
||||
if (typeof e === "object" && e && "status" in e) {
|
||||
const ex = e as { status: number; bodyText?: string };
|
||||
setMtxError(`http_${ex.status}${ex.bodyText ? `: ${ex.bodyText}` : ""}`);
|
||||
} else {
|
||||
setMtxError("failed_to_update_record_delete_after");
|
||||
}
|
||||
} finally {
|
||||
setMtxBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
const onRestartDocker = async () => {
|
||||
setMtxBusy(true);
|
||||
setRestartMsg(null);
|
||||
@@ -365,6 +389,20 @@ export default function Settings() {
|
||||
MediaMTX record (pathDefaults.record)
|
||||
</label>
|
||||
|
||||
<div>
|
||||
<label className="text-xs text-zinc-400">recordDeleteAfter</label>
|
||||
<select
|
||||
value={String(mtx?.record_delete_after_days ?? recordDeleteAfterDays)}
|
||||
onChange={(e) => void onChangeRecordDeleteAfter(Number(e.target.value))}
|
||||
disabled={mtxBusy}
|
||||
className="mt-1 h-9 w-full rounded-md border border-zinc-800 bg-zinc-950 px-3 text-sm text-zinc-100 disabled:opacity-60"
|
||||
>
|
||||
<option value="1">1 ngày</option>
|
||||
<option value="3">3 ngày</option>
|
||||
<option value="7">7 ngày</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<label className="flex items-center gap-2 text-sm text-zinc-200">
|
||||
<input
|
||||
type="checkbox"
|
||||
|
||||
@@ -52,5 +52,6 @@ export type MediaMtxConfigView = {
|
||||
api_url: string;
|
||||
webrtc_url: string;
|
||||
record_enabled: boolean;
|
||||
record_delete_after_days?: number | null;
|
||||
cameras: Camera[];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user