From 3e98f9e6bd16762f31813aeca021ce5e85de1a7d Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 20 Mar 2023 14:34:51 +0000 Subject: [PATCH] Button working now --- application/app.py | 5 ++++- frontend/src/Navigation.tsx | 23 +++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/application/app.py b/application/app.py index 164db16..dfce497 100644 --- a/application/app.py +++ b/application/app.py @@ -410,8 +410,11 @@ def delete_old(): if dirs[0] not in ['indexes', 'vectors']: return {"status": 'error'} path_clean = '/'.join(dirs) - shutil.rmtree(path) vectors_collection.delete_one({'location': path}) + try: + shutil.rmtree(path_clean) + except FileNotFoundError: + pass return {"status": 'ok'} # handling CORS diff --git a/frontend/src/Navigation.tsx b/frontend/src/Navigation.tsx index 053b948..f4b9eb9 100644 --- a/frontend/src/Navigation.tsx +++ b/frontend/src/Navigation.tsx @@ -63,7 +63,8 @@ export default function Navigation({ const imageElement = document.querySelector( `#img-${index}`, ) as HTMLElement; - imageElement.parentNode?.removeChild(imageElement); + const parentElement = imageElement.parentNode as HTMLElement; + parentElement.parentNode?.removeChild(parentElement); }) .catch((error) => console.error(error)); }; @@ -173,13 +174,18 @@ export default function Navigation({

{doc.name} {doc.version}

- Exit handleDeleteClick(index, doc)} - /> + {doc.location === 'local' ? ( + Exit { + event.stopPropagation(); + handleDeleteClick(index, doc); + }} + /> + ) : null} ); } @@ -189,6 +195,7 @@ export default function Navigation({

No default documentation.

)} + ) )}