feat: Install via git url
This commit is contained in:
@@ -5,7 +5,7 @@ import { CustomNodesInstaller } from "./custom-nodes-downloader.js";
|
||||
import { AlternativesInstaller } from "./a1111-alter-downloader.js";
|
||||
import { SnapshotManager } from "./snapshot.js";
|
||||
import { ModelInstaller } from "./model-downloader.js";
|
||||
import { manager_instance, setManagerInstance } from "./common.js";
|
||||
import { manager_instance, setManagerInstance, install_via_git_url } from "./common.js";
|
||||
|
||||
var style = document.createElement('style');
|
||||
style.innerHTML = `
|
||||
@@ -372,6 +372,17 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
SnapshotManager.instance.show();
|
||||
}
|
||||
}),
|
||||
$el("button", {
|
||||
type: "button",
|
||||
textContent: "Install via Git URL",
|
||||
onclick: () => {
|
||||
var url = prompt("Please enter the URL of the Git repository to install", "");
|
||||
|
||||
if (url !== null) {
|
||||
install_via_git_url(url);
|
||||
}
|
||||
}
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
31
js/common.js
31
js/common.js
@@ -59,4 +59,35 @@ export var manager_instance = null;
|
||||
|
||||
export function setManagerInstance(obj) {
|
||||
manager_instance = obj;
|
||||
}
|
||||
|
||||
function isValidURL(url) {
|
||||
const pattern = /^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/;
|
||||
return pattern.test(url);
|
||||
}
|
||||
|
||||
export async function install_via_git_url(url) {
|
||||
if(!url) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!isValidURL(url)) {
|
||||
app.ui.dialog.show(`Invalid Git url '${url}'`);
|
||||
app.ui.dialog.element.style.zIndex = 10010;
|
||||
return;
|
||||
}
|
||||
|
||||
app.ui.dialog.show(`Wait...<BR><BR>Installing '${url}'`);
|
||||
app.ui.dialog.element.style.zIndex = 10010;
|
||||
|
||||
const res = await api.fetchApi(`/customnode/install/git_url?url=${url}`);
|
||||
|
||||
if(res.status == 200) {
|
||||
app.ui.dialog.show(`'${url}' is installed<BR>To apply the installed/disabled/enabled custom node, please restart ComfyUI.`);
|
||||
app.ui.dialog.element.style.zIndex = 10010;
|
||||
}
|
||||
else {
|
||||
app.ui.dialog.show(`Failed to install '${url}'<BR>See terminal log.`);
|
||||
app.ui.dialog.element.style.zIndex = 10010;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user