mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-11 05:35:25 +03:00
Fix deleting and renaming
This commit is contained in:
parent
28a8b7c8d4
commit
e6f00c4b4f
@ -76,7 +76,7 @@ def export_recording(camera_name: str, start_time, end_time):
|
|||||||
exporter = RecordingExporter(
|
exporter = RecordingExporter(
|
||||||
current_app.frigate_config,
|
current_app.frigate_config,
|
||||||
camera_name,
|
camera_name,
|
||||||
secure_filename(name.replace(" ", "_")) if name else None,
|
secure_filename(name) if name else None,
|
||||||
int(start_time),
|
int(start_time),
|
||||||
int(end_time),
|
int(end_time),
|
||||||
(
|
(
|
||||||
@ -97,7 +97,7 @@ def export_recording(camera_name: str, start_time, end_time):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ExportBp.route("/export/<id>/<new_name>", methods=["POST"])
|
@ExportBp.route("/export/<id>/<new_name>", methods=["PATCH"])
|
||||||
def export_rename(id, new_name: str):
|
def export_rename(id, new_name: str):
|
||||||
try:
|
try:
|
||||||
export: Export = Export.get(Export.id == id)
|
export: Export = Export.get(Export.id == id)
|
||||||
@ -142,7 +142,7 @@ def export_delete(id: str):
|
|||||||
|
|
||||||
Path(export.video_path).unlink(missing_ok=True)
|
Path(export.video_path).unlink(missing_ok=True)
|
||||||
Path(export.thumb_path).unlink(missing_ok=True)
|
Path(export.thumb_path).unlink(missing_ok=True)
|
||||||
export.delete()
|
export.delete_instance()
|
||||||
return make_response(
|
return make_response(
|
||||||
jsonify(
|
jsonify(
|
||||||
{
|
{
|
||||||
|
|||||||
@ -159,7 +159,7 @@ class RecordingExporter(threading.Thread):
|
|||||||
export_id = f"{self.camera}_{''.join(random.choices(string.ascii_lowercase + string.digits, k=6))}"
|
export_id = f"{self.camera}_{''.join(random.choices(string.ascii_lowercase + string.digits, k=6))}"
|
||||||
export_name = (
|
export_name = (
|
||||||
self.user_provided_name
|
self.user_provided_name
|
||||||
or f"{self.camera.replace("_", " ")} {self.get_datetime_from_timestamp(self.start_time)} {self.get_datetime_from_timestamp(self.end_time)}"
|
or f"{self.camera.replace('_', ' ')} {self.get_datetime_from_timestamp(self.start_time)} {self.get_datetime_from_timestamp(self.end_time)}"
|
||||||
)
|
)
|
||||||
video_path = f"{EXPORT_DIR}/{export_id}.mp4"
|
video_path = f"{EXPORT_DIR}/{export_id}.mp4"
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@ export default function ExportCard({
|
|||||||
editName != undefined ? ["Enter"] : [],
|
editName != undefined ? ["Enter"] : [],
|
||||||
(_, down, repeat) => {
|
(_, down, repeat) => {
|
||||||
if (down && !repeat && editName && editName.update.length > 0) {
|
if (down && !repeat && editName && editName.update.length > 0) {
|
||||||
onRename(editName.original, editName.update);
|
onRename(exportedRecording.id, editName.update);
|
||||||
setEditName(undefined);
|
setEditName(undefined);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -78,10 +78,7 @@ export default function ExportCard({
|
|||||||
variant="select"
|
variant="select"
|
||||||
disabled={(editName?.update?.length ?? 0) == 0}
|
disabled={(editName?.update?.length ?? 0) == 0}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onRename(
|
onRename(exportedRecording.id, editName.update);
|
||||||
editName.original,
|
|
||||||
editName.update.replaceAll(" ", "_"),
|
|
||||||
);
|
|
||||||
setEditName(undefined);
|
setEditName(undefined);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@ -118,7 +115,7 @@ export default function ExportCard({
|
|||||||
<Chip
|
<Chip
|
||||||
className="bg-gradient-to-br from-gray-400 to-gray-500 bg-gray-500 rounded-md cursor-pointer"
|
className="bg-gradient-to-br from-gray-400 to-gray-500 bg-gray-500 rounded-md cursor-pointer"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
setEditName({ original: exportedRecording.id, update: "" })
|
setEditName({ original: exportedRecording.name, update: "" })
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<LuPencil className="size-4 text-white" />
|
<LuPencil className="size-4 text-white" />
|
||||||
|
|||||||
@ -34,9 +34,7 @@ function Exports() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return exports.filter((exp) =>
|
return exports.filter((exp) =>
|
||||||
exp.name
|
exp.name.toLowerCase().includes(search.toLowerCase()),
|
||||||
.toLowerCase()
|
|
||||||
.includes(search.toLowerCase().replaceAll(" ", "_")),
|
|
||||||
);
|
);
|
||||||
}, [exports, search]);
|
}, [exports, search]);
|
||||||
|
|
||||||
@ -90,7 +88,11 @@ function Exports() {
|
|||||||
</AlertDialogHeader>
|
</AlertDialogHeader>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||||
<Button variant="destructive" onClick={() => onHandleDelete()}>
|
<Button
|
||||||
|
className="text-white"
|
||||||
|
variant="destructive"
|
||||||
|
onClick={() => onHandleDelete()}
|
||||||
|
>
|
||||||
Delete
|
Delete
|
||||||
</Button>
|
</Button>
|
||||||
</AlertDialogFooter>
|
</AlertDialogFooter>
|
||||||
@ -144,7 +146,7 @@ function Exports() {
|
|||||||
exportedRecording={item}
|
exportedRecording={item}
|
||||||
onSelect={setSelected}
|
onSelect={setSelected}
|
||||||
onRename={onHandleRename}
|
onRename={onHandleRename}
|
||||||
onDelete={(file) => setDeleteClip(file)}
|
onDelete={(id) => setDeleteClip(id)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user