mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-06-20 18:08:00 +02:00
Implemented JeLuF's suggestion & added pagination basics
This commit is contained in:
parent
216ecce506
commit
ff75adab7f
@ -100,13 +100,14 @@ def init():
|
||||
raise HTTPException(status_code=404, detail="Image not found")
|
||||
|
||||
@server_api.get("/all_images")
|
||||
def get_all_images(prompt: str = "", model: str = "", db: Session = Depends(get_db)):
|
||||
def get_all_images(prompt: str = "", model: str = "", page = 0, db: Session = Depends(get_db)):
|
||||
from easydiffusion.easydb.mappings import GalleryImage
|
||||
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+"%"))
|
||||
images = images.offset(page*50).limit(50)
|
||||
return images.all()
|
||||
|
||||
@server_api.get("/single_image")
|
||||
|
@ -520,6 +520,7 @@
|
||||
<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>
|
||||
<input type="hidden" id="gallery-page" name="page" value="0">
|
||||
<button class="primaryButton" onclick="refreshGallery()">Refresh</button>
|
||||
</div>
|
||||
<div class="gallery">
|
||||
|
@ -3110,12 +3110,13 @@ function galleryImage(item) {
|
||||
|
||||
function refreshGallery() {
|
||||
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 + "&" : ""
|
||||
params = new URLSearchParams({
|
||||
prompt: document.getElementById("gallery-prompt-search").value,
|
||||
model: document.getElementById("gallery-model-search").value,
|
||||
page: document.getElementById("gallery-page").value
|
||||
})
|
||||
container.innerHTML=""
|
||||
fetch('/all_images?' + promptsearch + modelsearch)
|
||||
fetch('/all_images?' + params)
|
||||
.then(response => response.json())
|
||||
.then(json => {
|
||||
console.log(json)
|
||||
|
Loading…
x
Reference in New Issue
Block a user