diff --git a/__init__.py b/__init__.py index 499b5c20..d6d8021e 100644 --- a/__init__.py +++ b/__init__.py @@ -1,13 +1,13 @@ -from .nodes import LorasEndpoint +from .nodes.lora_gateway import LoRAGateway NODE_CLASS_MAPPINGS = { - "LorasEndpoint": LorasEndpoint + "LoRAGateway": LoRAGateway +} + +NODE_DISPLAY_NAME_MAPPINGS = { + "LoRAGateway": "LoRAGateway" } WEB_DIRECTORY = "./js" -# Add this init function to properly register routes -def init(): - LorasEndpoint.add_routes() - -__all__ = ['NODE_CLASS_MAPPINGS'] \ No newline at end of file +__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS', 'WEB_DIRECTORY'] \ No newline at end of file diff --git a/nodes.py b/lora_manager.py similarity index 99% rename from nodes.py rename to lora_manager.py index efc23c4c..b1741314 100644 --- a/nodes.py +++ b/lora_manager.py @@ -11,6 +11,7 @@ from .utils.lora_metadata import extract_lora_metadata from typing import Dict, Optional from .services.civitai_client import CivitaiClient import folder_paths +import logging class LorasEndpoint: def __init__(self): diff --git a/nodes/__init__.py b/nodes/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/nodes/lora_gateway.py b/nodes/lora_gateway.py new file mode 100644 index 00000000..970e944c --- /dev/null +++ b/nodes/lora_gateway.py @@ -0,0 +1,24 @@ +from ..lora_manager import LorasEndpoint + + +class LoRAGateway: + """ + LoRA Gateway Node + Acts as the entry point for LoRA management services + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": {}, + "optional": {} + } + + RETURN_TYPES = () + FUNCTION = "register_services" + CATEGORY = "LoRA Management" + + @classmethod + def register_services(cls): + # Service registration logic + LorasEndpoint.add_routes() + return () \ No newline at end of file diff --git a/static/js/script.js b/static/js/script.js index 6f51a179..d33df96e 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -292,19 +292,30 @@ document.addEventListener('DOMContentLoaded', function() { }, 500); } }); + + // Restore folder filter state + restoreFolderFilter(); + + // Restore scroll position if exists + const savedScrollPos = localStorage.getItem('scrollPosition'); + if (savedScrollPos !== null) { + window.scrollTo(0, parseInt(savedScrollPos)); + localStorage.removeItem('scrollPosition'); + } }); function toggleFolder(element) { - // Remove active class from all tags if clicking already active tag - if (element.classList.contains('active')) { - document.querySelectorAll('.tag').forEach(tag => tag.classList.remove('active')); - // Show all cards - document.querySelectorAll('.lora-card').forEach(card => card.style.display = ''); - } else { - // Remove active class from all tags - document.querySelectorAll('.tag').forEach(tag => tag.classList.remove('active')); + // Store the previous state + const wasActive = element.classList.contains('active'); + + // Remove active class from all tags + document.querySelectorAll('.tag').forEach(tag => tag.classList.remove('active')); + + if (!wasActive) { // Add active class to clicked tag element.classList.add('active'); + // Store active folder in localStorage + localStorage.setItem('activeFolder', element.getAttribute('data-folder')); // Hide all cards first document.querySelectorAll('.lora-card').forEach(card => { if (card.getAttribute('data-folder') === element.getAttribute('data-folder')) { @@ -313,6 +324,29 @@ function toggleFolder(element) { card.style.display = 'none'; } }); + } else { + // Clear stored folder when deactivating + localStorage.removeItem('activeFolder'); + // Show all cards + document.querySelectorAll('.lora-card').forEach(card => card.style.display = ''); + } +} + +// Add this function to restore folder filter state +function restoreFolderFilter() { + const activeFolder = localStorage.getItem('activeFolder'); + if (activeFolder !== null) { + const folderTag = document.querySelector(`.tag[data-folder="${activeFolder}"]`); + if (folderTag) { + folderTag.classList.add('active'); + document.querySelectorAll('.lora-card').forEach(card => { + if (card.getAttribute('data-folder') === activeFolder) { + card.style.display = ''; + } else { + card.style.display = 'none'; + } + }); + } } } @@ -408,7 +442,10 @@ async function fetchCivitai() { loadingStatus.textContent = 'Metadata update complete'; setTimeout(() => { loadingOverlay.style.display = 'none'; - // Optionally reload the page to show updated data + // Store current scroll position + const scrollPos = window.scrollY; + localStorage.setItem('scrollPosition', scrollPos.toString()); + // Reload the page window.location.reload(); }, 2000);