Styling changes for the confirm dialog

This commit is contained in:
cmdr2 2022-12-01 13:54:49 +05:30
parent 4bc6e51862
commit 3b554d881a

View File

@ -153,9 +153,12 @@ function shiftOrConfirm(e, prompt, fn) {
if (e.shiftKey || !confirmDangerousActionsField.checked) { if (e.shiftKey || !confirmDangerousActionsField.checked) {
fn(e) fn(e)
} else { } else {
$.confirm({ theme: 'supervan', $.confirm({
theme: 'modern',
title: prompt, title: prompt,
content: 'Tip: To skip this dialog, use shift-click or disable the setting "Confirm dangerous actions" in the systems setting.', useBootstrap: false,
animateFromElement: false,
content: '<small>Tip: To skip this dialog, use shift-click or disable the "Confirm dangerous actions" setting in the Settings tab.</small>',
buttons: { buttons: {
yes: () => { fn(e) }, yes: () => { fn(e) },
cancel: () => {} cancel: () => {}
@ -164,7 +167,6 @@ function shiftOrConfirm(e, prompt, fn) {
} }
} }
function logMsg(msg, level, outputMsg) { function logMsg(msg, level, outputMsg) {
if (outputMsg.hasChildNodes()) { if (outputMsg.hasChildNodes()) {
outputMsg.appendChild(document.createElement('br')) outputMsg.appendChild(document.createElement('br'))
@ -886,24 +888,27 @@ function createTask(task) {
task['progressBar'] = taskEntry.querySelector('.progress-bar') task['progressBar'] = taskEntry.querySelector('.progress-bar')
task['stopTask'] = taskEntry.querySelector('.stopTask') task['stopTask'] = taskEntry.querySelector('.stopTask')
task['stopTask'].addEventListener('click', (e) => { shiftOrConfirm(e, "Are you sure? Should this task be stopped?", async function(e) { task['stopTask'].addEventListener('click', (e) => {
if (task['isProcessing']) { let question = (task['isProcessing'] ? "Stop this task?" : "Remove this task?")
task.isProcessing = false shiftOrConfirm(e, question, async function(e) {
task.progressBar.classList.remove("active") if (task['isProcessing']) {
try { task.isProcessing = false
let res = await fetch('/image/stop?session_id=' + sessionId) task.progressBar.classList.remove("active")
} catch (e) { try {
console.log(e) let res = await fetch('/image/stop?session_id=' + sessionId)
} } catch (e) {
} else { console.log(e)
let idx = taskQueue.indexOf(task) }
if (idx >= 0) { } else {
taskQueue.splice(idx, 1) let idx = taskQueue.indexOf(task)
} if (idx >= 0) {
taskQueue.splice(idx, 1)
}
removeTask(taskEntry) removeTask(taskEntry)
} }
})}) })
})
task['useSettings'] = taskEntry.querySelector('.useSettings') task['useSettings'] = taskEntry.querySelector('.useSettings')
task['useSettings'].addEventListener('click', function(e) { task['useSettings'].addEventListener('click', function(e) {
@ -1054,14 +1059,14 @@ function removeTask(taskToRemove) {
} }
} }
clearAllPreviewsBtn.addEventListener('click', (e) => { shiftOrConfirm(e, "Are you sure? Remove all results and tasks from the results pane?", async function() { clearAllPreviewsBtn.addEventListener('click', (e) => { shiftOrConfirm(e, "Clear all the results and tasks in this window?", async function() {
await stopAllTasks() await stopAllTasks()
let taskEntries = document.querySelectorAll('.imageTaskContainer') let taskEntries = document.querySelectorAll('.imageTaskContainer')
taskEntries.forEach(removeTask) taskEntries.forEach(removeTask)
})}) })})
stopImageBtn.addEventListener('click', (e) => { shiftOrConfirm(e, "Are you sure? Do you want to stop all the tasks?", async function(e) { stopImageBtn.addEventListener('click', (e) => { shiftOrConfirm(e, "Stop all the tasks?", async function(e) {
await stopAllTasks() await stopAllTasks()
})}) })})