Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
8d7382ab
Commit
8d7382ab
authored
Jan 29, 2023
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add buttons for auto-search in subdirectories for extra tabs
parent
e8efd2ec
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
1 deletion
+41
-1
extraNetworks.js
javascript/extraNetworks.js
+9
-0
ui_extra_networks.py
modules/ui_extra_networks.py
+26
-1
style.css
style.css
+6
-0
No files found.
javascript/extraNetworks.js
View file @
8d7382ab
...
...
@@ -96,3 +96,12 @@ function saveCardPreview(event, tabname, filename){
event
.
stopPropagation
()
event
.
preventDefault
()
}
function
extraNetworksSearchButton
(
tabs_id
,
event
){
searchTextarea
=
gradioApp
().
querySelector
(
"#"
+
tabs_id
+
' > div > textarea'
)
button
=
event
.
target
text
=
button
.
classList
.
contains
(
"search-all"
)
?
""
:
button
.
textContent
.
trim
()
searchTextarea
.
value
=
text
updateInput
(
searchTextarea
)
}
\ No newline at end of file
modules/ui_extra_networks.py
View file @
8d7382ab
import
glob
import
os.path
import
urllib.parse
from
pathlib
import
Path
...
...
@@ -56,7 +57,7 @@ class ExtraNetworksPage:
for
parentdir
in
(
possible_directories
if
possible_directories
is
not
None
else
self
.
allowed_directories_for_previews
()):
parentdir
=
os
.
path
.
abspath
(
parentdir
)
if
abspath
.
startswith
(
parentdir
):
return
abspath
[
len
(
parentdir
):]
.
replace
(
'
\\
'
,
'/'
)
return
abspath
[
len
(
parentdir
):]
.
replace
(
'
\\
'
,
'/'
)
return
""
...
...
@@ -64,6 +65,27 @@ class ExtraNetworksPage:
view
=
shared
.
opts
.
extra_networks_default_view
items_html
=
''
subdirs
=
{}
for
parentdir
in
[
os
.
path
.
abspath
(
x
)
for
x
in
self
.
allowed_directories_for_previews
()]:
for
x
in
glob
.
glob
(
os
.
path
.
join
(
parentdir
,
'**/*'
),
recursive
=
True
):
if
not
os
.
path
.
isdir
(
x
):
continue
subdir
=
os
.
path
.
abspath
(
x
)[
len
(
parentdir
):]
.
replace
(
"
\\
"
,
"/"
)
while
subdir
.
startswith
(
"/"
):
subdir
=
subdir
[
1
:]
subdirs
[
subdir
]
=
1
if
subdirs
:
subdirs
=
{
""
:
1
,
**
subdirs
}
subdirs_html
=
""
.
join
([
f
"""
<button class='gr-button gr-button-lg gr-button-secondary{" search-all" if subdir=="" else ""}' onclick='extraNetworksSearchButton("{tabname}_extra_tabs", event)'>
{html.escape(subdir if subdir!="" else "all")}
</button>
"""
for
subdir
in
subdirs
])
for
item
in
self
.
list_items
():
items_html
+=
self
.
create_html_for_item
(
item
,
tabname
)
...
...
@@ -72,6 +94,9 @@ class ExtraNetworksPage:
items_html
=
shared
.
html
(
"extra-networks-no-cards.html"
)
.
format
(
dirs
=
dirs
)
res
=
f
"""
<div id='{tabname}_{self.name}_subdirs' class='extra-network-subdirs extra-network-subdirs-{view}'>
{subdirs_html}
</div>
<div id='{tabname}_{self.name}_cards' class='extra-network-{view}'>
{items_html}
</div>
...
...
style.css
View file @
8d7382ab
...
...
@@ -807,7 +807,13 @@ footer {
margin
:
0.3em
;
}
.extra-network-subdirs
{
padding
:
0.2em
0.35em
;
}
.extra-network-subdirs
button
{
margin
:
0
0.15em
;
}
#txt2img_extra_networks
.search
,
#img2img_extra_networks
.search
{
display
:
inline-block
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment