mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-08-22 13:47:29 +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 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.const import EXPORT_DIR
|
||||
from frigate.models import Export, Previews, Recordings
|
||||
@ -129,8 +130,8 @@ def export_recording(
|
||||
)
|
||||
|
||||
|
||||
@router.patch("/export/{event_id}/{new_name}")
|
||||
def export_rename(event_id: str, new_name: str):
|
||||
@router.patch("/export/{event_id}/rename")
|
||||
def export_rename(event_id: str, body: ExportRenameBody):
|
||||
try:
|
||||
export: Export = Export.get(Export.id == event_id)
|
||||
except DoesNotExist:
|
||||
@ -144,7 +145,7 @@ def export_rename(event_id: str, new_name: str):
|
||||
status_code=404,
|
||||
)
|
||||
|
||||
export.name = new_name
|
||||
export.name = body.name
|
||||
export.save()
|
||||
return JSONResponse(
|
||||
content=(
|
||||
|
@ -83,9 +83,11 @@ function Exports() {
|
||||
const onHandleRename = useCallback(
|
||||
(id: string, update: string) => {
|
||||
axios
|
||||
.patch(`export/${id}/${encodeURIComponent(update)}`)
|
||||
.patch(`export/${id}/rename`, {
|
||||
name: update,
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.status == 200) {
|
||||
if (response.status === 200) {
|
||||
setDeleteClip(undefined);
|
||||
mutate();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user