aboutsummaryrefslogtreecommitdiff
path: root/javascript/ui.js
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-04-29 22:13:48 +0300
committerGitHub <noreply@github.com>2023-04-29 22:13:48 +0300
commit80987c36f9bfa33092ac7c75624b25d839cb2a06 (patch)
tree6f1acaae50a49544a08384b52739df3e2d803a10 /javascript/ui.js
parent2e78e65a22bfa6b116ae18d12fdcb85ec8acd727 (diff)
parent15c4e78b44e14d70b82dcb5b563251fed7be0766 (diff)
Merge pull request #7595 from siutin/feature/restore-progress
restore the progress from session lost / tab reload
Diffstat (limited to 'javascript/ui.js')
-rw-r--r--javascript/ui.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/javascript/ui.js b/javascript/ui.js
index 0ba92ef8..e50b44ee 100644
--- a/javascript/ui.js
+++ b/javascript/ui.js
@@ -362,6 +362,32 @@ function selectCheckpoint(name){
gradioApp().getElementById('change_checkpoint').click()
}
+function restoreProgress (task_tag) {
+
+ if (task_tag) {
+ let successHandler = ({ current_task }) => {
+ if (current_task) {
+ 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
+
+}
+
function currentImg2imgSourceResolution(_, _, scaleBy){
var img = gradioApp().querySelector('#mode_img2img > div[style="display: block;"] img')
return img ? [img.naturalWidth, img.naturalHeight, scaleBy] : [0, 0, scaleBy]
@@ -377,3 +403,4 @@ function updateImg2imgResizeToTextAfterChangingImage(){
return []
}
+