diff --git a/VERSION b/VERSION index dd5a402..8624408 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.123 +0.0.124 diff --git a/backend/app/api/cameras.py b/backend/app/api/cameras.py index 8a74543..bb17a73 100644 --- a/backend/app/api/cameras.py +++ b/backend/app/api/cameras.py @@ -3,6 +3,7 @@ from __future__ import annotations import asyncio import re +from dataclasses import replace from fastapi import APIRouter, HTTPException, Query, Request, WebSocket, WebSocketDisconnect from fastapi.responses import StreamingResponse @@ -298,3 +299,23 @@ async def clear_cameras(request: Request) -> dict: await runtime.supervisor.remove_camera(cam_id) await go2rtc.remove_camera_streams(runtime.config, cam_id) return {"ok": True, "removed": len(ids)} + + +@router.post("/{cam_id}/record") +async def set_record(cam_id: str, request: Request) -> dict: + """Включает/выключает запись камеры на диск (тумблер REC). + + enabled=False — запись не идёт, но go2rtc/live не трогаем → просмотр работает. + Меняет только рекордер (без пересоздания go2rtc-потоков, чтобы live не мигал).""" + require_role(request, "admin") + cam = runtime.config.camera(cam_id) + if not cam: + raise HTTPException(404, "camera not found") + body = await request.json() + on = bool(body.get("enabled", True)) + idx = next(i for i, c in enumerate(runtime.config.cameras) if c.id == cam_id) + new = replace(cam, enabled=on) + runtime.config.cameras[idx] = new + save_config(runtime.config) + await runtime.supervisor.replace_camera(new) # старт/стоп записи; go2rtc не трогаем + return {"ok": True, "enabled": on} diff --git a/frontend/settings.html b/frontend/settings.html index 8d8318a..ce9cc47 100644 --- a/frontend/settings.html +++ b/frontend/settings.html @@ -55,7 +55,7 @@
| ID | Камера | IP | Потоки | Статус | ||
|---|---|---|---|---|---|---|
| ID | Камера | IP | Потоки | Запись | Статус |