mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-06-21 02:18:24 +02:00
Added Gallery search for prompt & model
This commit is contained in:
parent
64fc777a2b
commit
2bf7116f01
@ -100,11 +100,14 @@ def init():
|
|||||||
raise HTTPException(status_code=404, detail="Image not found")
|
raise HTTPException(status_code=404, detail="Image not found")
|
||||||
|
|
||||||
@server_api.get("/all_images")
|
@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
|
from easydiffusion.easydb.mappings import GalleryImage
|
||||||
images = db.query(GalleryImage).all()
|
images = db.query(GalleryImage)
|
||||||
return images
|
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):
|
def get_filename_from_url(url):
|
||||||
path = urlparse(url).path
|
path = urlparse(url).path
|
||||||
|
@ -517,7 +517,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="tab-content-gallery" class="tab-content">
|
<div id="tab-content-gallery" class="tab-content">
|
||||||
<button class="primaryButton" onclick="refreshGallery()">Refresh</button>
|
<div id="gallery-search">
|
||||||
|
<textarea id="gallery-prompt-search" onkeydown="gallery_keyDown_handler(event)" placeholder="Search for a prompt..."></textarea>
|
||||||
|
<textarea id="gallery-model-search" onkeydown="gallery_keyDown_handler(event)" placeholder="Search for a model..."></textarea>
|
||||||
|
<button class="primaryButton" onclick="refreshGallery()">Refresh</button>
|
||||||
|
</div>
|
||||||
<div class="gallery">
|
<div class="gallery">
|
||||||
<div class="gallery-container" id="imagecontainer"></div>
|
<div class="gallery-container" id="imagecontainer"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1897,6 +1897,17 @@ div#enlarge-buttons {
|
|||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#gallery-search {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
#gallery-search>* {
|
||||||
|
margin: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
.gallery-container {
|
.gallery-container {
|
||||||
columns: 5 ;
|
columns: 5 ;
|
||||||
column-gap: 1.5rem;
|
column-gap: 1.5rem;
|
||||||
@ -1924,6 +1935,6 @@ div#enlarge-buttons {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#tab-content-gallery>button {
|
#tab-content-gallery>* {
|
||||||
margin: 8px;
|
margin: 8px;
|
||||||
}
|
}
|
||||||
|
@ -3097,8 +3097,12 @@ function galleryImage(item) {
|
|||||||
|
|
||||||
function refreshGallery() {
|
function refreshGallery() {
|
||||||
let container = document.getElementById("imagecontainer")
|
let container = document.getElementById("imagecontainer")
|
||||||
|
let promptsearchfield = document.getElementById("gallery-prompt-search").value
|
||||||
|
let promptsearch = promptsearchfield.length > 0 ? "prompt=" + promptsearchfield + "&" : ""
|
||||||
|
let modelsearchfield = document.getElementById("gallery-model-search").value
|
||||||
|
let modelsearch = modelsearchfield.length > 0 ? "model=" + modelsearchfield + "&" : ""
|
||||||
container.innerHTML=""
|
container.innerHTML=""
|
||||||
fetch('/all_images')
|
fetch('/all_images?' + promptsearch + modelsearch)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(json => {
|
.then(json => {
|
||||||
console.log(json)
|
console.log(json)
|
||||||
@ -3107,3 +3111,10 @@ function refreshGallery() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gallery_keyDown_handler(event) {
|
||||||
|
if (event.key === 'Enter') {
|
||||||
|
event.preventDefault()
|
||||||
|
refreshGallery()
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user