mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-08-27 13:47:50 +02:00
fix renaming exports with a slash (#16588)
This commit is contained in:
parent
7b3556e4ad
commit
6bb1a5dfd2
5
frigate/api/defs/request/export_rename_body.py
Normal file
5
frigate/api/defs/request/export_rename_body.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
|
||||||
|
class ExportRenameBody(BaseModel):
|
||||||
|
name: str = Field(title="Friendly name", max_length=256)
|
@ -12,6 +12,7 @@ from peewee import DoesNotExist
|
|||||||
from playhouse.shortcuts import model_to_dict
|
from playhouse.shortcuts import model_to_dict
|
||||||
|
|
||||||
from frigate.api.defs.request.export_recordings_body import ExportRecordingsBody
|
from frigate.api.defs.request.export_recordings_body import ExportRecordingsBody
|
||||||
|
from frigate.api.defs.request.export_rename_body import ExportRenameBody
|
||||||
from frigate.api.defs.tags import Tags
|
from frigate.api.defs.tags import Tags
|
||||||
from frigate.const import EXPORT_DIR
|
from frigate.const import EXPORT_DIR
|
||||||
from frigate.models import Export, Previews, Recordings
|
from frigate.models import Export, Previews, Recordings
|
||||||
@ -129,8 +130,8 @@ def export_recording(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.patch("/export/{event_id}/{new_name}")
|
@router.patch("/export/{event_id}/rename")
|
||||||
def export_rename(event_id: str, new_name: str):
|
def export_rename(event_id: str, body: ExportRenameBody):
|
||||||
try:
|
try:
|
||||||
export: Export = Export.get(Export.id == event_id)
|
export: Export = Export.get(Export.id == event_id)
|
||||||
except DoesNotExist:
|
except DoesNotExist:
|
||||||
@ -144,7 +145,7 @@ def export_rename(event_id: str, new_name: str):
|
|||||||
status_code=404,
|
status_code=404,
|
||||||
)
|
)
|
||||||
|
|
||||||
export.name = new_name
|
export.name = body.name
|
||||||
export.save()
|
export.save()
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
content=(
|
content=(
|
||||||
|
@ -83,9 +83,11 @@ function Exports() {
|
|||||||
const onHandleRename = useCallback(
|
const onHandleRename = useCallback(
|
||||||
(id: string, update: string) => {
|
(id: string, update: string) => {
|
||||||
axios
|
axios
|
||||||
.patch(`export/${id}/${encodeURIComponent(update)}`)
|
.patch(`export/${id}/rename`, {
|
||||||
|
name: update,
|
||||||
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.status == 200) {
|
if (response.status === 200) {
|
||||||
setDeleteClip(undefined);
|
setDeleteClip(undefined);
|
||||||
mutate();
|
mutate();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user