mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-10 21:25:24 +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(
|
||||
current_app.frigate_config,
|
||||
camera_name,
|
||||
secure_filename(name.replace(" ", "_")) if name else None,
|
||||
secure_filename(name) if name else None,
|
||||
int(start_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):
|
||||
try:
|
||||
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.thumb_path).unlink(missing_ok=True)
|
||||
export.delete()
|
||||
export.delete_instance()
|
||||
return make_response(
|
||||
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_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"
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ export default function ExportCard({
|
||||
editName != undefined ? ["Enter"] : [],
|
||||
(_, down, repeat) => {
|
||||
if (down && !repeat && editName && editName.update.length > 0) {
|
||||
onRename(editName.original, editName.update);
|
||||
onRename(exportedRecording.id, editName.update);
|
||||
setEditName(undefined);
|
||||
}
|
||||
},
|
||||
@ -78,10 +78,7 @@ export default function ExportCard({
|
||||
variant="select"
|
||||
disabled={(editName?.update?.length ?? 0) == 0}
|
||||
onClick={() => {
|
||||
onRename(
|
||||
editName.original,
|
||||
editName.update.replaceAll(" ", "_"),
|
||||
);
|
||||
onRename(exportedRecording.id, editName.update);
|
||||
setEditName(undefined);
|
||||
}}
|
||||
>
|
||||
@ -118,7 +115,7 @@ export default function ExportCard({
|
||||
<Chip
|
||||
className="bg-gradient-to-br from-gray-400 to-gray-500 bg-gray-500 rounded-md cursor-pointer"
|
||||
onClick={() =>
|
||||
setEditName({ original: exportedRecording.id, update: "" })
|
||||
setEditName({ original: exportedRecording.name, update: "" })
|
||||
}
|
||||
>
|
||||
<LuPencil className="size-4 text-white" />
|
||||
|
||||
@ -34,9 +34,7 @@ function Exports() {
|
||||
}
|
||||
|
||||
return exports.filter((exp) =>
|
||||
exp.name
|
||||
.toLowerCase()
|
||||
.includes(search.toLowerCase().replaceAll(" ", "_")),
|
||||
exp.name.toLowerCase().includes(search.toLowerCase()),
|
||||
);
|
||||
}, [exports, search]);
|
||||
|
||||
@ -90,7 +88,11 @@ function Exports() {
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||
<Button variant="destructive" onClick={() => onHandleDelete()}>
|
||||
<Button
|
||||
className="text-white"
|
||||
variant="destructive"
|
||||
onClick={() => onHandleDelete()}
|
||||
>
|
||||
Delete
|
||||
</Button>
|
||||
</AlertDialogFooter>
|
||||
@ -144,7 +146,7 @@ function Exports() {
|
||||
exportedRecording={item}
|
||||
onSelect={setSelected}
|
||||
onRename={onHandleRename}
|
||||
onDelete={(file) => setDeleteClip(file)}
|
||||
onDelete={(id) => setDeleteClip(id)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user