From 48c10d0b955a614dba464f9189f254bbf5fdedc8 Mon Sep 17 00:00:00 2001 From: moldwebs Date: Mon, 12 May 2025 19:48:29 +0300 Subject: [PATCH] Show models used in current workflow (#1819) Simple javascript modify that filter models used in current workflow --- js/model-manager.js | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/js/model-manager.js b/js/model-manager.js index d744a34d..7811ab65 100644 --- a/js/model-manager.js +++ b/js/model-manager.js @@ -81,10 +81,13 @@ export class ModelManager { value: "" }, { label: "Installed", - value: "True" + value: "installed" }, { label: "Not Installed", - value: "False" + value: "not_installed" + }, { + label: "In Workflow", + value: "in_workflow" }]; this.typeList = [{ @@ -254,12 +257,31 @@ export class ModelManager { rowFilter: (rowItem) => { const searchableColumns = ["name", "type", "base", "description", "filename", "save_path"]; + const models_extensions = ['.ckpt', '.pt', '.pt2', '.bin', '.pth', '.safetensors', '.pkl', '.sft']; let shouldShown = grid.highlightKeywordsFilter(rowItem, searchableColumns, this.keywords); if (shouldShown) { - if(this.filter && rowItem.installed !== this.filter) { - return false; + if(this.filter) { + if (this.filter == "in_workflow") { + rowItem.in_workflow = null; + if (Array.isArray(app.graph._nodes)) { + app.graph._nodes.forEach((item, i) => { + if (Array.isArray(item.widgets_values)) { + item.widgets_values.forEach((_item, i) => { + if (rowItem.in_workflow === null && _item !== null && models_extensions.includes("." + _item.toString().split('.').pop())) { + let filename = _item.match(/([^\/]+)(?=\.\w+$)/)[0]; + if (grid.highlightKeywordsFilter(rowItem, searchableColumns, filename)) { + rowItem.in_workflow = "True"; + grid.highlightKeywordsFilter(rowItem, searchableColumns, ""); + } + } + }); + } + }); + } + } + return ((this.filter == "installed" && rowItem.installed == "True") || (this.filter == "not_installed" && rowItem.installed == "False") || (this.filter == "in_workflow" && rowItem.in_workflow == "True")); } if(this.type && rowItem.type !== this.type) { @@ -795,4 +817,4 @@ export class ModelManager { close() { this.element.style.display = "none"; } -} \ No newline at end of file +}