reduce verbosity of dirs view buttons

This commit is contained in:
Sj-Si 2024-04-22 19:05:27 -04:00
parent 7e006b8cc5
commit 05a0bf0efe
3 changed files with 16 additions and 8 deletions

View File

@ -1,5 +1,6 @@
<button
class='lg secondary gradio-button custom-button extra-network-dirs-view-button {extra_class}'
title="{title}"
onclick='extraNetworksBtnDirsViewItemOnClick(event, "{tabname_full}")'
data-path="{path}"
>{path}</button>
>{label}</button>

View File

@ -250,8 +250,8 @@ options_templates.update(options_section(('interrogate', "Interrogate"), {
}))
options_templates.update(options_section(('extra_networks', "Extra Networks", "sd"), {
"extra_networks_show_hidden_directories": OptionInfo(True, "Show hidden directories").info("directory is hidden if its name starts with \".\"."),
"extra_networks_hidden_models": OptionInfo("When searched", "Show cards for models in hidden directories", gr.Radio, {"choices": ["Always", "When searched", "Never"]}).info('"When searched" option will only show the item when the search string has 4 characters or more'),
"extra_networks_show_hidden_directories": OptionInfo(True, "Show hidden directories").info("directory is hidden if its name starts with \".\".").needs_reload_ui(),
"extra_networks_hidden_models": OptionInfo("When searched", "Show cards for models in hidden directories", gr.Radio, {"choices": ["Always", "When searched", "Never"]}).info('"When searched" option will only show the item when the search string has 4 characters or more').needs_reload_ui(),
"extra_networks_default_multiplier": OptionInfo(1.0, "Default multiplier for extra networks", gr.Slider, {"minimum": 0.0, "maximum": 2.0, "step": 0.01}),
"extra_networks_card_width": OptionInfo(0, "Card width for Extra Networks").info("in pixels"),
"extra_networks_card_height": OptionInfo(0, "Card height for Extra Networks").info("in pixels"),

View File

@ -678,18 +678,25 @@ class ExtraNetworksPage:
tree.values(),
key=lambda x: shared.natural_sort_key(x.relpath),
)
dirs_html = "".join(
[
dirs_html = []
for node in dir_nodes:
if node.parent is None:
label = node.relpath
else:
label = os.sep.join(node.relpath.split(os.sep)[1:])
dirs_html.append(
self.btn_dirs_view_item_tpl.format(
**{
"extra_class": "search-all" if node.relpath == "" else "",
"tabname_full": f"{tabname}_{self.extra_networks_tabname}",
"title": html.escape(node.abspath),
"path": html.escape(node.relpath),
"label": html.escape(label),
}
)
for node in dir_nodes
]
)
)
dirs_html = "".join(dirs_html)
return dirs_html