Skip to content

Commit 5999db3

Browse files
committed
Update 1.20.2
1 parent 3e048d9 commit 5999db3

File tree

9 files changed

+143
-76
lines changed

9 files changed

+143
-76
lines changed

extensions-builtin/sd-webui-ux/javascript/dist/index.js

Lines changed: 20 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extensions-builtin/sd-webui-ux/javascript/overrides.js

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,51 @@ window.onAfterUiUpdate(() => {
120120
}
121121

122122
};
123-
124123

124+
window.restart_reload = function() {
125+
const messageElement = document.createElement('p');
126+
messageElement.style.cssText = `
127+
font-family: monospace;
128+
position: absolute;
129+
top: calc(40% + 110px);
130+
left: 50%;
131+
transform: translate(-50%, -50%);
132+
padding-left: 20px;
133+
text-align: center;
134+
width: max-content;
135+
white-space: pre;
136+
`;
137+
document.body.innerHTML = '';
138+
document.body.appendChild(messageElement);
139+
140+
const animationFrames = [
141+
" ",
142+
". ",
143+
".. ",
144+
"...",
145+
];
146+
147+
let frameIndex = 0;
148+
function updateMessage() {
149+
const animation = animationFrames[frameIndex % animationFrames.length];
150+
messageElement.innerHTML = `Server is restarting please wait${animation} `;
151+
frameIndex++;
152+
}
153+
154+
const requestPing = function() {
155+
updateMessage();
156+
requestGet("./internal/ping", {}, function(data) {
157+
location.reload();
158+
}, function() {
159+
setTimeout(requestPing, 500);
160+
});
161+
};
162+
163+
updateMessage();
164+
setTimeout(requestPing, 1000);
165+
166+
return [];
167+
};
168+
125169

126170
});

extensions-builtin/sd-webui-ux/javascript/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {showContributors, showMembers} from './utils/api_external.js';
88
import {switchMobile} from './utils/mobile.js';
99
import {uiuxOptionSettings} from './components/settings.js';
1010
import {localStorageWrapper, onLocalStorageChange} from './utils/storage.js';
11-
import {setupGenerateObservers, setupCheckpointChangeObserver} from './utils/observers.js';
11+
import {setupGenerateObservers, setupCheckpointChangeObserver, setReloadBackgroundColor} from './utils/observers.js';
1212
import {createTabsForExtensions, injectStylesToIframe, injectStylesAfterUIUX, replaceStylesheet} from './components/extensions.js';
1313
import {setupThemeEditor} from './components/theme_editor.js';
1414
import {UIUX} from './utils/module.js';
@@ -130,7 +130,7 @@ function onUiUxReady(content_div) {
130130
document.querySelector("#github-project-link").href = "https://github.com/anapnoe/sd-webui-ux"
131131
}
132132

133-
133+
setReloadBackgroundColor();
134134

135135
//const totalListeners = countEventListeners(document.body);
136136
//console.warn(`Total event listeners: ${totalListeners}`);

extensions-builtin/sd-webui-ux/javascript/src/utils/observers.js

Lines changed: 66 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {VERSION_DATA} from "../constants.js";
22

33
export function setupGenerateObservers() {
4+
45
const keys = ['#txt2img', '#img2img', '#deforum'];
56
keys.forEach((key) => {
67
const tgb = document.querySelector(`${key}_generate`);
@@ -13,88 +14,63 @@ export function setupGenerateObservers() {
1314
const ts = document.querySelector(`${key}_skip`).closest('.portal');
1415
const loop = document.querySelector(`${key}_loop`);
1516

16-
17-
1817
tib.addEventListener('click', () => {
1918
loop?.classList.add('stop');
2019
});
21-
22-
20+
2321
const gen_observer = new MutationObserver((mutations) => {
2422
mutations.forEach((m) => {
25-
if (tib.style.display === 'none') {
26-
const progress = document.querySelector(`.progressDiv .progress`);
27-
if (progress) {
28-
ti.classList.remove('disable');
29-
setTimeout(() => tib.click(), 500);
30-
}
31-
if (loop) {
32-
if (loop.className.indexOf('stop') !== -1 || loop.className.indexOf('active') === -1) {
33-
loop.classList.remove('stop');
23+
const isNotGenerating = tib.style.display === 'none';
24+
const check = () => {
25+
const progressElExists = document.querySelector(`.progressDiv .progress`);
26+
if (isNotGenerating) {
27+
28+
if (progressElExists) {
29+
setTimeout(() => {
30+
tib.click(); //interrupt
31+
check();
32+
}, 500);
33+
return;
34+
}
35+
36+
if (loop) {
37+
const isLoopActive = loop.classList.contains('active');
38+
const isLoopStopped = loop.classList.contains('stop');
39+
if (isLoopStopped || !isLoopActive) {
40+
loop.classList.remove('stop');
41+
ti.classList.add('disable');
42+
ts?.classList.add('disable');
43+
tg.classList.remove('active');
44+
tgb.classList.remove('disable')
45+
} else if (isLoopActive) {
46+
tgb.click();
47+
tgb.classList.add('disable');
48+
}
49+
} else {
3450
ti.classList.add('disable');
35-
ts?.classList.add('disable');
3651
tg.classList.remove('active');
37-
} else if (loop.className.indexOf('active') !== -1) {
38-
tgb.click();
52+
tgb.classList.remove('disable')
3953
}
54+
4055
} else {
41-
ti.classList.add('disable');
42-
tg.classList.remove('active');
56+
ti.classList.remove('disable');
57+
ts?.classList.remove('disable');
58+
tg.classList.add('active');
59+
tgb.classList.add('disable');
4360
}
44-
} else {
45-
ti.classList.remove('disable');
46-
ts?.classList.remove('disable');
47-
tg.classList.add('active');
48-
}
61+
};
62+
63+
check();
64+
4965
});
5066
});
67+
5168

5269
gen_observer.observe(tib, {attributes: true, attributeFilter: ['style']});
5370
}
5471
});
5572
}
56-
/*
57-
export function setupCheckpointChangeObserver(vScroll, treeView) {
58-
59-
const ch_input = document.querySelector("#setting_sd_model_checkpoint .wrap .secondary-wrap input") || document.querySelector(".gradio-dropdown.model_selection .wrap .secondary-wrap input");
60-
const ch_preload = document.querySelector("#setting_sd_model_checkpoint .wrap") || document.querySelector(".gradio-dropdown.model_selection .wrap");
6173

62-
const ch_footer_selected = document.querySelector("#checkpoints_main_footer_db .model-selected");
63-
const ch_footer_preload = document.querySelector("#checkpoints_main_footer_db .model-preloader");
64-
ch_footer_preload.append(ch_preload);
65-
66-
let hash_value = "";
67-
68-
const selectCard = (value) => {
69-
if (hash_value !== value) {
70-
const name = value.split('.').slice(0, -1).join();
71-
vScroll.selected = new Set([name]);
72-
vScroll.renderItems();
73-
74-
if (treeView) {
75-
treeView.selected = vScroll.selected;
76-
treeView.updateSelectedItems();
77-
}
78-
79-
ch_footer_selected.textContent = value;
80-
console.log("Checkpoint:", value, name);
81-
hash_value = value;
82-
}
83-
};
84-
85-
selectCard(ch_input.value);
86-
87-
const combinedObserver = new MutationObserver(function(mutations) {
88-
mutations.forEach(function(m) {
89-
setTimeout(() => selectCard(ch_input.value), 1000);
90-
});
91-
});
92-
93-
// Observe both the input and the preloaded model in one line
94-
combinedObserver.observe(ch_input, {attributes: true});
95-
combinedObserver.observe(ch_preload, {childList: true, subtree: true});
96-
}
97-
*/
9874

9975
export function setupCheckpointChangeObserver(vScroll) {
10076
const ch_input = document.querySelector("#setting_sd_model_checkpoint .wrap .secondary-wrap input") ||
@@ -181,6 +157,8 @@ export function setupExtraNetworksAddToPromptObserver() {
181157

182158
}
183159

160+
161+
184162
export function setupInputObservers(paramsMapping, apiParams, vScroll, modifyParamsCallback = null) {
185163
Object.keys(paramsMapping).forEach((inputId) => {
186164
const inputElement = document.querySelector(`${inputId}`);
@@ -215,3 +193,27 @@ export function setupInputObservers(paramsMapping, apiParams, vScroll, modifyPar
215193
});
216194
return apiParams;
217195
}
196+
197+
export function setReloadBackgroundColor() {
198+
const bgcolor = getComputedStyle(document.documentElement).getPropertyValue('--ae-main-bg-color').trim();
199+
const color = getComputedStyle(document.documentElement).getPropertyValue('--ae-primary-color').trim();
200+
const encodedColor = color.replace(/#/g, '%23');
201+
const bgsvg = `
202+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
203+
<polygon fill="${encodedColor}" points="19.5,13.7 21.6,9.9 11.8,9.9 16.7,18.5 17.7,16.7 17.1,15.7 16.7,16.5 13.5,10.9 19.9,10.9 18.9,12.7"/>
204+
<polygon fill="${encodedColor}" points="17.3,11.7 15.8,11.7 20.2,19.3 3.8,19.3 12,5.2 14.2,9 15.8,9 12,2.5 1.5,20.7 22.5,20.7"/>
205+
</svg>
206+
`.replace(/\n\s+/g, ' ');
207+
const encodedSVG = encodeURIComponent(bgsvg);
208+
const dataURI = `url("data:image/svg+xml,${encodedSVG}")`;
209+
210+
document.documentElement.style.cssText = `
211+
background-position: 50% 40%;
212+
background-size: 200px;
213+
background-repeat: no-repeat;
214+
background-color: ${bgcolor} !important;
215+
background-image: ${dataURI} !important;
216+
color: ${color};
217+
height: 100%;
218+
`;
219+
}

extensions-builtin/sd-webui-ux/scripts/anapnoe/db_output_images.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def get_instance(cls):
4343
return cls._instance
4444

4545
def allowed_directories_for_previews(self):
46-
return [self.images_folder] # Allow the styles folder
46+
return [self.images_folder]
4747

4848
def register_page(self):
4949
self.allowed_dirs.update(self.allowed_directories_for_previews())

extensions-builtin/sd-webui-ux/scripts/anapnoe_sd_uiux.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
#"uiux_enable_db_extra_networks": shared.OptionInfo(True, "Enable Database for Extra Networks (Needs Restart)"),
117117
"uiux_enable_sd_styles": shared.OptionInfo(True, "Enable Styles (Needs Restart)"),
118118
"uiux_enable_sd_output_images": shared.OptionInfo(True, "Enable Image Browser (Needs Restart)"),
119+
"uiux_sd_output_images_path": shared.OptionInfo("outputs", "Default base path for images"),
119120

120121
#"uiux_enable_event_delegation": shared.OptionInfo(False, "Enable Event Delegation for Extra Networks (Needs Restart)"),
121122
"uiux_max_resolution_output": shared.OptionInfo(

extensions-builtin/sd-webui-ux/scripts/anapnoe_sd_uiux_db.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from modules import script_callbacks, shared, ui_extra_networks
88
from fastapi import FastAPI, HTTPException, Query, Body
99
from typing import Optional, List, Dict, Any
10+
from modules.paths_internal import default_output_dir
11+
from modules.shared import opts
1012

1113
import launch
1214
commit = launch.commit_hash()
@@ -33,7 +35,10 @@
3335
webuidir = Path(basedir).parents[1]
3436
scriptsdir = os.path.join(basedir, "scripts")
3537

36-
imagesdir = os.path.join(webuidir, "outputs")
38+
#imagesdir = os.path.join(webuidir, "outputs")
39+
imagesdir = opts.outdir_samples or opts.uiux_sd_output_images_path
40+
#print(imagesdir)
41+
3742
stylesdir = os.path.join(basedir, "styles_data")
3843

3944
DB_FILE = os.path.join(basedir, 'sd_webui_ux.db')

extensions-builtin/sd-webui-ux/themes/ae_v1_marine.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extensions-builtin/sd-webui-ux/themes/ae_v1_red.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)