Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
72cdd83c
Commit
72cdd83c
authored
Mar 03, 2023
by
pythongosssss
Browse files
Readded loading file
parent
a5c5c97d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
48 deletions
+26
-48
web/index.html
web/index.html
+1
-24
web/scripts/app.js
web/scripts/app.js
+16
-13
web/scripts/ui.js
web/scripts/ui.js
+9
-11
No files found.
web/index.html
View file @
72cdd83c
...
@@ -12,28 +12,5 @@
...
@@ -12,28 +12,5 @@
window
.
graph
=
app
.
graph
;
window
.
graph
=
app
.
graph
;
</script>
</script>
</head>
</head>
<body>
<body></body>
<script>
return
;
let
runningNodeId
=
null
;
let
progress
=
null
;
let
clientId
=
null
;
var
input
=
document
.
createElement
(
"
input
"
);
input
.
setAttribute
(
"
type
"
,
"
file
"
);
input
.
setAttribute
(
"
accept
"
,
"
.json,image/png
"
);
input
.
style
.
display
=
"
none
"
;
document
.
body
.
appendChild
(
input
);
input
.
addEventListener
(
"
change
"
,
function
()
{
var
file
=
input
.
files
[
0
];
prompt_file_load
(
file
);
});
function
loadGraph
()
{
input
.
click
();
}
</script>
</body>
</html>
</html>
web/scripts/app.js
View file @
72cdd83c
...
@@ -300,19 +300,7 @@ class ComfyApp {
...
@@ -300,19 +300,7 @@ class ComfyApp {
event
.
preventDefault
();
event
.
preventDefault
();
event
.
stopPropagation
();
event
.
stopPropagation
();
const
file
=
event
.
dataTransfer
.
files
[
0
];
const
file
=
event
.
dataTransfer
.
files
[
0
];
await
this
.
handleFile
(
file
);
if
(
file
.
type
===
"
image/png
"
)
{
const
pngInfo
=
await
getPngMetadata
(
file
);
if
(
pngInfo
&&
pngInfo
.
workflow
)
{
this
.
loadGraphData
(
JSON
.
parse
(
pngInfo
.
workflow
));
}
}
else
if
(
file
.
type
===
"
application/json
"
||
file
.
name
.
endsWith
(
"
.json
"
))
{
const
reader
=
new
FileReader
();
reader
.
onload
=
()
=>
{
this
.
loadGraphData
(
JSON
.
parse
(
reader
.
result
));
};
reader
.
readAsText
(
file
);
}
});
});
}
}
...
@@ -630,6 +618,21 @@ class ComfyApp {
...
@@ -630,6 +618,21 @@ class ComfyApp {
this
.
canvas
.
draw
(
true
,
true
);
this
.
canvas
.
draw
(
true
,
true
);
await
this
.
ui
.
queue
.
update
();
await
this
.
ui
.
queue
.
update
();
}
}
async
handleFile
(
file
)
{
if
(
file
.
type
===
"
image/png
"
)
{
const
pngInfo
=
await
getPngMetadata
(
file
);
if
(
pngInfo
&&
pngInfo
.
workflow
)
{
this
.
loadGraphData
(
JSON
.
parse
(
pngInfo
.
workflow
));
}
}
else
if
(
file
.
type
===
"
application/json
"
||
file
.
name
.
endsWith
(
"
.json
"
))
{
const
reader
=
new
FileReader
();
reader
.
onload
=
()
=>
{
this
.
loadGraphData
(
JSON
.
parse
(
reader
.
result
));
};
reader
.
readAsText
(
file
);
}
}
}
}
export
const
app
=
new
ComfyApp
();
export
const
app
=
new
ComfyApp
();
web/scripts/ui.js
View file @
72cdd83c
...
@@ -159,18 +159,16 @@ export class ComfyUI {
...
@@ -159,18 +159,16 @@ export class ComfyUI {
this
.
history
.
update
();
this
.
history
.
update
();
});
});
var
input
=
document
.
createElement
(
"
input
"
);
const
fileInput
=
$el
(
"
input
"
,
{
input
.
setAttribute
(
"
type
"
,
"
file
"
);
type
:
"
file
"
,
input
.
setAttribute
(
"
accept
"
,
"
.json,image/png
"
);
accept
:
"
.json,image/png
"
,
input
.
style
.
display
=
"
none
"
;
style
:
"
display: none
"
,
document
.
body
.
appendChild
(
input
);
parent
:
document
.
body
,
onchange
:
()
=>
{
input
.
addEventListener
(
"
change
"
,
function
()
{
app
.
handleFile
(
fileInput
.
files
[
0
]);
var
file
=
input
.
files
[
0
];
},
prompt_file_load
(
file
);
});
});
this
.
menuContainer
=
$el
(
"
div.comfy-menu
"
,
{
parent
:
document
.
body
},
[
this
.
menuContainer
=
$el
(
"
div.comfy-menu
"
,
{
parent
:
document
.
body
},
[
$el
(
"
span
"
,
{
$
:
(
q
)
=>
(
this
.
queueSize
=
q
)
}),
$el
(
"
span
"
,
{
$
:
(
q
)
=>
(
this
.
queueSize
=
q
)
}),
$el
(
"
button.comfy-queue-btn
"
,
{
textContent
:
"
Queue Prompt
"
,
onclick
:
()
=>
app
.
queuePrompt
(
0
)
}),
$el
(
"
button.comfy-queue-btn
"
,
{
textContent
:
"
Queue Prompt
"
,
onclick
:
()
=>
app
.
queuePrompt
(
0
)
}),
...
@@ -214,7 +212,7 @@ export class ComfyUI {
...
@@ -214,7 +212,7 @@ export class ComfyUI {
},
0
);
},
0
);
},
},
}),
}),
$el
(
"
button
"
,
{
textContent
:
"
Load
"
,
onclick
:
()
=>
{}
}),
$el
(
"
button
"
,
{
textContent
:
"
Load
"
,
onclick
:
()
=>
fileInput
.
click
()
}),
$el
(
"
button
"
,
{
textContent
:
"
Clear
"
,
onclick
:
()
=>
app
.
graph
.
clear
()
}),
$el
(
"
button
"
,
{
textContent
:
"
Clear
"
,
onclick
:
()
=>
app
.
graph
.
clear
()
}),
$el
(
"
button
"
,
{
textContent
:
"
Load Default
"
,
onclick
:
()
=>
app
.
loadGraphData
()
}),
$el
(
"
button
"
,
{
textContent
:
"
Load Default
"
,
onclick
:
()
=>
app
.
loadGraphData
()
}),
]);
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment