Dr.Lt.Data
2024-05-14 23:54:06 +09:00
parent ef6b6ff690
commit 1c313ee822
9 changed files with 198 additions and 106 deletions

View File

@@ -56,7 +56,7 @@ export class AlternativesInstaller extends ComfyDialog {
let data2 = data1.custom_node;
if(!data2)
continue;
continue;
let content = data1.tags.toLowerCase() + data1.description.toLowerCase() + data2.author.toLowerCase() + data2.description.toLowerCase() + data2.title.toLowerCase();

View File

@@ -41,9 +41,18 @@ async function tryInstallCustomNode(event) {
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(event.detail.target)
});
if(response.status == 403) {
show_message('This action is not allowed with this security level configuration.');
return false;
}
}
api.fetchApi("/manager/reboot");
let response = await api.fetchApi("/manager/reboot");
if(response.status == 403) {
show_message('This action is not allowed with this security level configuration.');
return false;
}
await sleep(300);

View File

@@ -15,7 +15,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, install_via_git_url, install_pip, rebootAPI, free_models } from "./common.js";
import { manager_instance, setManagerInstance, install_via_git_url, install_pip, rebootAPI, free_models, show_message } from "./common.js";
import { ComponentBuilderDialog, load_components, set_component_policy, getPureName } from "./components-manager.js";
import { set_double_click_policy } from "./node_fixer.js";
@@ -520,25 +520,21 @@ async function updateComfyUI() {
const response = await api.fetchApi('/comfyui_manager/update_comfyui');
if (response.status == 400) {
app.ui.dialog.show('Failed to update ComfyUI.');
app.ui.dialog.element.style.zIndex = 10010;
show_message('Failed to update ComfyUI.');
return false;
}
if (response.status == 201) {
app.ui.dialog.show('ComfyUI has been successfully updated.');
app.ui.dialog.element.style.zIndex = 10010;
show_message('ComfyUI has been successfully updated.');
}
else {
app.ui.dialog.show('ComfyUI is already up to date with the latest version.');
app.ui.dialog.element.style.zIndex = 10010;
show_message('ComfyUI is already up to date with the latest version.');
}
return true;
}
catch (exception) {
app.ui.dialog.show(`Failed to update ComfyUI / ${exception}`);
app.ui.dialog.element.style.zIndex = 10010;
show_message(`Failed to update ComfyUI / ${exception}`);
return false;
}
finally {
@@ -560,13 +556,12 @@ async function fetchUpdates(update_check_checkbox) {
const response = await api.fetchApi(`/customnode/fetch_updates?mode=${mode}`);
if (response.status != 200 && response.status != 201) {
app.ui.dialog.show('Failed to fetch updates.');
app.ui.dialog.element.style.zIndex = 10010;
show_message('Failed to fetch updates.');
return false;
}
if (response.status == 201) {
app.ui.dialog.show("There is an updated extension available.<BR><BR><P><B>NOTE:<BR>Fetch Updates is not an update.<BR>Please update from <button id='cm-install-customnodes-button'>Install Custom Nodes</button> </B></P>");
show_message("There is an updated extension available.<BR><BR><P><B>NOTE:<BR>Fetch Updates is not an update.<BR>Please update from <button id='cm-install-customnodes-button'>Install Custom Nodes</button> </B></P>");
const button = document.getElementById('cm-install-customnodes-button');
button.addEventListener("click",
@@ -580,19 +575,16 @@ async function fetchUpdates(update_check_checkbox) {
}
);
app.ui.dialog.element.style.zIndex = 10010;
update_check_checkbox.checked = false;
}
else {
app.ui.dialog.show('All extensions are already up-to-date with the latest versions.');
app.ui.dialog.element.style.zIndex = 10010;
show_message('All extensions are already up-to-date with the latest versions.');
}
return true;
}
catch (exception) {
app.ui.dialog.show(`Failed to update custom nodes / ${exception}`);
app.ui.dialog.element.style.zIndex = 10010;
show_message(`Failed to update custom nodes / ${exception}`);
return false;
}
finally {
@@ -615,11 +607,16 @@ async function updateAll(update_check_checkbox, manager_dialog) {
const response1 = await api.fetchApi('/comfyui_manager/update_comfyui');
const response2 = await api.fetchApi(`/customnode/update_all?mode=${mode}`);
if (response1.status == 400 || response2.status == 400) {
app.ui.dialog.show('Failed to update ComfyUI or several extensions.<BR><BR>See terminal log.<BR>');
app.ui.dialog.element.style.zIndex = 10010;
if (response2.status == 403) {
show_message('This action is not allowed with this security level configuration.');
return false;
}
if (response1.status == 400 || response2.status == 400) {
show_message('Failed to update ComfyUI or several extensions.<BR><BR>See terminal log.<BR>');
return false;
}
if(response1.status == 201 || response2.status == 201) {
const update_info = await response2.json();
@@ -633,7 +630,7 @@ async function updateAll(update_check_checkbox, manager_dialog) {
updated_list = "<BR>UPDATED: "+update_info.updated.join(", ");
}
app.ui.dialog.show(
show_message(
"ComfyUI and all extensions have been updated to the latest version.<BR>To apply the updated custom node, please <button class='cm-small-button' id='cm-reboot-button5'>RESTART</button> ComfyUI. And refresh browser.<BR>"
+failed_list
+updated_list
@@ -646,19 +643,15 @@ async function updateAll(update_check_checkbox, manager_dialog) {
manager_dialog.close();
}
});
app.ui.dialog.element.style.zIndex = 10010;
}
else {
app.ui.dialog.show('ComfyUI and all extensions are already up-to-date with the latest versions.');
app.ui.dialog.element.style.zIndex = 10010;
show_message('ComfyUI and all extensions are already up-to-date with the latest versions.');
}
return true;
}
catch (exception) {
app.ui.dialog.show(`Failed to update ComfyUI or several extensions / ${exception}`);
app.ui.dialog.element.style.zIndex = 10010;
show_message(`Failed to update ComfyUI or several extensions / ${exception}`);
return false;
}
finally {

View File

@@ -1,6 +1,11 @@
import { app } from "../../scripts/app.js";
import { api } from "../../scripts/api.js";
export function show_message(msg) {
app.ui.dialog.show(msg);
app.ui.dialog.element.style.zIndex = 10010;
}
export async function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
@@ -47,6 +52,20 @@ export async function install_checked_custom_node(grid_rows, target_i, caller, m
body: JSON.stringify(target)
});
if(response.status == 403) {
show_message('This action is not allowed with this security level configuration.');
caller.updateMessage('');
await caller.invalidateControl();
return;
}
if(response.status == 404) {
show_message('With the current security level configuration, only custom nodes from the <B>"default channel"</B> can be installed.');
caller.updateMessage('');
await caller.invalidateControl();
return;
}
if(response.status == 400) {
show_message(`${mode} failed: ${target.title}`);
continue;
@@ -94,19 +113,21 @@ export async function install_pip(packages) {
body: packages,
});
if(res.status == 403) {
show_message('This action is not allowed with this security level configuration.');
return;
}
if(res.status == 200) {
app.ui.dialog.show(`PIP package installation is processed.<br>To apply the pip packages, please click the <button id='cm-reboot-button3'><font size='3px'>RESTART</font></button> button in ComfyUI.`);
show_message(`PIP package installation is processed.<br>To apply the pip packages, please click the <button id='cm-reboot-button3'><font size='3px'>RESTART</font></button> button in ComfyUI.`);
const rebootButton = document.getElementById('cm-reboot-button3');
const self = this;
rebootButton.addEventListener("click", rebootAPI);
app.ui.dialog.element.style.zIndex = 10010;
}
else {
app.ui.dialog.show(`Failed to install '${packages}'<BR>See terminal log.`);
app.ui.dialog.element.style.zIndex = 10010;
show_message(`Failed to install '${packages}'<BR>See terminal log.`);
}
}
@@ -116,21 +137,24 @@ export async function install_via_git_url(url, manager_dialog) {
}
if(!isValidURL(url)) {
app.ui.dialog.show(`Invalid Git url '${url}'`);
app.ui.dialog.element.style.zIndex = 10010;
show_message(`Invalid Git url '${url}'`);
return;
}
app.ui.dialog.show(`Wait...<BR><BR>Installing '${url}'`);
app.ui.dialog.element.style.zIndex = 10010;
show_message(`Wait...<BR><BR>Installing '${url}'`);
const res = await api.fetchApi("/customnode/install/git_url", {
method: "POST",
body: url,
});
if(res.status == 403) {
show_message('This action is not allowed with this security level configuration.');
return;
}
if(res.status == 200) {
app.ui.dialog.show(`'${url}' is installed<BR>To apply the installed custom node, please <button id='cm-reboot-button4'><font size='3px'>RESTART</font></button> ComfyUI.`);
show_message(`'${url}' is installed<BR>To apply the installed custom node, please <button id='cm-reboot-button4'><font size='3px'>RESTART</font></button> ComfyUI.`);
const rebootButton = document.getElementById('cm-reboot-button4');
const self = this;
@@ -141,12 +165,9 @@ export async function install_via_git_url(url, manager_dialog) {
manager_dialog.close();
}
});
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;
show_message(`Failed to install '${url}'<BR>See terminal log.`);
}
}
@@ -158,15 +179,9 @@ export async function free_models() {
});
if(res.status == 200) {
app.ui.dialog.show('Models have been unloaded.')
show_message('Models have been unloaded.')
}
else {
app.ui.dialog.show('Unloading of models failed.<BR><BR>Installed ComfyUI may be an outdated version.')
show_message('Unloading of models failed.<BR><BR>Installed ComfyUI may be an outdated version.')
}
app.ui.dialog.element.style.zIndex = 10010;
}
export function show_message(msg) {
app.ui.dialog.show(msg);
app.ui.dialog.element.style.zIndex = 10010;
}

View File

@@ -1,7 +1,7 @@
import { app } from "../../scripts/app.js";
import { api } from "../../scripts/api.js"
import { ComfyDialog, $el } from "../../scripts/ui.js";
import { install_checked_custom_node, manager_instance, rebootAPI } from "./common.js";
import { install_checked_custom_node, manager_instance, rebootAPI, show_message } from "./common.js";
async function install_model(target) {
if(ModelInstaller.instance) {
@@ -20,8 +20,7 @@ async function install_model(target) {
return true;
}
catch(exception) {
app.ui.dialog.show(`Install failed: ${target.title} / ${exception}`);
app.ui.dialog.element.style.zIndex = 10010;
show_message(`Install failed: ${target.title} / ${exception}`);
return false;
}
finally {

View File

@@ -1,24 +1,28 @@
import { app } from "../../scripts/app.js";
import { api } from "../../scripts/api.js"
import { ComfyDialog, $el } from "../../scripts/ui.js";
import { manager_instance, rebootAPI } from "./common.js";
import { manager_instance, rebootAPI, show_message } from "./common.js";
async function restore_snapshot(target) {
if(SnapshotManager.instance) {
try {
const response = await api.fetchApi(`/snapshot/restore?target=${target}`, { cache: "no-store" });
if(response.status == 403) {
show_message('This action is not allowed with this security level configuration.');
return false;
}
if(response.status == 400) {
app.ui.dialog.show(`Restore snapshot failed: ${target.title} / ${exception}`);
app.ui.dialog.element.style.zIndex = 10010;
show_message(`Restore snapshot failed: ${target.title} / ${exception}`);
}
app.ui.dialog.close();
return true;
}
catch(exception) {
app.ui.dialog.show(`Restore snapshot failed: ${target.title} / ${exception}`);
app.ui.dialog.element.style.zIndex = 10010;
show_message(`Restore snapshot failed: ${target.title} / ${exception}`);
return false;
}
finally {
@@ -32,17 +36,21 @@ async function remove_snapshot(target) {
if(SnapshotManager.instance) {
try {
const response = await api.fetchApi(`/snapshot/remove?target=${target}`, { cache: "no-store" });
if(response.status == 403) {
show_message('This action is not allowed with this security level configuration.');
return false;
}
if(response.status == 400) {
app.ui.dialog.show(`Remove snapshot failed: ${target.title} / ${exception}`);
app.ui.dialog.element.style.zIndex = 10010;
show_message(`Remove snapshot failed: ${target.title} / ${exception}`);
}
app.ui.dialog.close();
return true;
}
catch(exception) {
app.ui.dialog.show(`Restore snapshot failed: ${target.title} / ${exception}`);
app.ui.dialog.element.style.zIndex = 10010;
show_message(`Restore snapshot failed: ${target.title} / ${exception}`);
return false;
}
finally {
@@ -58,8 +66,7 @@ async function save_current_snapshot() {
return true;
}
catch(exception) {
app.ui.dialog.show(`Backup snapshot failed: ${exception}`);
app.ui.dialog.element.style.zIndex = 10010;
show_message(`Backup snapshot failed: ${exception}`);
return false;
}
finally {