🟢 __init__.py for loading sidebar route and simplifying package check

🛠️ __init__.py -> Removed package name check, always prints loading message
🛠️ __init__.py -> Added async route /sidebar/current to get current folder name
🔴 __init__.py -> Removed commented code and obsolete warning block

🛠️ app/js/functions/sb_fn.js -> Fetches current folder name synchronously via AJAX
🛠️ app/js/functions/settings.js -> Changed sidebar position to "right" and added layout adjustments
🛠️ app/js/functions/utils.js -> Fetches current folder name asynchronously for dynamic path setting
🛠️ app/js/sidebar_node.js -> Uses async fetch to get folder name and construct extension path
This commit is contained in:
Nuked88
2025-05-24 15:40:10 +02:00
parent 1f4a7cfeb1
commit 7a963d9f9a
5 changed files with 49 additions and 16 deletions
+13 -12
View File
@@ -241,18 +241,7 @@ def check_model_existence(metadata_path, config_manager, id_model=None):
# If is different from ComfyUISidebar, change it
if __package__ != "ComfyUI-N-Sidebar":
RED = "\033[31m"
END = '\33[0m'
print(f"{RED}!!!{END}")
print(f"{RED}!!!{END}")
print(f"{RED}WARNING:'{__package__}' folder name is WRONG!!! Please rename it 'ComfyUI-N-Sidebar'.{END}")
print(f"{RED}!!!{END}")
print(f"{RED}!!!{END}")
else:
print("ComfyUI-N-Sidebar is loading...")
print("ComfyUI-N-Sidebar is loading...")
@@ -299,6 +288,18 @@ for folder in folders:
list_panels_array.append(folder)
@server.PromptServer.instance.routes.get("/sidebar/current" )
async def s_get(request):
#current directory
current_dir = os.path.dirname(os.path.realpath(__file__))
current_dir_name = os.path.basename(current_dir)
return web.json_response(current_dir_name, content_type='application/json')
@server.PromptServer.instance.routes.get("/sidebar/backup" )
async def s_get(request):
backup_path = file_path + ".bak"
+18 -1
View File
@@ -1,4 +1,21 @@
const cnPath="../extensions/ComfyUI-N-Sidebar/"
//load folder name
function getNameFolderSync() {
const xhr = new XMLHttpRequest();
xhr.open("GET", "sidebar/current", false); // false = sincrona (blasfemia)
xhr.send(null);
if (xhr.status === 200) {
return JSON.parse(xhr.responseText);
} else {
throw new Error("Errore nella richiesta");
}
}
const nameFolder = getNameFolderSync();
const cnPath = `../extensions/${nameFolder}/`;
function addSidebarStyles(cssPath) {
const timestamp = new Date().getTime();
const linkElement = document.createElement("link");
+8 -1
View File
@@ -1,6 +1,6 @@
let sbPosition = "left";
let sbPosition = "right";
let defaultSearchToggle = "fuzzy";
let defaultSearchOrder = "comfyui";
let current_path = null;
@@ -510,6 +510,13 @@ async function settingsSetup(app,$el) {
addDynamicCSSRule('.side-bar-panel', 'min-width', 'calc('+localStorage.getItem("sidebarWidth")+'px - 35px)');
}
if (localStorage.getItem("Comfy.Settings.Comfy.Sidebar.Location") === null ) {
addDynamicCSSRule('.side-bar-panel', 'min-width', 'calc('+localStorage.getItem("sidebarWidth")+'px - 35px)');
addDynamicCSSRule('.splitter-overlay', 'margin-left', '35px');
}
}
}
catch(err){
+6 -1
View File
@@ -452,7 +452,12 @@ function containsSpecialCharacters(name, level=0) {
}
async function reloadCtxMenu() {
const cnPath="../extensions/ComfyUI-N-Sidebar/"
//load folder name
var nameRequest = await fetch('sidebar/current');
var nameFolder = await nameRequest.json();
const cnPath = `../extensions/${nameFolder}/`
const response3 = await fetch(cnPath +'settings.json');
const settingsData = await response3.json();
+4 -1
View File
@@ -8,7 +8,10 @@ import { GroupNodeConfig, GroupNodeHandler } from "../../../../extensions/core/g
const gnc = GroupNodeConfig;
//import {settingsSetup} from './functions/settings.jsb';
console.time('execution time');
const cnPath = "../extensions/ComfyUI-N-Sidebar/"
//load folder name
var nameRequest = await fetch('sidebar/current');
var nameFolder = await nameRequest.json();
const cnPath = `../extensions/${nameFolder}/`
function jsloader(url) {
return new Promise((resolve, reject) => {
try{