mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-06-21 02:18:24 +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")
|
raise HTTPException(status_code=404, detail="Image not found")
|
||||||
|
|
||||||
@server_api.get("/all_images")
|
@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
|
from easydiffusion.easydb.mappings import GalleryImage
|
||||||
images = db.query(GalleryImage)
|
images = db.query(GalleryImage)
|
||||||
if prompt != "":
|
if prompt != "":
|
||||||
images = images.filter(GalleryImage.path.like("%"+prompt+"%"))
|
images = images.filter(GalleryImage.path.like("%"+prompt+"%"))
|
||||||
if model != "":
|
if model != "":
|
||||||
images = images.filter(GalleryImage.use_stable_diffusion_model.like("%"+model+"%"))
|
images = images.filter(GalleryImage.use_stable_diffusion_model.like("%"+model+"%"))
|
||||||
|
images = images.offset(page*50).limit(50)
|
||||||
return images.all()
|
return images.all()
|
||||||
|
|
||||||
@server_api.get("/single_image")
|
@server_api.get("/single_image")
|
||||||
|
@ -520,6 +520,7 @@
|
|||||||
<div id="gallery-search">
|
<div id="gallery-search">
|
||||||
<textarea id="gallery-prompt-search" onkeydown="gallery_keyDown_handler(event)" placeholder="Search for a prompt..."></textarea>
|
<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>
|
<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>
|
<button class="primaryButton" onclick="refreshGallery()">Refresh</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="gallery">
|
<div class="gallery">
|
||||||
|
@ -3110,12 +3110,13 @@ 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
|
params = new URLSearchParams({
|
||||||
let promptsearch = promptsearchfield.length > 0 ? "prompt=" + promptsearchfield + "&" : ""
|
prompt: document.getElementById("gallery-prompt-search").value,
|
||||||
let modelsearchfield = document.getElementById("gallery-model-search").value
|
model: document.getElementById("gallery-model-search").value,
|
||||||
let modelsearch = modelsearchfield.length > 0 ? "model=" + modelsearchfield + "&" : ""
|
page: document.getElementById("gallery-page").value
|
||||||
|
})
|
||||||
container.innerHTML=""
|
container.innerHTML=""
|
||||||
fetch('/all_images?' + promptsearch + modelsearch)
|
fetch('/all_images?' + params)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(json => {
|
.then(json => {
|
||||||
console.log(json)
|
console.log(json)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user