mirror of
https://github.com/justUmen/Bjornulf_custom_nodes.git
synced 2026-03-25 22:35:43 -03:00
0.77
This commit is contained in:
@@ -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."
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user