Skip to content

Commit

Permalink
- Fixed bug on dragging templates
Browse files Browse the repository at this point in the history
  - Added multi user support on templates
  • Loading branch information
Nuked88 committed Jul 5, 2024
1 parent 3a7940b commit 7ae7da4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ For what i know nobody did it, so i did it.
Maybe you don't need it. I need it >.<

# Updates
- 05-07-2024
- Fixed bug on dragging templates
- Added multi user support on templates


- 04-06-2024
- Fixed some bugs
Expand Down Expand Up @@ -157,8 +161,11 @@ PS: Workflow Path
- [x] Templates
- [ ] Custom Shortcuts
- [ ] Export and Import Settings
- [ ] Touch Support


### Known Issues:
- After you drag a template onto the workflow, if you drag any other file from your PC that does not include a workflow, it will paste the last template you dragged again.

## Contributing

Expand Down
16 changes: 13 additions & 3 deletions app/panels/custom_templates/custom_templates.jsb
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ var custom_templates = (function () {
app.canvas.graph_mouse[1] = coord[1];
app.canvas.pasteFromClipboard();
localStorage.removeItem("litegrapheditor_clipboard");
draggedElement.dataset.data = NaN;
//draggedElement.dataset.data = NaN;
});
} else if (draggedElement.id === 'sidebarItem' && (event.target.classList.contains('sidebarCategory') || event.target.classList.contains('displayNamesList'))) {
const ulElement = event.target.querySelector('ul');
Expand Down Expand Up @@ -386,8 +386,18 @@ var custom_templates = (function () {

async function readComfyTemplates() {
let comfy_templates = {};
try {
const response = await fetch('./userdata/comfy.templates.json');
try {
//multi user check
//if Comfy.User local storage exists
if (localStorage.getItem('Comfy.userId')) {
headers = {
'Comfy-User': localStorage.getItem('Comfy.userId')
}
} else {
headers = {}
}

const response = await fetch('./userdata/comfy.templates.json', { headers: headers });
comfy_templates = await response.json();
} catch (error) {
console.error('Error fetching data:', error);
Expand Down
6 changes: 4 additions & 2 deletions app/panels/custom_workflows/custom_workflows.jsb
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ var custom_workflows = (function () {


function createHtmlFromTree(tree, parentElement) {
// Prima, crea le sottocartelle
// Make i subfolder
for (const key in tree) {
if (key !== 'workflows') {
const subfolderLi = document.createElement('li');
Expand All @@ -541,7 +541,7 @@ var custom_workflows = (function () {
}
}

// Poi, crea i workflow
// Then make workflows
if (tree.workflows) {
tree.workflows.forEach(workflow => {
const workflowItem = document.createElement('li');
Expand All @@ -550,6 +550,7 @@ var custom_workflows = (function () {
workflowItem.dataset.nameworkflow = workflow.name;
workflowItem.dataset.data = workflow.path;
workflowItem.dataset.id = workflow.id;
workflowItem.title = workflow.name;
workflowItem.textContent = workflow.name;
workflowItem.draggable = true;
parentElement.appendChild(workflowItem);
Expand Down Expand Up @@ -617,6 +618,7 @@ var custom_workflows = (function () {
displayNameItem.classList.add("sidebarItem");
displayNameItem.id = "sidebarWorkflowItem"
displayNameItem.textContent = data[displayName].name;
displayNameItem.title = data[displayName].name;
displayNameItem.dataset.nameworkflow = data[displayName].name;
displayNameItem.dataset.data = data[displayName].path;
displayNameItem.dataset.id = displayName;
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "comfyui-n-sidebar"
description = "A simple sidebar for ComfyUI."
version = "1.2.1"
version = "1.2.2"
license = "LICENSE"

[project.urls]
Expand Down

0 comments on commit 7ae7da4

Please sign in to comment.