From 2bf7116f011868ab8675aa6fa94e215f1b813d77 Mon Sep 17 00:00:00 2001 From: ManInDark <61268856+ManInDark@users.noreply.github.com> Date: Wed, 9 Aug 2023 22:50:03 +0200 Subject: [PATCH] Added Gallery search for prompt & model --- ui/easydiffusion/bucket_manager.py | 11 +++++++---- ui/index.html | 6 +++++- ui/media/css/main.css | 13 ++++++++++++- ui/media/js/main.js | 13 ++++++++++++- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/ui/easydiffusion/bucket_manager.py b/ui/easydiffusion/bucket_manager.py index 0d72ed06..43b5f147 100644 --- a/ui/easydiffusion/bucket_manager.py +++ b/ui/easydiffusion/bucket_manager.py @@ -100,11 +100,14 @@ def init(): raise HTTPException(status_code=404, detail="Image not found") @server_api.get("/all_images") - def get_all_images(db: Session = Depends(get_db)): + def get_all_images(prompt: str = "", model: str = "", db: Session = Depends(get_db)): from easydiffusion.easydb.mappings import GalleryImage - images = db.query(GalleryImage).all() - return images - + images = db.query(GalleryImage) + if prompt != "": + images = images.filter(GalleryImage.path.like("%"+prompt+"%")) + if model != "": + images = images.filter(GalleryImage.use_stable_diffusion_model.like("%"+model+"%")) + return images.all() def get_filename_from_url(url): path = urlparse(url).path diff --git a/ui/index.html b/ui/index.html index d5803fcc..9aeb7ab2 100644 --- a/ui/index.html +++ b/ui/index.html @@ -517,7 +517,11 @@