This commit is contained in:
justumen
2025-03-19 17:36:25 +01:00
parent 44d69e8907
commit 39dfb0220a
76 changed files with 3207 additions and 955 deletions

View File

@@ -26,4 +26,52 @@ app.registerExtension({
});
}
}
});
app.registerExtension({
name: "Bjornulf.LoadCivitAILinks",
async nodeCreated(node) {
if (node.comfyClass === "Bjornulf_LoadCivitAILinks") {
// Add a refresh button widget
const refreshButton = node.addWidget(
"button",
"Refresh File List",
null,
() => {
fetch("/get_civitai_links_files", {
method: "POST",
})
.then((response) => response.json())
.then((data) => {
if (data.success) {
// Update the dropdown with the new file list
const dropdownWidget = node.widgets.find(w => w.name === "selected_file");
if (dropdownWidget) {
dropdownWidget.options.values = ["Not selected", ...data.files];
dropdownWidget.value = "Not selected";
app.ui.dialog.show(
"[LoadCivitAILinks] File list refreshed successfully!"
);
}
} else {
app.ui.dialog.show(
`[LoadCivitAILinks] Failed to refresh file list: ${
data.error || "Unknown error"
}`
);
}
})
.catch((error) => {
console.error(
"[LoadCivitAILinks] Error fetching links files:",
error
);
app.ui.dialog.show(
"[LoadCivitAILinks] An error occurred while refreshing the file list."
);
});
}
);
}
},
});