diff --git a/__init__.py b/__init__.py index 363f1df..0ff578a 100644 --- a/__init__.py +++ b/__init__.py @@ -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" diff --git a/app/css/base_style_sb.css b/app/css/base_style_sb.css index 2496bb9..8415109 100644 --- a/app/css/base_style_sb.css +++ b/app/css/base_style_sb.css @@ -760,8 +760,8 @@ /* Settings */ #switch_settings{ - bottom: 5px; - position: absolute; + /*bottom: 5px; + position: absolute;*/ width: -moz-available; /* WebKit-based browsers will ignore this. */ width: -webkit-fill-available; /* Mozilla-based browsers will ignore this. */ width: fill-available; diff --git a/app/html/sidebar.html b/app/html/sidebar.html index 8b65fa4..0cc33a5 100644 --- a/app/html/sidebar.html +++ b/app/html/sidebar.html @@ -7,11 +7,12 @@ C
diff --git a/app/js/functions/sb_fn.js b/app/js/functions/sb_fn.js index 0718b43..d1d414f 100644 --- a/app/js/functions/sb_fn.js +++ b/app/js/functions/sb_fn.js @@ -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"); diff --git a/app/js/functions/settings.js b/app/js/functions/settings.js index 194fd98..f114a8e 100644 --- a/app/js/functions/settings.js +++ b/app/js/functions/settings.js @@ -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){ diff --git a/app/js/functions/utils.js b/app/js/functions/utils.js index c010113..efee64d 100644 --- a/app/js/functions/utils.js +++ b/app/js/functions/utils.js @@ -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(); diff --git a/app/js/sidebar_node.js b/app/js/sidebar_node.js index d198fac..cb34130 100644 --- a/app/js/sidebar_node.js +++ b/app/js/sidebar_node.js @@ -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{ diff --git a/pyproject.toml b/pyproject.toml index 7f52ed4..caa251c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-n-sidebar" description = "A simple sidebar for ComfyUI." -version = "1.5.8" +version = "1.6.0" license = { file = "LICENSE" } [project.urls]