Hide search and clear search buttons in settings.
This commit is contained in:
@@ -32,7 +32,9 @@ Download, browse and delete models in ComfyUI.
|
|||||||
<img src="demo-tab-model-info-overview.png" alt="Model Manager Demo Screenshot" width="65%"/>
|
<img src="demo-tab-model-info-overview.png" alt="Model Manager Demo Screenshot" width="65%"/>
|
||||||
|
|
||||||
- View model metadata and file info.
|
- View model metadata and file info.
|
||||||
- Read, edit and save notes in a `.txt` file beside the model. (Autosave optional.)
|
- Read, edit and save notes in a `.txt` file beside the model.
|
||||||
|
- `Ctrl+S` to save when note textarea is in focus.
|
||||||
|
- Optionally enable autosave.
|
||||||
- Change or remove a model's preview image (add a different one using a url or local upload).
|
- Change or remove a model's preview image (add a different one using a url or local upload).
|
||||||
- Rename, move or **permanently** remove model files.
|
- Rename, move or **permanently** remove model files.
|
||||||
|
|
||||||
|
|||||||
20
__init__.py
20
__init__.py
@@ -174,25 +174,33 @@ def model_type_to_dir_name(model_type):
|
|||||||
def ui_rules():
|
def ui_rules():
|
||||||
Rule = config_loader.Rule
|
Rule = config_loader.Rule
|
||||||
return [
|
return [
|
||||||
Rule("sidebar-default-height", 0.5, float, 0.0, 1.0),
|
|
||||||
Rule("sidebar-default-width", 0.5, float, 0.0, 1.0),
|
|
||||||
Rule("sidebar-control-always-compact", False, bool),
|
|
||||||
Rule("model-search-always-append", "", str),
|
Rule("model-search-always-append", "", str),
|
||||||
Rule("model-default-browser-model-type", "checkpoints", str),
|
Rule("model-default-browser-model-type", "checkpoints", str),
|
||||||
Rule("model-real-time-search", True, bool),
|
Rule("model-real-time-search", True, bool),
|
||||||
Rule("model-persistent-search", True, bool),
|
Rule("model-persistent-search", True, bool),
|
||||||
Rule("model-show-label-extensions", False, bool),
|
|
||||||
Rule("model-info-autosave-notes", False, bool),
|
Rule("model-preview-thumbnail-type", "AUTO", str),
|
||||||
Rule("model-preview-fallback-search-safetensors-thumbnail", False, bool),
|
Rule("model-preview-fallback-search-safetensors-thumbnail", False, bool),
|
||||||
|
Rule("model-show-label-extensions", False, bool),
|
||||||
Rule("model-show-add-button", True, bool),
|
Rule("model-show-add-button", True, bool),
|
||||||
Rule("model-show-copy-button", True, bool),
|
Rule("model-show-copy-button", True, bool),
|
||||||
Rule("model-show-load-workflow-button", True, bool),
|
Rule("model-show-load-workflow-button", True, bool),
|
||||||
Rule("model-info-button-on-left", False, bool),
|
Rule("model-info-button-on-left", False, bool),
|
||||||
Rule("model-preview-thumbnail-type", "AUTO", str),
|
|
||||||
Rule("model-add-embedding-extension", False, bool),
|
Rule("model-add-embedding-extension", False, bool),
|
||||||
Rule("model-add-drag-strict-on-field", False, bool),
|
Rule("model-add-drag-strict-on-field", False, bool),
|
||||||
Rule("model-add-offset", 25, int),
|
Rule("model-add-offset", 25, int),
|
||||||
|
|
||||||
|
Rule("model-info-autosave-notes", False, bool),
|
||||||
|
|
||||||
Rule("download-save-description-as-text-file", True, bool),
|
Rule("download-save-description-as-text-file", True, bool),
|
||||||
|
|
||||||
|
Rule("sidebar-default-height", 0.5, float, 0.0, 1.0),
|
||||||
|
Rule("sidebar-default-width", 0.5, float, 0.0, 1.0),
|
||||||
|
Rule("sidebar-control-always-compact", False, bool),
|
||||||
|
Rule("text-input-always-hide-search-button", False, bool),
|
||||||
|
Rule("text-input-always-hide-clear-button", False, bool),
|
||||||
|
|
||||||
Rule("tag-generator-sampler-method", "Frequency", str),
|
Rule("tag-generator-sampler-method", "Frequency", str),
|
||||||
Rule("tag-generator-count", 10, int),
|
Rule("tag-generator-count", 10, int),
|
||||||
Rule("tag-generator-threshold", 2, int),
|
Rule("tag-generator-threshold", 2, int),
|
||||||
|
|||||||
@@ -3206,17 +3206,22 @@ class DownloadView {
|
|||||||
/** @type {HTMLDivElement} */ infos: null,
|
/** @type {HTMLDivElement} */ infos: null,
|
||||||
/** @type {HTMLInputElement} */ overwrite: null,
|
/** @type {HTMLInputElement} */ overwrite: null,
|
||||||
/** @type {HTMLInputElement} */ downloadNotes: null,
|
/** @type {HTMLInputElement} */ downloadNotes: null,
|
||||||
|
/** @type {HTMLButtonElement} */ searchButton: null,
|
||||||
|
/** @type {HTMLButtonElement} */ clearSearchButton: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @type {DOMParser} */
|
/** @type {DOMParser} */
|
||||||
#domParser = null;
|
#domParser = null;
|
||||||
|
|
||||||
|
/** @type {Object.<string, HTMLElement>} */
|
||||||
|
#settings = null;
|
||||||
|
|
||||||
/** @type {() => Promise<void>} */
|
/** @type {() => Promise<void>} */
|
||||||
#updateModels = () => {};
|
#updateModels = () => {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ModelData} modelData
|
* @param {ModelData} modelData
|
||||||
* @param {any} settings
|
* @param {Object.<string, HTMLElement>} settings
|
||||||
* @param {() => Promise<void>} updateModels
|
* @param {() => Promise<void>} updateModels
|
||||||
*/
|
*/
|
||||||
constructor(modelData, settings, updateModels) {
|
constructor(modelData, settings, updateModels) {
|
||||||
@@ -3229,6 +3234,49 @@ class DownloadView {
|
|||||||
$el("h1", ["Input a URL to select a model to download."])
|
$el("h1", ["Input a URL to select a model to download."])
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const searchButton = new ComfyButton({
|
||||||
|
icon: "magnify",
|
||||||
|
tooltip: "Search url",
|
||||||
|
classList: "comfyui-button icon-button",
|
||||||
|
action: async(e) => {
|
||||||
|
const [button, icon, span] = comfyButtonDisambiguate(e.target);
|
||||||
|
button.disabled = true;
|
||||||
|
if (this.elements.url.value === "") {
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
await update();
|
||||||
|
}
|
||||||
|
button.disabled = false;
|
||||||
|
},
|
||||||
|
}).element;
|
||||||
|
settings["model-real-time-search"].addEventListener("change", () => {
|
||||||
|
const hideSearchButton = settings["text-input-always-hide-search-button"].checked;
|
||||||
|
searchButton.style.display = hideSearchButton ? "none" : "";
|
||||||
|
});
|
||||||
|
settings["text-input-always-hide-search-button"].addEventListener("change", () => {
|
||||||
|
const hideSearchButton = settings["text-input-always-hide-search-button"].checked;
|
||||||
|
searchButton.style.display = hideSearchButton ? "none" : "";
|
||||||
|
});
|
||||||
|
this.elements.searchButton = searchButton;
|
||||||
|
|
||||||
|
const clearSearchButton = new ComfyButton({
|
||||||
|
icon: "close",
|
||||||
|
tooltip: "Clear search",
|
||||||
|
classList: "comfyui-button icon-button",
|
||||||
|
action: async(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
this.elements.url.value = "";
|
||||||
|
reset();
|
||||||
|
},
|
||||||
|
}).element;
|
||||||
|
settings["text-input-always-hide-clear-button"].addEventListener("change", () => {
|
||||||
|
const hideClearButton = settings["text-input-always-hide-clear-button"].checked;
|
||||||
|
clearSearchButton.style.display = hideClearButton ? "none" : "";
|
||||||
|
});
|
||||||
|
this.elements.clearSearchButton = clearSearchButton;
|
||||||
|
|
||||||
$el("div.tab-header", {
|
$el("div.tab-header", {
|
||||||
$: (el) => (this.element = el),
|
$: (el) => (this.element = el),
|
||||||
}, [
|
}, [
|
||||||
@@ -3252,32 +3300,8 @@ class DownloadView {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
new ComfyButton({
|
clearSearchButton,
|
||||||
icon: "close",
|
searchButton,
|
||||||
tooltip: "Clear search",
|
|
||||||
classList: "comfyui-button icon-button",
|
|
||||||
action: async(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
this.elements.url.value = "";
|
|
||||||
reset();
|
|
||||||
},
|
|
||||||
}).element,
|
|
||||||
new ComfyButton({
|
|
||||||
icon: "magnify",
|
|
||||||
tooltip: "Search url",
|
|
||||||
classList: "comfyui-button icon-button",
|
|
||||||
action: async(e) => {
|
|
||||||
const [button, icon, span] = comfyButtonDisambiguate(e.target);
|
|
||||||
button.disabled = true;
|
|
||||||
if (this.elements.url.value === "") {
|
|
||||||
reset();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
await update();
|
|
||||||
}
|
|
||||||
button.disabled = false;
|
|
||||||
},
|
|
||||||
}).element,
|
|
||||||
]),
|
]),
|
||||||
$el("div.download-model-infos", {
|
$el("div.download-model-infos", {
|
||||||
$: (el) => (this.elements.infos = el),
|
$: (el) => (this.elements.infos = el),
|
||||||
@@ -3540,6 +3564,12 @@ class DownloadView {
|
|||||||
const infosHtml = this.elements.infos;
|
const infosHtml = this.elements.infos;
|
||||||
infosHtml.innerHTML = "";
|
infosHtml.innerHTML = "";
|
||||||
infosHtml.append.apply(infosHtml, modelInfosHtml);
|
infosHtml.append.apply(infosHtml, modelInfosHtml);
|
||||||
|
|
||||||
|
const hideSearchButtons = settings["text-input-always-hide-search-button"].checked;
|
||||||
|
this.elements.searchButton.style.display = hideSearchButtons ? "none" : "";
|
||||||
|
|
||||||
|
const hideClearSearchButtons = settings["text-input-always-hide-clear-button"].checked;
|
||||||
|
this.elements.clearSearchButton.style.display = hideClearSearchButtons ? "none" : "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3553,6 +3583,7 @@ class BrowseView {
|
|||||||
/** @type {HTMLSelectElement} */ modelSortSelect: null,
|
/** @type {HTMLSelectElement} */ modelSortSelect: null,
|
||||||
/** @type {HTMLInputElement} */ modelContentFilter: null,
|
/** @type {HTMLInputElement} */ modelContentFilter: null,
|
||||||
/** @type {HTMLButtonElement} */ searchButton: null,
|
/** @type {HTMLButtonElement} */ searchButton: null,
|
||||||
|
/** @type {HTMLButtonElement} */ clearSearchButton: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @type {Array} */
|
/** @type {Array} */
|
||||||
@@ -3624,8 +3655,14 @@ class BrowseView {
|
|||||||
);
|
);
|
||||||
updateModelGridCallback();
|
updateModelGridCallback();
|
||||||
|
|
||||||
const searchButtonIsVisible = this.#settingsElements["model-real-time-search"].checked ? "none" : "";
|
const hideSearchButtons = (
|
||||||
this.elements.searchButton.style.display = searchButtonIsVisible;
|
this.#settingsElements["model-real-time-search"].checked |
|
||||||
|
this.#settingsElements["text-input-always-hide-search-button"].checked
|
||||||
|
);
|
||||||
|
this.elements.searchButton.style.display = hideSearchButtons ? "none" : "";
|
||||||
|
|
||||||
|
const hideClearSearchButtons = this.#settingsElements["text-input-always-hide-clear-button"].checked;
|
||||||
|
this.elements.clearSearchButton.style.display = hideClearSearchButtons ? "none" : "";
|
||||||
}
|
}
|
||||||
this.updateModelGrid = updateModelGrid;
|
this.updateModelGrid = updateModelGrid;
|
||||||
|
|
||||||
@@ -3653,15 +3690,40 @@ class BrowseView {
|
|||||||
},
|
},
|
||||||
}).element;
|
}).element;
|
||||||
settingsElements["model-real-time-search"].addEventListener("change", () => {
|
settingsElements["model-real-time-search"].addEventListener("change", () => {
|
||||||
if (this.#settingsElements["model-real-time-search"].checked) {
|
const hideSearchButton = (
|
||||||
searchButton.style.display = "none";
|
this.#settingsElements["text-input-always-hide-search-button"].checked ||
|
||||||
}
|
this.#settingsElements["model-real-time-search"].checked
|
||||||
else {
|
);
|
||||||
searchButton.style.display = "";
|
searchButton.style.display = hideSearchButton ? "none" : "";
|
||||||
}
|
});
|
||||||
|
settingsElements["text-input-always-hide-search-button"].addEventListener("change", () => {
|
||||||
|
const hideSearchButton = (
|
||||||
|
this.#settingsElements["text-input-always-hide-search-button"].checked ||
|
||||||
|
this.#settingsElements["model-real-time-search"].checked
|
||||||
|
);
|
||||||
|
searchButton.style.display = hideSearchButton ? "none" : "";
|
||||||
});
|
});
|
||||||
this.elements.searchButton = searchButton;
|
this.elements.searchButton = searchButton;
|
||||||
|
|
||||||
|
const clearSearchButton = new ComfyButton({
|
||||||
|
icon: "close",
|
||||||
|
tooltip: "Clear search",
|
||||||
|
classList: "comfyui-button icon-button",
|
||||||
|
action: (e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
const [button, icon, span] = comfyButtonDisambiguate(e.target);
|
||||||
|
button.disabled = true;
|
||||||
|
this.elements.modelContentFilter.value = "";
|
||||||
|
updateModelGrid();
|
||||||
|
button.disabled = false;
|
||||||
|
},
|
||||||
|
}).element;
|
||||||
|
settingsElements["text-input-always-hide-clear-button"].addEventListener("change", () => {
|
||||||
|
const hideClearSearchButton = this.#settingsElements["text-input-always-hide-clear-button"].checked;
|
||||||
|
clearSearchButton.style.display = hideClearSearchButton ? "none" : "";
|
||||||
|
});
|
||||||
|
this.elements.clearSearchButton = clearSearchButton;
|
||||||
|
|
||||||
this.element = $el("div", [
|
this.element = $el("div", [
|
||||||
$el("div.row.tab-header", [
|
$el("div.row.tab-header", [
|
||||||
$el("div.row.tab-header-flex-block", [
|
$el("div.row.tab-header-flex-block", [
|
||||||
@@ -3714,19 +3776,7 @@ class BrowseView {
|
|||||||
searchInput,
|
searchInput,
|
||||||
searchDropdown.element,
|
searchDropdown.element,
|
||||||
]),
|
]),
|
||||||
new ComfyButton({
|
clearSearchButton,
|
||||||
icon: "close",
|
|
||||||
tooltip: "Clear search",
|
|
||||||
classList: "comfyui-button icon-button",
|
|
||||||
action: (e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
const [button, icon, span] = comfyButtonDisambiguate(e.target);
|
|
||||||
button.disabled = true;
|
|
||||||
this.elements.modelContentFilter.value = "";
|
|
||||||
updateModelGrid();
|
|
||||||
button.disabled = false;
|
|
||||||
},
|
|
||||||
}).element,
|
|
||||||
searchButton,
|
searchButton,
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
@@ -3768,6 +3818,8 @@ class SettingsView {
|
|||||||
//"sidebar-default-height": null,
|
//"sidebar-default-height": null,
|
||||||
//"sidebar-default-width": null,
|
//"sidebar-default-width": null,
|
||||||
/** @type {HTMLInputElement} */ "sidebar-control-always-compact": null,
|
/** @type {HTMLInputElement} */ "sidebar-control-always-compact": null,
|
||||||
|
/** @type {HTMLInputElement} */ "text-input-always-hide-search-button": null,
|
||||||
|
/** @type {HTMLInputElement} */ "text-input-always-hide-clear-button": null,
|
||||||
|
|
||||||
/** @type {HTMLInputElement} */ "tag-generator-sampler-method": null,
|
/** @type {HTMLInputElement} */ "tag-generator-sampler-method": null,
|
||||||
/** @type {HTMLInputElement} */ "tag-generator-count": null,
|
/** @type {HTMLInputElement} */ "tag-generator-count": null,
|
||||||
@@ -3782,7 +3834,7 @@ class SettingsView {
|
|||||||
* @param {Object} settingsData
|
* @param {Object} settingsData
|
||||||
* @param {boolean} updateModels
|
* @param {boolean} updateModels
|
||||||
*/
|
*/
|
||||||
#setSettings(settingsData, updateModels) {
|
async #setSettings(settingsData, updateModels) {
|
||||||
const settings = this.elements.settings;
|
const settings = this.elements.settings;
|
||||||
for (const [key, value] of Object.entries(settingsData)) {
|
for (const [key, value] of Object.entries(settingsData)) {
|
||||||
const setting = settings[key];
|
const setting = settings[key];
|
||||||
@@ -3801,7 +3853,7 @@ class SettingsView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (updateModels) {
|
if (updateModels) {
|
||||||
this.#updateModels(); // Is this slow?
|
await this.#updateModels(); // Is this slow?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3812,7 +3864,7 @@ class SettingsView {
|
|||||||
async reload(updateModels) {
|
async reload(updateModels) {
|
||||||
const data = await request("/model-manager/settings/load");
|
const data = await request("/model-manager/settings/load");
|
||||||
const settingsData = data["settings"];
|
const settingsData = data["settings"];
|
||||||
this.#setSettings(settingsData, updateModels);
|
await this.#setSettings(settingsData, updateModels);
|
||||||
comfyButtonAlert(this.elements.reloadButton, true);
|
comfyButtonAlert(this.elements.reloadButton, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3846,7 +3898,7 @@ class SettingsView {
|
|||||||
const success = data["success"];
|
const success = data["success"];
|
||||||
if (success) {
|
if (success) {
|
||||||
const settingsData = data["settings"];
|
const settingsData = data["settings"];
|
||||||
this.#setSettings(settingsData, true);
|
await this.#setSettings(settingsData, true);
|
||||||
}
|
}
|
||||||
comfyButtonAlert(this.elements.saveButton, success);
|
comfyButtonAlert(this.elements.saveButton, success);
|
||||||
}
|
}
|
||||||
@@ -4016,7 +4068,6 @@ class SettingsView {
|
|||||||
textContent: "Save notes by default.",
|
textContent: "Save notes by default.",
|
||||||
}),
|
}),
|
||||||
$el("h2", ["Window"]),
|
$el("h2", ["Window"]),
|
||||||
sidebarControl,
|
|
||||||
/*
|
/*
|
||||||
$el("input", {
|
$el("input", {
|
||||||
$: (el) => (settings["sidebar-default-width"] = el),
|
$: (el) => (settings["sidebar-default-width"] = el),
|
||||||
@@ -4039,6 +4090,15 @@ class SettingsView {
|
|||||||
step: 0.05,
|
step: 0.05,
|
||||||
}),
|
}),
|
||||||
*/
|
*/
|
||||||
|
sidebarControl,
|
||||||
|
$checkbox({
|
||||||
|
$: (el) => (settings["text-input-always-hide-search-button"] = el),
|
||||||
|
textContent: "Always hide \"Search\" buttons.",
|
||||||
|
}),
|
||||||
|
$checkbox({
|
||||||
|
$: (el) => (settings["text-input-always-hide-clear-button"] = el),
|
||||||
|
textContent: "Always hide \"Clear Search\" buttons.",
|
||||||
|
}),
|
||||||
$el("h2", ["Model Preview Images"]),
|
$el("h2", ["Model Preview Images"]),
|
||||||
$el("div", [
|
$el("div", [
|
||||||
correctPreviewsButton,
|
correctPreviewsButton,
|
||||||
@@ -4413,6 +4473,16 @@ class ModelManager extends ComfyDialog {
|
|||||||
async #init() {
|
async #init() {
|
||||||
await this.#settingsView.reload(false);
|
await this.#settingsView.reload(false);
|
||||||
await this.#refreshModels();
|
await this.#refreshModels();
|
||||||
|
|
||||||
|
const settings = this.#settingsView.elements.settings;
|
||||||
|
console.log(settings);
|
||||||
|
|
||||||
|
{
|
||||||
|
const hideSearchButtons = settings["text-input-always-hide-search-button"].checked;
|
||||||
|
const hideClearSearchButtons = settings["text-input-always-hide-clear-button"].checked;
|
||||||
|
this.#downloadView.elements.searchButton.style.display = hideSearchButtons ? "none" : "";
|
||||||
|
this.#downloadView.elements.clearSearchButton.style.display = hideClearSearchButtons ? "none" : "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#resetManagerContentsScroll = () => {
|
#resetManagerContentsScroll = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user