forked from extern/easydiffusion
Tabs to 4 spaces
This commit is contained in:
parent
0ea38db7ef
commit
ff9430b8a2
@ -934,10 +934,10 @@ function getPrompts() {
|
|||||||
prompts = prompts.filter(prompt => prompt !== '')
|
prompts = prompts.filter(prompt => prompt !== '')
|
||||||
|
|
||||||
if (activeTags.length > 0) {
|
if (activeTags.length > 0) {
|
||||||
const promptTags = activeTags.map(x => x.name).join(", ")
|
const promptTags = activeTags.map(x => x.name).join(", ")
|
||||||
prompts = prompts.map((prompt) => `${prompt}, ${promptTags}`)
|
prompts = prompts.map((prompt) => `${prompt}, ${promptTags}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
let promptsToMake = applySetOperator(prompts)
|
let promptsToMake = applySetOperator(prompts)
|
||||||
promptsToMake = applyPermuteOperator(promptsToMake)
|
promptsToMake = applyPermuteOperator(promptsToMake)
|
||||||
|
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
var ParameterType = {
|
var ParameterType = {
|
||||||
checkbox: "checkbox",
|
checkbox: "checkbox",
|
||||||
select: "select",
|
select: "select",
|
||||||
select_multiple: "select_multiple",
|
select_multiple: "select_multiple",
|
||||||
custom: "custom",
|
custom: "custom",
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,174 +23,174 @@
|
|||||||
|
|
||||||
/** @type {Array.<Parameter>} */
|
/** @type {Array.<Parameter>} */
|
||||||
var PARAMETERS = [
|
var PARAMETERS = [
|
||||||
{
|
{
|
||||||
id: "theme",
|
id: "theme",
|
||||||
type: ParameterType.select,
|
type: ParameterType.select,
|
||||||
label: "Theme",
|
label: "Theme",
|
||||||
default: "theme-default",
|
default: "theme-default",
|
||||||
note: "customize the look and feel of the ui",
|
note: "customize the look and feel of the ui",
|
||||||
options: [ // Note: options expanded dynamically
|
options: [ // Note: options expanded dynamically
|
||||||
{
|
{
|
||||||
value: "theme-default",
|
value: "theme-default",
|
||||||
label: "Default"
|
label: "Default"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
icon: "fa-palette"
|
icon: "fa-palette"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "save_to_disk",
|
id: "save_to_disk",
|
||||||
type: ParameterType.checkbox,
|
type: ParameterType.checkbox,
|
||||||
label: "Auto-Save Images",
|
label: "Auto-Save Images",
|
||||||
note: "automatically saves images to the specified location",
|
note: "automatically saves images to the specified location",
|
||||||
icon: "fa-download",
|
icon: "fa-download",
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "diskPath",
|
id: "diskPath",
|
||||||
type: ParameterType.custom,
|
type: ParameterType.custom,
|
||||||
label: "Save Location",
|
label: "Save Location",
|
||||||
render: (parameter) => {
|
render: (parameter) => {
|
||||||
return `<input id="${parameter.id}" name="${parameter.id}" size="30" disabled>`
|
return `<input id="${parameter.id}" name="${parameter.id}" size="30" disabled>`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "sound_toggle",
|
id: "sound_toggle",
|
||||||
type: ParameterType.checkbox,
|
type: ParameterType.checkbox,
|
||||||
label: "Enable Sound",
|
label: "Enable Sound",
|
||||||
note: "plays a sound on task completion",
|
note: "plays a sound on task completion",
|
||||||
icon: "fa-volume-low",
|
icon: "fa-volume-low",
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "ui_open_browser_on_start",
|
id: "ui_open_browser_on_start",
|
||||||
type: ParameterType.checkbox,
|
type: ParameterType.checkbox,
|
||||||
label: "Open browser on startup",
|
label: "Open browser on startup",
|
||||||
note: "starts the default browser on startup",
|
note: "starts the default browser on startup",
|
||||||
icon: "fa-window-restore",
|
icon: "fa-window-restore",
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "turbo",
|
id: "turbo",
|
||||||
type: ParameterType.checkbox,
|
type: ParameterType.checkbox,
|
||||||
label: "Turbo Mode",
|
label: "Turbo Mode",
|
||||||
note: "generates images faster, but uses an additional 1 GB of GPU memory",
|
note: "generates images faster, but uses an additional 1 GB of GPU memory",
|
||||||
icon: "fa-forward",
|
icon: "fa-forward",
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "use_cpu",
|
id: "use_cpu",
|
||||||
type: ParameterType.checkbox,
|
type: ParameterType.checkbox,
|
||||||
label: "Use CPU (not GPU)",
|
label: "Use CPU (not GPU)",
|
||||||
note: "warning: this will be *very* slow",
|
note: "warning: this will be *very* slow",
|
||||||
icon: "fa-microchip",
|
icon: "fa-microchip",
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "auto_pick_gpus",
|
id: "auto_pick_gpus",
|
||||||
type: ParameterType.checkbox,
|
type: ParameterType.checkbox,
|
||||||
label: "Automatically pick the GPUs (experimental)",
|
label: "Automatically pick the GPUs (experimental)",
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "use_gpus",
|
id: "use_gpus",
|
||||||
type: ParameterType.select_multiple,
|
type: ParameterType.select_multiple,
|
||||||
label: "GPUs to use (experimental)",
|
label: "GPUs to use (experimental)",
|
||||||
note: "to process in parallel",
|
note: "to process in parallel",
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "use_full_precision",
|
id: "use_full_precision",
|
||||||
type: ParameterType.checkbox,
|
type: ParameterType.checkbox,
|
||||||
label: "Use Full Precision",
|
label: "Use Full Precision",
|
||||||
note: "for GPU-only. warning: this will consume more VRAM",
|
note: "for GPU-only. warning: this will consume more VRAM",
|
||||||
icon: "fa-crosshairs",
|
icon: "fa-crosshairs",
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "auto_save_settings",
|
id: "auto_save_settings",
|
||||||
type: ParameterType.checkbox,
|
type: ParameterType.checkbox,
|
||||||
label: "Auto-Save Settings",
|
label: "Auto-Save Settings",
|
||||||
note: "restores settings on browser load",
|
note: "restores settings on browser load",
|
||||||
icon: "fa-gear",
|
icon: "fa-gear",
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "listen_to_network",
|
id: "listen_to_network",
|
||||||
type: ParameterType.checkbox,
|
type: ParameterType.checkbox,
|
||||||
label: "Make Stable Diffusion available on your network",
|
label: "Make Stable Diffusion available on your network",
|
||||||
note: "Other devices on your network can access this web page",
|
note: "Other devices on your network can access this web page",
|
||||||
icon: "fa-network-wired",
|
icon: "fa-network-wired",
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "listen_port",
|
id: "listen_port",
|
||||||
type: ParameterType.custom,
|
type: ParameterType.custom,
|
||||||
label: "Network port",
|
label: "Network port",
|
||||||
note: "Port that this server listens to. The '9000' part in 'http://localhost:9000'",
|
note: "Port that this server listens to. The '9000' part in 'http://localhost:9000'",
|
||||||
icon: "fa-anchor",
|
icon: "fa-anchor",
|
||||||
render: (parameter) => {
|
render: (parameter) => {
|
||||||
return `<input id="${parameter.id}" name="${parameter.id}" size="6" value="9000" onkeypress="preventNonNumericalInput(event)">`
|
return `<input id="${parameter.id}" name="${parameter.id}" size="6" value="9000" onkeypress="preventNonNumericalInput(event)">`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "test_sd2",
|
id: "test_sd2",
|
||||||
type: ParameterType.checkbox,
|
type: ParameterType.checkbox,
|
||||||
label: "Test SD 2.0",
|
label: "Test SD 2.0",
|
||||||
note: "Experimental! High memory usage! GPU-only! Not the final version! Please restart the program after changing this.",
|
note: "Experimental! High memory usage! GPU-only! Not the final version! Please restart the program after changing this.",
|
||||||
icon: "fa-fire",
|
icon: "fa-fire",
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "use_beta_channel",
|
id: "use_beta_channel",
|
||||||
type: ParameterType.checkbox,
|
type: ParameterType.checkbox,
|
||||||
label: "Beta channel",
|
label: "Beta channel",
|
||||||
note: "Get the latest features immediately (but could be less stable). Please restart the program after changing this.",
|
note: "Get the latest features immediately (but could be less stable). Please restart the program after changing this.",
|
||||||
icon: "fa-fire",
|
icon: "fa-fire",
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
function getParameterSettingsEntry(id) {
|
function getParameterSettingsEntry(id) {
|
||||||
let parameter = PARAMETERS.filter(p => p.id === id)
|
let parameter = PARAMETERS.filter(p => p.id === id)
|
||||||
if (parameter.length === 0) {
|
if (parameter.length === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return parameter[0].settingsEntry
|
return parameter[0].settingsEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
function getParameterElement(parameter) {
|
function getParameterElement(parameter) {
|
||||||
switch (parameter.type) {
|
switch (parameter.type) {
|
||||||
case ParameterType.checkbox:
|
case ParameterType.checkbox:
|
||||||
var is_checked = parameter.default ? " checked" : "";
|
var is_checked = parameter.default ? " checked" : "";
|
||||||
return `<input id="${parameter.id}" name="${parameter.id}"${is_checked} type="checkbox">`
|
return `<input id="${parameter.id}" name="${parameter.id}"${is_checked} type="checkbox">`
|
||||||
case ParameterType.select:
|
case ParameterType.select:
|
||||||
case ParameterType.select_multiple:
|
case ParameterType.select_multiple:
|
||||||
var options = (parameter.options || []).map(option => `<option value="${option.value}">${option.label}</option>`).join("")
|
var options = (parameter.options || []).map(option => `<option value="${option.value}">${option.label}</option>`).join("")
|
||||||
var multiple = (parameter.type == ParameterType.select_multiple ? 'multiple' : '')
|
var multiple = (parameter.type == ParameterType.select_multiple ? 'multiple' : '')
|
||||||
return `<select id="${parameter.id}" name="${parameter.id}" ${multiple}>${options}</select>`
|
return `<select id="${parameter.id}" name="${parameter.id}" ${multiple}>${options}</select>`
|
||||||
case ParameterType.custom:
|
case ParameterType.custom:
|
||||||
return parameter.render(parameter)
|
return parameter.render(parameter)
|
||||||
default:
|
default:
|
||||||
console.error(`Invalid type for parameter ${parameter.id}`);
|
console.error(`Invalid type for parameter ${parameter.id}`);
|
||||||
return "ERROR: Invalid Type"
|
return "ERROR: Invalid Type"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let parametersTable = document.querySelector("#system-settings .parameters-table")
|
let parametersTable = document.querySelector("#system-settings .parameters-table")
|
||||||
/* fill in the system settings popup table */
|
/* fill in the system settings popup table */
|
||||||
function initParameters() {
|
function initParameters() {
|
||||||
PARAMETERS.forEach(parameter => {
|
PARAMETERS.forEach(parameter => {
|
||||||
var element = getParameterElement(parameter)
|
var element = getParameterElement(parameter)
|
||||||
var note = parameter.note ? `<small>${parameter.note}</small>` : "";
|
var note = parameter.note ? `<small>${parameter.note}</small>` : "";
|
||||||
var icon = parameter.icon ? `<i class="fa ${parameter.icon}"></i>` : "";
|
var icon = parameter.icon ? `<i class="fa ${parameter.icon}"></i>` : "";
|
||||||
var newrow = document.createElement('div')
|
var newrow = document.createElement('div')
|
||||||
newrow.innerHTML = `
|
newrow.innerHTML = `
|
||||||
<div>${icon}</div>
|
<div>${icon}</div>
|
||||||
<div><label for="${parameter.id}">${parameter.label}</label>${note}</div>
|
<div><label for="${parameter.id}">${parameter.label}</label>${note}</div>
|
||||||
<div>${element}</div>`
|
<div>${element}</div>`
|
||||||
parametersTable.appendChild(newrow)
|
parametersTable.appendChild(newrow)
|
||||||
parameter.settingsEntry = newrow
|
parameter.settingsEntry = newrow
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
initParameters()
|
initParameters()
|
||||||
@ -243,14 +243,14 @@ async function getAppConfig() {
|
|||||||
testSD2Field.checked = config['test_sd2']
|
testSD2Field.checked = config['test_sd2']
|
||||||
}
|
}
|
||||||
|
|
||||||
let testSD2SettingEntry = getParameterSettingsEntry('test_sd2')
|
let testSD2SettingEntry = getParameterSettingsEntry('test_sd2')
|
||||||
testSD2SettingEntry.style.display = (config.update_branch === 'beta' ? '' : 'none')
|
testSD2SettingEntry.style.display = (config.update_branch === 'beta' ? '' : 'none')
|
||||||
if (config.net && config.net.listen_to_network === false) {
|
if (config.net && config.net.listen_to_network === false) {
|
||||||
listenToNetworkField.checked = false
|
listenToNetworkField.checked = false
|
||||||
}
|
}
|
||||||
if (config.net && config.net.listen_port !== undefined) {
|
if (config.net && config.net.listen_port !== undefined) {
|
||||||
listenPortField.value = config.net.listen_port
|
listenPortField.value = config.net.listen_port
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('get config status response', config)
|
console.log('get config status response', config)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -278,7 +278,6 @@ function getCurrentRenderDeviceSelection() {
|
|||||||
useCPUField.addEventListener('click', function() {
|
useCPUField.addEventListener('click', function() {
|
||||||
let gpuSettingEntry = getParameterSettingsEntry('use_gpus')
|
let gpuSettingEntry = getParameterSettingsEntry('use_gpus')
|
||||||
let autoPickGPUSettingEntry = getParameterSettingsEntry('auto_pick_gpus')
|
let autoPickGPUSettingEntry = getParameterSettingsEntry('auto_pick_gpus')
|
||||||
console.log("hello", this.checked);
|
|
||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
gpuSettingEntry.style.display = 'none'
|
gpuSettingEntry.style.display = 'none'
|
||||||
autoPickGPUSettingEntry.style.display = 'none'
|
autoPickGPUSettingEntry.style.display = 'none'
|
||||||
@ -375,23 +374,23 @@ async function getDevices() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
saveSettingsBtn.addEventListener('click', function() {
|
saveSettingsBtn.addEventListener('click', function() {
|
||||||
let updateBranch = (useBetaChannelField.checked ? 'beta' : 'main')
|
let updateBranch = (useBetaChannelField.checked ? 'beta' : 'main')
|
||||||
|
|
||||||
if (listenPortField.value == '') {
|
if (listenPortField.value == '') {
|
||||||
alert('The network port field must not be empty.')
|
alert('The network port field must not be empty.')
|
||||||
} else if (listenPortField.value<1 || listenPortField.value>65535) {
|
} else if (listenPortField.value<1 || listenPortField.value>65535) {
|
||||||
alert('The network port must be a number from 1 to 65535')
|
alert('The network port must be a number from 1 to 65535')
|
||||||
} else {
|
} else {
|
||||||
changeAppConfig({
|
changeAppConfig({
|
||||||
'render_devices': getCurrentRenderDeviceSelection(),
|
'render_devices': getCurrentRenderDeviceSelection(),
|
||||||
'update_branch': updateBranch,
|
'update_branch': updateBranch,
|
||||||
'ui_open_browser_on_start': uiOpenBrowserOnStartField.checked,
|
'ui_open_browser_on_start': uiOpenBrowserOnStartField.checked,
|
||||||
'listen_to_network': listenToNetworkField.checked,
|
'listen_to_network': listenToNetworkField.checked,
|
||||||
'listen_port': listenPortField.value,
|
'listen_port': listenPortField.value,
|
||||||
'test_sd2': testSD2Field.checked
|
'test_sd2': testSD2Field.checked
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
saveSettingsBtn.classList.add('active')
|
saveSettingsBtn.classList.add('active')
|
||||||
asyncDelay(300).then(() => saveSettingsBtn.classList.remove('active'))
|
asyncDelay(300).then(() => saveSettingsBtn.classList.remove('active'))
|
||||||
})
|
})
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
// https://gomakethings.com/finding-the-next-and-previous-sibling-elements-that-match-a-selector-with-vanilla-js/
|
// https://gomakethings.com/finding-the-next-and-previous-sibling-elements-that-match-a-selector-with-vanilla-js/
|
||||||
function getNextSibling(elem, selector) {
|
function getNextSibling(elem, selector) {
|
||||||
// Get the next sibling element
|
// Get the next sibling element
|
||||||
var sibling = elem.nextElementSibling
|
var sibling = elem.nextElementSibling
|
||||||
|
|
||||||
// If there's no selector, return the first sibling
|
// If there's no selector, return the first sibling
|
||||||
if (!selector) return sibling
|
if (!selector) return sibling
|
||||||
|
|
||||||
// If the sibling matches our selector, use it
|
// If the sibling matches our selector, use it
|
||||||
// If not, jump to the next sibling and continue the loop
|
// If not, jump to the next sibling and continue the loop
|
||||||
while (sibling) {
|
while (sibling) {
|
||||||
if (sibling.matches(selector)) return sibling
|
if (sibling.matches(selector)) return sibling
|
||||||
sibling = sibling.nextElementSibling
|
sibling = sibling.nextElementSibling
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user