mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
ability to disable parts of the app
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
@@ -61,7 +61,7 @@ async function initChangelog() {
|
||||
const search = gradioApp().querySelector('#changelog_search > label> textarea');
|
||||
const md = gradioApp().getElementById('changelog_markdown');
|
||||
if (!search || !md) {
|
||||
error('initChangelog', 'Missing search or markdown elements');
|
||||
// error('initChangelog', 'Missing search or markdown elements');
|
||||
return;
|
||||
}
|
||||
const searchChangelog = async (e) => {
|
||||
|
||||
@@ -577,7 +577,8 @@ function setupExtraNetworksForTab(tabName) {
|
||||
|
||||
async function showNetworks() {
|
||||
for (const tabName of ['txt2img', 'img2img', 'control', 'video']) {
|
||||
if (window.opts.extra_networks_show) gradioApp().getElementById(`${tabName}_extra_networks_btn`).click();
|
||||
const btn = gradioApp().getElementById(`${tabName}_extra_networks_btn`);
|
||||
if (window.opts.extra_networks_show && btn) btn.click();
|
||||
}
|
||||
log('showNetworks');
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ async function initLogMonitor() {
|
||||
const el = document.getElementsByTagName('footer')[0];
|
||||
if (!el) return;
|
||||
el.classList.add('log-monitor');
|
||||
if (window.opts.ui_disabled?.includes('logs')) return;
|
||||
el.innerHTML = `
|
||||
<table id="logMonitor" style="width: 100%;">
|
||||
<thead style="display: block; text-align: left; border-bottom: solid 1px var(--button-primary-border-color)">
|
||||
|
||||
@@ -74,6 +74,8 @@ function executeCallbacks(queue, arg) {
|
||||
}
|
||||
}
|
||||
|
||||
const anyPromptExists = () => gradioApp().querySelectorAll('.main-prompts').length > 0;
|
||||
|
||||
function scheduleAfterUiUpdateCallbacks() {
|
||||
clearTimeout(uiAfterUpdateTimeout);
|
||||
uiAfterUpdateTimeout = setTimeout(() => executeCallbacks(uiAfterUpdateCallbacks, 500));
|
||||
@@ -96,7 +98,7 @@ async function mutationCallback(mutations) {
|
||||
|
||||
if (mutationTimer) clearTimeout(mutationTimer);
|
||||
mutationTimer = setTimeout(async () => {
|
||||
if (!executedOnLoaded && gradioApp().getElementById('txt2img_prompt')) { // execute once
|
||||
if (!executedOnLoaded && anyPromptExists()) { // execute once
|
||||
executedOnLoaded = true;
|
||||
executeCallbacks(uiLoadedCallbacks);
|
||||
}
|
||||
|
||||
@@ -168,17 +168,21 @@ async function tooltipHide(e) {
|
||||
localeData.currentElement = null;
|
||||
}
|
||||
|
||||
async function validateHints(json, elements) {
|
||||
async function validateHints(json, elements, tab) {
|
||||
json.missing = [];
|
||||
const data = Object.values(json).flat().filter((e) => e.hint.length > 0);
|
||||
for (const e of data) e.label = e.label.trim();
|
||||
if (tab) {
|
||||
elements = elements.filter((el) => el.closest(`#${tab}_tabitem`)); // include only elements within specified tab
|
||||
elements = elements.filter((el) => !el.closest(`#${tab}_scripts_tabitem`));
|
||||
}
|
||||
let original = elements.map((e) => e.textContent.toLowerCase().trim()).sort(); // should be case sensitive
|
||||
let duplicateUI = original.filter((e, i, a) => a.indexOf(e.toLowerCase()) !== i).sort();
|
||||
original = [...new Set(original)]; // remove duplicates
|
||||
duplicateUI = [...new Set(duplicateUI)]; // remove duplicates
|
||||
const current = data.map((e) => e.label.toLowerCase().trim()).sort(); // should be case sensitive
|
||||
log('all elements:', original);
|
||||
log('all hints:', current);
|
||||
// log('all elements:', original);
|
||||
// log('all hints:', current);
|
||||
log('hints-differences', { elements: original.length, hints: current.length });
|
||||
const missingHints = original.filter((e) => !current.includes(e.toLowerCase())).sort();
|
||||
const orphanedHints = current.filter((e) => !original.includes(e.toLowerCase())).sort();
|
||||
@@ -333,6 +337,7 @@ async function setHints(analyze = false) {
|
||||
log('setHints', { type: localeData.type, locale: localeData.locale, elements: elements.length, localized, hints, data: localeData.data.length, override: overrideData.length, time: Math.round(t1 - t0) });
|
||||
// sortUIElements();
|
||||
if (analyze) {
|
||||
log('analyzing hints', 'control_tabitem');
|
||||
const [missingHints, orphanedHints] = await validateHints(json, elements);
|
||||
await addMissingHints(json, missingHints);
|
||||
await removeOrphanedHints(json, orphanedHints);
|
||||
|
||||
Reference in New Issue
Block a user