diff options
author | siutin <osiutino@gmail.com> | 2023-02-05 19:55:31 +0000 |
---|---|---|
committer | siutin <osiutino@gmail.com> | 2023-03-30 09:20:09 +0000 |
commit | 4242e194e417ec5008d09ec6d756594ac65f77bd (patch) | |
tree | a39f18034e3bef43db01b98a52145e06603124b3 /javascript | |
parent | 9407f1731aa8c112ffc0efaa611a76f7fead3d0c (diff) | |
download | stable-diffusion-webui-gfx803-4242e194e417ec5008d09ec6d756594ac65f77bd.tar.gz stable-diffusion-webui-gfx803-4242e194e417ec5008d09ec6d756594ac65f77bd.tar.bz2 stable-diffusion-webui-gfx803-4242e194e417ec5008d09ec6d756594ac65f77bd.zip |
add a button to restore the current progress
Diffstat (limited to 'javascript')
-rw-r--r-- | javascript/progressbar.js | 4 | ||||
-rw-r--r-- | javascript/ui.js | 36 |
2 files changed, 36 insertions, 4 deletions
diff --git a/javascript/progressbar.js b/javascript/progressbar.js index 4ac9b8db..7ba14192 100644 --- a/javascript/progressbar.js +++ b/javascript/progressbar.js @@ -59,8 +59,8 @@ function setTitle(progress){ } -function randomId(){ - return "task(" + Math.random().toString(36).slice(2, 7) + Math.random().toString(36).slice(2, 7) + Math.random().toString(36).slice(2, 7)+")" +function randomId(prefix=null){ + return "task(" + (prefix == null ? "" : prefix + "_") + Math.random().toString(36).slice(2, 7) + Math.random().toString(36).slice(2, 7) + Math.random().toString(36).slice(2, 7)+")" } // starts sending progress requests to "/internal/progress" uri, creating progressbar above progressbarContainer element and diff --git a/javascript/ui.js b/javascript/ui.js index 4a440193..9fe884c0 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -163,7 +163,7 @@ function submit(){ rememberGallerySelection('txt2img_gallery') showSubmitButtons('txt2img', false) - var id = randomId() + var id = randomId("txt2img") requestProgress(id, gradioApp().getElementById('txt2img_gallery_container'), gradioApp().getElementById('txt2img_gallery'), function(){ showSubmitButtons('txt2img', true) @@ -180,7 +180,7 @@ function submit_img2img(){ rememberGallerySelection('img2img_gallery') showSubmitButtons('img2img', false) - var id = randomId() + var id = randomId("img2img") requestProgress(id, gradioApp().getElementById('img2img_gallery_container'), gradioApp().getElementById('img2img_gallery'), function(){ showSubmitButtons('img2img', true) }) @@ -361,3 +361,35 @@ function selectCheckpoint(name){ desiredCheckpointName = name; gradioApp().getElementById('change_checkpoint').click() } + +function restoreProgress (task_tag) { + + if (task_tag) { + let successHandler = ({ current_task }) => { + if (current_task) { + let _task_tag = ["txt2img", "img2img"].find(t => current_task.startsWith(`task(${t}_`) && current_task.endsWith(")")) + if (!_task_tag) { + console.warn(`task tag ${current_task} not implemented yet`) + return + } + if (task_tag != _task_tag) return + showSubmitButtons(task_tag, false) + requestProgress(current_task, gradioApp().getElementById(`${task_tag}_gallery_container`), gradioApp().getElementById(`${task_tag}_gallery`), function(){ + showSubmitButtons(task_tag, true) + }) + } + } + + let errorHandler = e => window.alert(`invalid internal api respsonse. message: ${e}`) + + fetch("./internal/current_task") + .then(res => res.json()) + .then(successHandler) + .catch(errorHandler) + } + + var res = create_submit_args(arguments) + res[0] = 0 + return res + +}
\ No newline at end of file |