From ae409dd0ecd71e80256c73e6efa0206e1de85930 Mon Sep 17 00:00:00 2001 From: JeLuF Date: Sat, 19 Nov 2022 21:00:41 +0100 Subject: [PATCH] Prevent empty fields in make image request Prevent render jobs to fail with HTTP 422 due to empty fields in the image settings. https://discord.com/channels/1014774730907209781/1043481789706031215/1043481789706031215 https://discord.com/channels/1014774730907209781/1014774732018683927/1042768986871443516 minor change, no CHANGE.md entry --- ui/media/js/main.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/ui/media/js/main.js b/ui/media/js/main.js index bff548c0..2811a50c 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -823,16 +823,26 @@ function getCurrentUserRequest() { function makeImage() { if (!isServerAvailable()) { alert('The server is not available.') - return - } - const taskTemplate = getCurrentUserRequest() - const newTaskRequests = [] - getPrompts().forEach((prompt) => newTaskRequests.push(Object.assign({}, taskTemplate, { - reqBody: Object.assign({ prompt: prompt }, taskTemplate.reqBody) - }))) - newTaskRequests.forEach(createTask) + } else if (!randomSeedField.checked && seedField.value == '') { + alert('The "Seed" field must not be empty.') + } else if (numOutputsTotalField.value == '') { + alert('The "Number of Images" field must not be empty.') + } else if (numOutputsParallelField.value == '') { + alert('The "Number of parallel Images" field must not be empty.') + } else if (numInferenceStepsField.value == '') { + alert('The "Inference Steps" field must not be empty.') + } else if (guidanceScaleField.value == '') { + alert('The Guidance Scale field must not be empty.') + } else { + const taskTemplate = getCurrentUserRequest() + const newTaskRequests = [] + getPrompts().forEach((prompt) => newTaskRequests.push(Object.assign({}, taskTemplate, { + reqBody: Object.assign({ prompt: prompt }, taskTemplate.reqBody) + }))) + newTaskRequests.forEach(createTask) - initialText.style.display = 'none' + initialText.style.display = 'none' + } } function createTask(task) { @@ -1336,4 +1346,4 @@ window.addEventListener("beforeunload", function(e) { }); createCollapsibles() -prettifyInputs(document); \ No newline at end of file +prettifyInputs(document);