From 231cda38df0ba9f9af198fe86cb801e6d3a4cfe4 Mon Sep 17 00:00:00 2001 From: Martino Bettucci Date: Thu, 19 Jan 2023 13:42:26 +0100 Subject: [PATCH 1/2] Update smart_process.js Signed-off-by: Martino Bettucci --- javascript/smart_process.js | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/javascript/smart_process.js b/javascript/smart_process.js index b9f5fc3..3341a6a 100644 --- a/javascript/smart_process.js +++ b/javascript/smart_process.js @@ -1,9 +1,28 @@ +const SP_PROGRESSBAR_LABEL = 'sp_preview' +const SP_GALLERY_LABEL = 'sp_gallery' +const SP_ERROR_LABEL = '#sp_error' +const SP_GALLERY_CHILD = 'sp_gallery_kid'; +const SP_PROGRESS_LABEL = 'sp_progress'; + function start_smart_process() { - requestProgress('sp'); - gradioApp().querySelector('#sp_error').innerHTML = ''; - return args_to_array(arguments); -} + rememberGallerySelection(SP_GALLERY_LABEL) + gradioApp().querySelector('#sp_error').innerHTML = '' + var daGalleryElt = gradioApp().getElementById(SP_GALLERY_LABEL) + // set id of first child of daGalleryElt to 'sp_gallery_kid', + // required by AUTOMATIC1111 UI Logic + daGalleryElt.children[0].id = SP_GALLERY_CHILD + var id = randomId(); + requestProgress(id, + gradioApp().getElementById(SP_GALLERY_LABEL), + gradioApp().getElementById(SP_GALLERY_CHILD), + function () { + }, + function (progress) { + gradioApp().getElementById(SP_PROGRESS_LABEL).innerHTML = progress.textinfo + }) -onUiUpdate(function () { - check_progressbar('sp', 'sp_progressbar', 'sp_progress_span', '', 'sp_interrupt', 'sp_preview', 'sp_gallery') -}) \ No newline at end of file + const argsToArray = args_to_array(arguments); + argsToArray.push(argsToArray[0]) + argsToArray[0] = id; + return argsToArray +} From 5c1def03a6ec5fb0032bc75910dc05748b13b389 Mon Sep 17 00:00:00 2001 From: Martino Bettucci Date: Thu, 19 Jan 2023 13:47:19 +0100 Subject: [PATCH 2/2] Update smart_process.js Signed-off-by: Martino Bettucci --- javascript/smart_process.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/javascript/smart_process.js b/javascript/smart_process.js index 3341a6a..b757fa8 100644 --- a/javascript/smart_process.js +++ b/javascript/smart_process.js @@ -7,10 +7,10 @@ const SP_PROGRESS_LABEL = 'sp_progress'; function start_smart_process() { rememberGallerySelection(SP_GALLERY_LABEL) gradioApp().querySelector('#sp_error').innerHTML = '' - var daGalleryElt = gradioApp().getElementById(SP_GALLERY_LABEL) - // set id of first child of daGalleryElt to 'sp_gallery_kid', + var spGalleryElt = gradioApp().getElementById(SP_GALLERY_LABEL) + // set id of first child of spGalleryElt to 'sp_gallery_kid', // required by AUTOMATIC1111 UI Logic - daGalleryElt.children[0].id = SP_GALLERY_CHILD + spGalleryElt.children[0].id = SP_GALLERY_CHILD var id = randomId(); requestProgress(id, gradioApp().getElementById(SP_GALLERY_LABEL), @@ -26,3 +26,7 @@ function start_smart_process() { argsToArray[0] = id; return argsToArray } + +onUiUpdate(function(){ + check_gallery(SP_GALLERY_LABEL) +})