Show models used in current workflow (#1819)

Simple javascript modify that filter models used in current workflow
This commit is contained in:
moldwebs 2025-05-12 19:48:29 +03:00 committed by GitHub
parent 9bb56b1457
commit 48c10d0b95
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -81,10 +81,13 @@ export class ModelManager {
value: "" value: ""
}, { }, {
label: "Installed", label: "Installed",
value: "True" value: "installed"
}, { }, {
label: "Not Installed", label: "Not Installed",
value: "False" value: "not_installed"
}, {
label: "In Workflow",
value: "in_workflow"
}]; }];
this.typeList = [{ this.typeList = [{
@ -254,12 +257,31 @@ export class ModelManager {
rowFilter: (rowItem) => { rowFilter: (rowItem) => {
const searchableColumns = ["name", "type", "base", "description", "filename", "save_path"]; 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); let shouldShown = grid.highlightKeywordsFilter(rowItem, searchableColumns, this.keywords);
if (shouldShown) { if (shouldShown) {
if(this.filter && rowItem.installed !== this.filter) { if(this.filter) {
return false; 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) { if(this.type && rowItem.type !== this.type) {
@ -795,4 +817,4 @@ export class ModelManager {
close() { close() {
this.element.style.display = "none"; this.element.style.display = "none";
} }
} }