Fix deleting and renaming

This commit is contained in:
Nicolas Mowen 2024-04-19 09:02:43 -06:00
parent 28a8b7c8d4
commit e6f00c4b4f
4 changed files with 14 additions and 15 deletions

View File

@ -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(
{

View File

@ -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"

View File

@ -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" />

View File

@ -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>