Compare commits
128
Commits
remove-indexdb
...
beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9e2f8c844 | ||
|
|
f5b42a358f | ||
|
|
acaa2e4c35 | ||
|
|
99126eea03 | ||
|
|
98e5772cb2 | ||
|
|
a23b6cd56b | ||
|
|
fb5e3ae89e | ||
|
|
2f4d3c26a9 | ||
|
|
8456ea44bf | ||
|
|
7daf20238b | ||
|
|
2697daa7b8 | ||
|
|
64e5f7f480 | ||
|
|
c2780caad4 | ||
|
|
fb9f355c6a | ||
|
|
e751e0543a | ||
|
|
bece4a711f | ||
|
|
f62e1dc1a5 | ||
|
|
cb623b6e5f | ||
|
|
b1052d32b2 | ||
|
|
5442392003 | ||
|
|
3b23b8aa91 | ||
|
|
c385393313 | ||
|
|
db9245b2ef | ||
|
|
eccfd87ce4 | ||
|
|
201a1aabd5 | ||
|
|
a251035fee | ||
|
|
87a1d96c2f | ||
|
|
8e1c6a47cb | ||
|
|
f68a5e994a | ||
|
|
ee2a3a2d2c | ||
|
|
3da2fcfa72 | ||
|
|
f3c8e8c98d | ||
|
|
3f02557170 | ||
|
|
23652905c9 | ||
|
|
d9c2015850 | ||
|
|
cf5ce2c3df | ||
|
|
4a5c7c1631 | ||
|
|
19ac362b3a | ||
|
|
41c6ad5318 | ||
|
|
9cf00a6de0 | ||
|
|
b36e2a472f | ||
|
|
276fead5c9 | ||
|
|
431d56ef14 | ||
|
|
793f07f6e2 | ||
|
|
194f9ddac0 | ||
|
|
203a357837 | ||
|
|
759f304478 | ||
|
|
dd3add9543 | ||
|
|
1549af7b6b | ||
|
|
649a06eac3 | ||
|
|
cddff8f4e4 | ||
|
|
d3ef04400f | ||
|
|
e65ad81b55 | ||
|
|
939272dc9d | ||
|
|
1dc8f62529 | ||
|
|
7870cf2249 | ||
|
|
b9889fb9e8 | ||
|
|
60c31720b3 | ||
|
|
2136340896 | ||
|
|
21fc00f2b3 | ||
|
|
4bcb0f5e13 | ||
|
|
bdc09ce94b | ||
|
|
34594aaee6 | ||
|
|
296a65aab7 | ||
|
|
69eaecef67 | ||
|
|
e03250c75b | ||
|
|
69061b049e | ||
|
|
ba98a8a728 | ||
|
|
0ca5a256a0 | ||
|
|
6b22f272bf | ||
|
|
237ad68f68 | ||
|
|
d5203e2f19 | ||
|
|
c0abaefe33 | ||
|
|
f93df0fae6 | ||
|
|
8955f2b8d9 | ||
|
|
257ae0eeed | ||
|
|
e9ae7cf78f | ||
|
|
c017486af7 | ||
|
|
c42a7488f9 | ||
|
|
64bef141e8 | ||
|
|
cc6e84e61c | ||
|
|
3fba152799 | ||
|
|
d0250c8656 | ||
|
|
c3801d48a4 | ||
|
|
0ede851085 | ||
|
|
46a421a656 | ||
|
|
170cd936bc | ||
|
|
d54721a7b4 | ||
|
|
73ef48bc22 | ||
|
|
6e1c5cd8af | ||
|
|
dc59c5a19b | ||
|
|
a15985e146 | ||
|
|
16e061326a | ||
|
|
44543a9a13 | ||
|
|
9b0aa05bdf | ||
|
|
19190f9d10 | ||
|
|
f8658097ab | ||
|
|
2265813f21 | ||
|
|
793d64a62c | ||
|
|
98b02afa22 | ||
|
|
08daec1df0 | ||
|
|
70aa6bfdb4 | ||
|
|
efe02ddfcb | ||
|
|
b7b09de812 | ||
|
|
64b2ddad3a | ||
|
|
1fdef6a8d3 | ||
|
|
df93ecaa42 | ||
|
|
853b4c8926 | ||
|
|
1aec5359ce | ||
|
|
2398de9940 | ||
|
|
8af9d6143c | ||
|
|
62a53cfdf4 | ||
|
|
b44e4e4972 | ||
|
|
713eb1158c | ||
|
|
1b3241424f | ||
|
|
74c2efaca3 | ||
|
|
2f4a3f52c4 | ||
|
|
e98014823b | ||
|
|
610a4fca92 | ||
|
|
b212bada44 | ||
|
|
db9c13f89d | ||
|
|
ea4a814e02 | ||
|
|
010839adbb | ||
|
|
9c1a1890fe | ||
|
|
c977e4cd51 | ||
|
|
74be8c1e08 | ||
|
|
81a0cf3827 | ||
|
|
ed4c5b85b9 |
@@ -11,6 +11,7 @@ pnpm-debug.log*
|
|||||||
lerna-debug.log*
|
lerna-debug.log*
|
||||||
|
|
||||||
ui/node_modules
|
ui/node_modules
|
||||||
|
# ui/src/utils/encryptUtils.ts
|
||||||
db
|
db
|
||||||
dist-ssr
|
dist-ssr
|
||||||
*.local
|
*.local
|
||||||
|
|||||||
@@ -2,13 +2,19 @@
|
|||||||
|
|
||||||
A ComfyUI workflow and model manager extension to **organize and manage all your workflows, models and generated images in one place**. Seamlessly switch between workflows, track version history and image generation history, 1 click install models from Civit ai, browse/update your installed models
|
A ComfyUI workflow and model manager extension to **organize and manage all your workflows, models and generated images in one place**. Seamlessly switch between workflows, track version history and image generation history, 1 click install models from Civit ai, browse/update your installed models
|
||||||
|
|
||||||
If you have questions or suggestions, please [join our Discord](https://discord.gg/HHvfEurv2Z)!
|
If you have questions or suggestions, please [join our Discord](https://discord.gg/HHvfEurv2Z)!
|
||||||
|
|
||||||
|
✨We have a new platform to turn your comfyui workflow to runnable web app: www.nodecafe.co please check it out! 🥳
|
||||||
|
|
||||||
|
[6-25] ⚠️ Please update workspace manager to latest version if it's not showing up for you after updating ComfyUI
|
||||||
|
|
||||||
|
[6-21] ‼️please upgrade to V2 and enable twoway sync if you haven't already. I will stop supporting V1 soon and will forcefully turn on twoway sync later. (twoway sync means that your workflow are twoway synced with your disk files /my_workflows directly)
|
||||||
|
|
||||||
|
[6-21] ‼️ Auto-save mode will be removed comopoletely from next version. Because there are reports that autosave mode sometimes overwrite workflows mistakenly. Therefore, please **manual save** your workflows always.
|
||||||
|
|
||||||
[New!] We provide 👭**team workspace** now! If you need to **share workflows, backup workflow versions for enterprise and teams**, please contact me about our team/enterprise product at weixuanfu01@gmail.com or join discord and DM me @briefpeach
|
[New!] We provide 👭**team workspace** now! If you need to **share workflows, backup workflow versions for enterprise and teams**, please contact me about our team/enterprise product at weixuanfu01@gmail.com or join discord and DM me @briefpeach
|
||||||
|
|
||||||
‼️ [3-23-2024]**search and install models from civitai is not working in previous versions**, because civitai changed something in their api. **Please update to the latest version** if you are seeing blank screen in Install Models dialog
|
[5-23-2024]**search and install models from civitai is not working in previous versions**, **Please update to the latest version** if you are seeing blank screen in Install Models dialog
|
||||||
|
|
||||||
[5-7-2024] Author (me) is job hunting in Beijing 🥲 so recently maybe too busy to update this plugin. I will come back to updating this plugin as soon as I finish job hunting 🥲🫠
|
|
||||||
|
|
||||||
<img width="610" alt="Screenshot 2024-03-08 at 6 41 18 PM" src="https://github.com/11cafe/comfyui-workspace-manager/assets/18367033/30455eb1-3d12-4930-bb81-28b33148fbaa">
|
<img width="610" alt="Screenshot 2024-03-08 at 6 41 18 PM" src="https://github.com/11cafe/comfyui-workspace-manager/assets/18367033/30455eb1-3d12-4930-bb81-28b33148fbaa">
|
||||||
|
|
||||||
@@ -26,7 +32,19 @@ Like any other custom node installation, in your ComfyUI root folder run command
|
|||||||
cd custom_nodes && git clone https://github.com/11cafe/comfyui-workspace-manager.git
|
cd custom_nodes && git clone https://github.com/11cafe/comfyui-workspace-manager.git
|
||||||
```
|
```
|
||||||
|
|
||||||
‼️ Be careful with Auto Save mode as it is constantly overwriting/saving your workflow, which can lead to unwanted overwriting of your precious work if not using carefully. If you disabled Auto Save, make sure you don't forget to Shift+S to save your workflows.
|
|
||||||
|
Please upgrade to V2 asap, you should see an **unicorn🦄** here instead of ☕️ (V1). I will stop supporting V1 soon.
|
||||||
|
|
||||||
|
<img width="136" alt="Screenshot 2024-05-31 at 5 39 58 PM" src="https://github.com/11cafe/comfyui-workspace-manager/assets/18367033/f52a83f2-4679-4a40-95ed-e75584516ec5">
|
||||||
|
|
||||||
|
Recommanded settings for V2 (Do not use these settings if you are on V1):
|
||||||
|
- Enable two way sync (‼️ Will stop supporting non-two-way sync mode starting next version)
|
||||||
|
- Make sure My Workspace Save Directory is valid path
|
||||||
|
|
||||||
|
<img width="202" alt="Screenshot 2024-05-30 at 6 34 39 PM" src="https://github.com/11cafe/comfyui-workspace-manager/assets/18367033/67020966-c190-48cb-bffc-b715449d5c99">
|
||||||
|
|
||||||
|
<img width="377" alt="335530039-10002a3f-ea2f-4bd1-8597-0ae1443d9851" src="https://github.com/11cafe/comfyui-workspace-manager/assets/18367033/6001a7f1-93f2-48ef-86c6-95c9560030ef">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
@@ -35,7 +53,7 @@ cd custom_nodes && git clone https://github.com/11cafe/comfyui-workspace-manager
|
|||||||
|
|
||||||
- 🔁Switch between different workflows easily. 1click open workflow in multiple browser tabs.
|
- 🔁Switch between different workflows easily. 1click open workflow in multiple browser tabs.
|
||||||
- 🤏**Drag and drop** to insert subworkflows into current flow.
|
- 🤏**Drag and drop** to insert subworkflows into current flow.
|
||||||
- 🗂️Organize workflows with folders, tags.
|
- 🗂️Organize workflows with folders (tags are deprecated, please use folders to organize)
|
||||||
- 📂Save and sync all your workflows in a local folder (by default under `/ComfyUI/my_workflows` customize in Settings)
|
- 📂Save and sync all your workflows in a local folder (by default under `/ComfyUI/my_workflows` customize in Settings)
|
||||||
- **Save workflow by pressing the 💾 button, or ⌨Shift+S shortcut** (customize in Settings).
|
- **Save workflow by pressing the 💾 button, or ⌨Shift+S shortcut** (customize in Settings).
|
||||||
- Every time you save, it will create a new record in **Version History**. You can easily revert to any version.
|
- Every time you save, it will create a new record in **Version History**. You can easily revert to any version.
|
||||||
@@ -62,13 +80,6 @@ Recommend using Chrome browser for the best experience. Safari doesn't work well
|
|||||||
[中文版教程](https://www.uisdc.com/workspace-manager) [Roadmap](https://github.com/orgs/11cafe/projects/1/views/1)
|
[中文版教程](https://www.uisdc.com/workspace-manager) [Roadmap](https://github.com/orgs/11cafe/projects/1/views/1)
|
||||||
|
|
||||||
## Updates
|
## Updates
|
||||||
**🦩v2.1 New gallery! Inspect image metadata, search image by prompt, model/lora used**
|
|
||||||
|
|
||||||
<img width="700" alt="Screenshot 2024-03-23 at 12 58 38 AM" src="https://github.com/11cafe/comfyui-workspace-manager/assets/18367033/5bac9793-7491-4131-b850-037094d03823">
|
|
||||||
|
|
||||||
Control+P quick spotlight search (like VSCode)
|
|
||||||
|
|
||||||
<img width="500" alt="Screenshot 2024-03-27 at 3 49 35 PM" src="https://github.com/11cafe/comfyui-workspace-manager/assets/18367033/47c14904-180c-4c52-a644-223d0936c9fa">
|
|
||||||
|
|
||||||
**🦄v2.0 Two-way sync with local folder, models manager support external models path like Automatic1111, cloud sync workflows**
|
**🦄v2.0 Two-way sync with local folder, models manager support external models path like Automatic1111, cloud sync workflows**
|
||||||
|
|
||||||
|
|||||||
+6
-36
@@ -11,8 +11,9 @@ import os
|
|||||||
import json
|
import json
|
||||||
from .service.media_service import *
|
from .service.media_service import *
|
||||||
from .service.file_sync_service import *
|
from .service.file_sync_service import *
|
||||||
from .service.db_service import get_my_workflows_dir
|
|
||||||
from .service.node_service import *
|
from .service.node_service import *
|
||||||
|
from .service.setting_service import *
|
||||||
|
from .service.model_manager.model_installer import *
|
||||||
try:
|
try:
|
||||||
from send2trash import send2trash
|
from send2trash import send2trash
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -21,9 +22,9 @@ except ImportError:
|
|||||||
WEB_DIRECTORY = "entry"
|
WEB_DIRECTORY = "entry"
|
||||||
NODE_CLASS_MAPPINGS = {}
|
NODE_CLASS_MAPPINGS = {}
|
||||||
__all__ = ['NODE_CLASS_MAPPINGS']
|
__all__ = ['NODE_CLASS_MAPPINGS']
|
||||||
version = "V1.0.0"
|
version = "V2.1.0"
|
||||||
|
|
||||||
print(f"### Loading: Workspace Manager ({version})")
|
print(f"🦄🦄Loading: Workspace Manager ({version})")
|
||||||
workspace_path = os.path.join(os.path.dirname(__file__))
|
workspace_path = os.path.join(os.path.dirname(__file__))
|
||||||
comfy_path = os.path.dirname(folder_paths.__file__)
|
comfy_path = os.path.dirname(folder_paths.__file__)
|
||||||
db_dir_path = os.path.join(workspace_path, "db")
|
db_dir_path = os.path.join(workspace_path, "db")
|
||||||
@@ -33,39 +34,8 @@ if os.path.exists(dist_path):
|
|||||||
server.PromptServer.instance.app.add_routes([
|
server.PromptServer.instance.app.add_routes([
|
||||||
web.static('/workspace_web/', dist_path),
|
web.static('/workspace_web/', dist_path),
|
||||||
])
|
])
|
||||||
|
else:
|
||||||
BACKUP_DIR = os.path.join(workspace_path, "backup")
|
print(f"🦄🦄🔴🔴Error: Web directory not found: {dist_path}")
|
||||||
MAX_BACKUP_FILES = 20
|
|
||||||
|
|
||||||
@server.PromptServer.instance.routes.post("/workspace/list_backup")
|
|
||||||
async def list_backup(request):
|
|
||||||
try:
|
|
||||||
data = await request.json()
|
|
||||||
dir_path = os.path.join(BACKUP_DIR, data.get('dir'))
|
|
||||||
# List all files in the directory
|
|
||||||
files = os.listdir(dir_path)
|
|
||||||
|
|
||||||
# Filter out .json files and sort them by filename (which starts with Unix timestamp)
|
|
||||||
json_files = sorted(
|
|
||||||
[file for file in files if file.endswith('.json')],
|
|
||||||
key=lambda x: x, # Assuming the format is 'timestamp_filename.json'
|
|
||||||
reverse=True
|
|
||||||
)
|
|
||||||
|
|
||||||
# Select the 10 most recent files
|
|
||||||
recent_json_files = json_files[:10]
|
|
||||||
|
|
||||||
# Read the contents of each JSON file
|
|
||||||
file_contents = []
|
|
||||||
for file in recent_json_files:
|
|
||||||
with open(os.path.join(dir_path, file), 'r') as f:
|
|
||||||
content = json.load(f)
|
|
||||||
file_contents.append({"fileName": file, "jsonStr": content})
|
|
||||||
|
|
||||||
return web.Response(text=json.dumps(file_contents), content_type='application/json')
|
|
||||||
except Exception as e:
|
|
||||||
return web.Response(text=json.dumps({"error": str(e)}), status=500)
|
|
||||||
|
|
||||||
|
|
||||||
@server.PromptServer.instance.routes.post("/workspace/get_system_dir")
|
@server.PromptServer.instance.routes.post("/workspace/get_system_dir")
|
||||||
async def get_system_dir(request):
|
async def get_system_dir(request):
|
||||||
|
|||||||
Vendored
+27
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
|||||||
|
import{r as l,N as n}from"./input.js";import{W as S,ag as w,w as d,E as p,ah as _,ai as C}from"./App-iAk7mY0h.js";import{u as D}from"./useDebounceFn-ld478fd0.js";function L(){const{isDirty:f,setIsDirty:h,setRoute:g,saveCurWorkflow:v,setCurFlowIDAndName:k}=l.useContext(S),m=l.useRef(f);l.useEffect(()=>{m.current=f},[f]),l.useEffect(()=>{const c=e=>{var s;if(document.visibilityState==="hidden")return;const t=C(e);if(t)switch(t===p.openSpotlightSearch&&e.preventDefault(),window.dispatchEvent(new CustomEvent(_,{detail:{shortcutType:t}})),t){case p.SAVE:v();break;case p.SAVE_AS:g("saveAsModal");break;case p.openSpotlightSearch:g("spotlightSearch");break}else(s=e.target)!=null&&s.matches("input, textarea")&&Object.keys(n.canvas.selected_nodes??{}).length&&E()},u=async()=>{var t,s,a,i;if(!((t=n)!=null&&t.graph)){console.error("🦄 Error in workspace manager! app.graph is not available in restoreCurWorkflow()");return}const e=(a=(s=n.graph.extra)==null?void 0:s[w])==null?void 0:a.id;if(console.log("🦄 Restoring workflow... id=",e),e){const r=await((i=d)==null?void 0:i.get(e));console.log("🦄 Restored workflow",(r==null?void 0:r.parentFolderID)+"/"+(r==null?void 0:r.name)),r&&k(r),!(r!=null&&r.saveLock)&&r&&r.json!==JSON.stringify(n.graph.serialize())&&h(!0)}},o=n.graph.onConfigure;return n.graph.onConfigure=function(){o==null||o.apply(this,arguments),setTimeout(()=>{var t,s,a,i;const e=(s=(t=n.graph.extra)==null?void 0:t[w])==null?void 0:s.id;(e==null||e!=((i=(a=d)==null?void 0:a.curWorkflow)==null?void 0:i.id))&&k(null)},500)},document.addEventListener("click",e=>{Object.keys(n.canvas.selected_nodes??{}).length&&(n.canvas.node_over!=null||n.canvas.node_capturing_input!=null||n.canvas.node_widget!=null)&&E()}),document.addEventListener("keydown",c),u(),()=>{document.removeEventListener("keydown",c)}},[]);const y=async()=>{var u,o,e,t;if((o=(u=d)==null?void 0:u.curWorkflow)!=null&&o.saveLock||m.current)return;const c=n.graph.serialize();JSON.stringify(c)!==((t=(e=d)==null?void 0:e.curWorkflow)==null?void 0:t.json)&&h(!0)},[E,b]=D(y,900);return null}export{L as default};
|
||||||
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
|||||||
|
import{d as a}from"./App-iAk7mY0h.js";var p=a("copy","IconCopy",[["path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z",key:"svg-0"}],["path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1",key:"svg-1"}]]);export{p as I};
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
import{d as a}from"./App-iAk7mY0h.js";var r=a("search","IconSearch",[["path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0",key:"svg-0"}],["path",{d:"M21 21l-6 -6",key:"svg-1"}]]);export{r as I};
|
||||||
+1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
|||||||
|
.dragPanelIcon{display:none!important}.workspaceManagerPanel:hover .dragPanelIcon{display:block!important}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
.drag-model-manager-top-bar-icon{visibility:hidden!important}.model-manager-top-bar:hover .drag-model-manager-top-bar-icon{visibility:visible!important}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
import{f as x,j as l,g as i,e as w,k as C,o as E,l as I,r as f,a5 as P}from"./input.js";import{ab as z}from"./App-iAk7mY0h.js";var v=x(function(o,s){const{children:t,placeholder:n,className:r,...a}=o;return l.jsxs(i.select,{...a,ref:s,className:w("chakra-select",r),children:[n&&l.jsx("option",{value:"",children:n}),t]})});v.displayName="SelectField";function F(e,o){const s={},t={};for(const[n,r]of Object.entries(e))o.includes(n)?s[n]=r:t[n]=r;return[s,t]}var H=x((e,o)=>{var s;const t=C("Select",e),{rootProps:n,placeholder:r,icon:a,color:c,height:_,h:d,minH:h,minHeight:y,iconColor:p,iconSize:u,...j}=E(e),[g,N]=F(j,P),m=z(N),k={width:"100%",height:"fit-content",position:"relative",color:c},b={paddingEnd:"2rem",...t.field,_focus:{zIndex:"unset",...(s=t.field)==null?void 0:s._focus}};return l.jsxs(i.div,{className:"chakra-select__wrapper",__css:k,...g,...n,children:[l.jsx(v,{ref:o,height:d??_,minH:h??y,placeholder:r,...m,__css:b,children:e.children}),l.jsx(S,{"data-disabled":I(m.disabled),...(p||c)&&{color:p||c},__css:t.icon,...u&&{fontSize:u},children:a})]})});H.displayName="Select";var M=e=>l.jsx("svg",{viewBox:"0 0 24 24",...e,children:l.jsx("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})}),R=i("div",{baseStyle:{position:"absolute",display:"inline-flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",top:"50%",transform:"translateY(-50%)"}}),S=e=>{const{children:o=l.jsx(M,{}),...s}=e,t=f.cloneElement(o,{role:"presentation",className:"chakra-select__icon",focusable:!1,"aria-hidden":!0,style:{width:"1em",height:"1em",color:"currentColor"}});return l.jsx(R,{...s,className:"chakra-select__icon-wrapper",children:f.isValidElement(o)?t:null})};S.displayName="SelectIcon";export{H as S};
|
||||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
|||||||
|
import{b as D,r as h,j as t,g as i,a2 as v,f as j,k as T,o as B,H as E,e as $}from"./input.js";import{u as z}from"./chunk-7D6N5TE5-8Zf7TGGG.js";var[Z,F]=D({name:"CheckboxGroupContext",strict:!1});function M(o){const[s,n]=h.useState(o),[e,r]=h.useState(!1);return o!==s&&(r(!0),n(o)),e}function W(o){return t.jsx(i.svg,{width:"1.2em",viewBox:"0 0 12 10",style:{fill:"none",strokeWidth:2,stroke:"currentColor",strokeDasharray:16},...o,children:t.jsx("polyline",{points:"1.5 6 4.5 9 10.5 1"})})}function X(o){return t.jsx(i.svg,{width:"1.2em",viewBox:"0 0 24 24",style:{stroke:"currentColor",strokeWidth:4},...o,children:t.jsx("line",{x1:"21",x2:"3",y1:"12",y2:"12"})})}function H(o){const{isIndeterminate:s,isChecked:n,...e}=o,r=s?X:W;return n||s?t.jsx(i.div,{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:t.jsx(r,{...e})}):null}var L={display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"top",userSelect:"none",flexShrink:0},O={cursor:"pointer",display:"inline-flex",alignItems:"center",verticalAlign:"top",position:"relative"},q=v({from:{opacity:0,strokeDashoffset:16,transform:"scale(0.95)"},to:{opacity:1,strokeDashoffset:0,transform:"scale(1)"}}),J=v({from:{opacity:0},to:{opacity:1}}),K=v({from:{transform:"scaleX(0.65)"},to:{transform:"scaleX(1)"}}),Q=j(function(s,n){const e=F(),r={...e,...s},a=T("Checkbox",r),c=B(s),{spacing:x="0.5rem",className:C,children:m,iconColor:u,iconSize:d,icon:k=t.jsx(H,{}),isChecked:f,isDisabled:g=e==null?void 0:e.isDisabled,onChange:p,inputProps:w,..._}=c;let y=f;e!=null&&e.value&&c.value&&(y=e.value.includes(c.value));let b=p;e!=null&&e.onChange&&c.value&&(b=E(e.onChange,p));const{state:l,getInputProps:A,getCheckboxProps:S,getLabelProps:G,getRootProps:P}=z({..._,isDisabled:g,isChecked:y,onChange:b}),I=M(l.isChecked),R=h.useMemo(()=>({animation:I?l.isIndeterminate?`${J} 20ms linear, ${K} 200ms linear`:`${q} 200ms linear`:void 0,fontSize:d,color:u,...a.icon}),[u,d,I,l.isIndeterminate,a.icon]),N=h.cloneElement(k,{__css:R,isIndeterminate:l.isIndeterminate,isChecked:l.isChecked});return t.jsxs(i.label,{__css:{...O,...a.container},className:$("chakra-checkbox",C),...P(),children:[t.jsx("input",{className:"chakra-checkbox__input",...A(w,n)}),t.jsx(i.span,{__css:{...L,...a.control},className:"chakra-checkbox__control",...S(),children:N}),m&&t.jsx(i.span,{className:"chakra-checkbox__label",...G(),__css:{marginStart:x,...a.label},children:m})]})});Q.displayName="Checkbox";var U=j(function(s,n){const{templateAreas:e,gap:r,rowGap:a,columnGap:c,column:x,row:C,autoFlow:m,autoRows:u,templateRows:d,autoColumns:k,templateColumns:f,...g}=s,p={display:"grid",gridTemplateAreas:e,gridGap:r,gridRowGap:a,gridColumnGap:c,gridAutoColumns:k,gridColumn:x,gridRow:C,gridAutoFlow:m,gridAutoRows:u,gridTemplateRows:d,gridTemplateColumns:f};return t.jsx(i.div,{ref:n,__css:p,...g})});U.displayName="Grid";export{Q as C,U as G};
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
import{f as t}from"./App-iAk7mY0h.js";import{f as o,j as s}from"./input.js";var e=o((a,r)=>s.jsx(t,{align:"center",...a,direction:"column",ref:r}));e.displayName="VStack";export{e as V};
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
import{f as l,n as f,o as h,j as e,g as n,e as m,k as y,r as o}from"./input.js";import{u as w}from"./chunk-7D6N5TE5-8Zf7TGGG.js";var N=l(function(a,i){const s=f("Link",a),{className:c,isExternal:t,...r}=h(a);return e.jsx(n.a,{target:t?"_blank":void 0,rel:t?"noopener":void 0,ref:i,className:m("chakra-link",c),...r,__css:s})});N.displayName="Link";var j=l(function(a,i){const s=y("Switch",a),{spacing:c="0.5rem",children:t,...r}=h(a),{getIndicatorProps:u,getInputProps:p,getCheckboxProps:x,getRootProps:_,getLabelProps:g}=w(r),b=o.useMemo(()=>({display:"inline-block",position:"relative",verticalAlign:"middle",lineHeight:0,...s.container}),[s.container]),S=o.useMemo(()=>({display:"inline-flex",flexShrink:0,justifyContent:"flex-start",boxSizing:"content-box",cursor:"pointer",...s.track}),[s.track]),d=o.useMemo(()=>({userSelect:"none",marginStart:c,...s.label}),[c,s.label]);return e.jsxs(n.label,{..._(),className:m("chakra-switch",a.className),__css:b,children:[e.jsx("input",{className:"chakra-switch__input",...p({},i)}),e.jsx(n.span,{...x(),className:"chakra-switch__track",__css:S,children:e.jsx(n.span,{__css:s.thumb,className:"chakra-switch__thumb",...u()})}),t&&e.jsx(n.span,{className:"chakra-switch__label",...g(),__css:d,children:t})]})});j.displayName="Switch";export{N as L,j as S};
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
import{h as m}from"./App-iAk7mY0h.js";const r="WORKSPACE_CIVIT_API_KEY_STORAGE_KEY";function h(){return localStorage.getItem(r)}function g(e){localStorage.setItem(r,e)}function v(e){return`https://civitai.com/api/download/models/${e}`}async function w(e){var s,a,n;try{const l=`https://civitai.com/api/v1/model-versions/by-hash/${e}`,t=await(await fetch(l)).json();let i;if(await((s=m)==null?void 0:s.getSetting("showNsfwModelThumbnail"))===!0)i=(n=(a=t==null?void 0:t.images)==null?void 0:a[0])==null?void 0:n.url;else if(!t.model.nsfw){const o=t.images.find(c=>c.nsfwLevel==1);i=o==null?void 0:o.url}return{modelName:t.model.name,civitModelID:String(t.modelId),civitModelVersionID:String(t.id),imageUrl:i??void 0}}catch{return{}}}export{v as a,w as f,h as g,g as s};
|
||||||
Vendored
+688
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
|||||||
|
import{r}from"./input.js";function a(u,c){const e=r.useRef(0),t=r.useCallback(()=>{e.current!==null&&(clearTimeout(e.current),e.current=0)},[]),n=r.useCallback((...o)=>{t(),e.current=setTimeout(()=>u(...o),c)},[u,c,t]);return r.useEffect(()=>()=>{t()},[]),[n,t]}export{a as u};
|
||||||
+5
-26
@@ -1,27 +1,6 @@
|
|||||||
const targetNode = document.body;
|
//@ts-ignore
|
||||||
|
import { api } from "../../scripts/api.js";
|
||||||
|
|
||||||
// Options for the observer (which mutations to observe)
|
setTimeout(() => {
|
||||||
const config = { childList: true, subtree: true };
|
import(api.api_base + "/workspace_web/input.js");
|
||||||
const api_base = window.location.pathname.split("/").slice(0, -1).join("/");
|
}, 500);
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
const callback = function (mutationsList, observer) {
|
|
||||||
for (const mutation of mutationsList) {
|
|
||||||
if (mutation.type === "childList") {
|
|
||||||
// @ts-ignore
|
|
||||||
mutation.addedNodes.forEach((node) => {
|
|
||||||
if (node.nodeName === "CANVAS") {
|
|
||||||
// @ts-ignore
|
|
||||||
import(api_base + "/workspace_web/input.js");
|
|
||||||
observer.disconnect();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create an instance of the MutationObserver
|
|
||||||
const observer = new MutationObserver(callback);
|
|
||||||
|
|
||||||
// Start observing the target node for configured mutations
|
|
||||||
observer.observe(targetNode, config);
|
|
||||||
|
|||||||
@@ -51,22 +51,3 @@ async def get_workspace(request):
|
|||||||
table = request.query.get('table')
|
table = request.query.get('table')
|
||||||
data = await asyncio.to_thread(read_table, table)
|
data = await asyncio.to_thread(read_table, table)
|
||||||
return web.json_response(data)
|
return web.json_response(data)
|
||||||
|
|
||||||
def get_my_workflows_dir():
|
|
||||||
data = read_table('userSettings')
|
|
||||||
if (data):
|
|
||||||
records = json.loads(data)
|
|
||||||
|
|
||||||
if DEFAULT_USER in records and 'myWorkflowsDir' in records[DEFAULT_USER]:
|
|
||||||
curDir = records[DEFAULT_USER]['myWorkflowsDir']
|
|
||||||
elif 'myWorkflowsDir' in records:
|
|
||||||
curDir = records['myWorkflowsDir']
|
|
||||||
|
|
||||||
# this is to be compatible of a bug that a dict is stored in userSettings.myWorkflowsDir
|
|
||||||
# should not be needed once all users refresh their settings
|
|
||||||
if not isinstance(curDir, str):
|
|
||||||
curDir = curDir.get('path', None)
|
|
||||||
|
|
||||||
if curDir and os.path.exists(curDir):
|
|
||||||
return curDir
|
|
||||||
return os.path.join(comfy_path, 'my_workflows')
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import folder_paths
|
import folder_paths
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import platform
|
|
||||||
import tempfile
|
|
||||||
import server
|
import server
|
||||||
import os
|
import os
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ from aiohttp import FormData, web, ClientSession
|
|||||||
import folder_paths
|
import folder_paths
|
||||||
import os
|
import os
|
||||||
from .model_manager.model_preview import get_thumbnail_for_image_file
|
from .model_manager.model_preview import get_thumbnail_for_image_file
|
||||||
|
from .setting_service import get_settings
|
||||||
|
|
||||||
image_extensions = ['.jpg', '.jpeg', '.png', '.gif', '.webp']
|
image_extensions = ['.jpg', '.jpeg', '.png', '.gif', '.webp']
|
||||||
video_extensions = ['.mp4', '.mov', '.avi', '.webm', '.mkv']
|
video_extensions = ['.mp4', '.mov', '.avi', '.webm', '.mkv']
|
||||||
API_URL = 'https://www.nodecafe.co/api/image/upload'
|
|
||||||
def view_media(filename, isPreview = False, isInput = False):
|
def view_media(filename, isPreview = False, isInput = False):
|
||||||
if not filename:
|
if not filename:
|
||||||
return web.Response(status=404)
|
return web.Response(status=404)
|
||||||
@@ -62,6 +63,9 @@ async def view_file(request):
|
|||||||
|
|
||||||
@server.PromptServer.instance.routes.post("/workspace/upload_image") # Handle POST requests
|
@server.PromptServer.instance.routes.post("/workspace/upload_image") # Handle POST requests
|
||||||
async def upload_image_handler(request):
|
async def upload_image_handler(request):
|
||||||
|
settings = get_settings()
|
||||||
|
cloudHost = settings.get("cloudHost", 'https://www.nodecafe.co')
|
||||||
|
API_URL = cloudHost + '/api/image/upload'
|
||||||
data = await request.json()
|
data = await request.json()
|
||||||
image_paths = data.get("images")
|
image_paths = data.get("images")
|
||||||
if not image_paths:
|
if not image_paths:
|
||||||
|
|||||||
@@ -8,7 +8,11 @@ import logging
|
|||||||
from threading import Lock
|
from threading import Lock
|
||||||
import server
|
import server
|
||||||
import uuid
|
import uuid
|
||||||
from .db_service import get_my_workflows_dir
|
from .setting_service import get_my_workflows_dir
|
||||||
|
|
||||||
|
@server.PromptServer.instance.routes.get('/workspace/get_os')
|
||||||
|
async def scan_my_workflows_files(request):
|
||||||
|
return web.Response(text= json.dumps({'os': platform.system()}), content_type='application/json')
|
||||||
|
|
||||||
@server.PromptServer.instance.routes.post('/workspace/file/scan_my_workflows_folder')
|
@server.PromptServer.instance.routes.post('/workspace/file/scan_my_workflows_folder')
|
||||||
async def scan_my_workflows_files(request):
|
async def scan_my_workflows_files(request):
|
||||||
@@ -34,6 +38,7 @@ def folder_handle(path, recursive, metaInfoOnly, fileList=None):
|
|||||||
createTime, updateTime = getFileCreateTime(item_path)
|
createTime, updateTime = getFileCreateTime(item_path)
|
||||||
fileList.append({
|
fileList.append({
|
||||||
'name': item,
|
'name': item,
|
||||||
|
'path': item_path,
|
||||||
'type': 'folder',
|
'type': 'folder',
|
||||||
'createTime': createTime,
|
'createTime': createTime,
|
||||||
'updateTime': updateTime
|
'updateTime': updateTime
|
||||||
@@ -52,6 +57,9 @@ def file_handle(name, fileList, file_path, metaInfoOnly):
|
|||||||
createTime, updateTime = getFileCreateTime(file_path)
|
createTime, updateTime = getFileCreateTime(file_path)
|
||||||
workspace_info = json_data.get('extra', {}).get('workspace_info', {})
|
workspace_info = json_data.get('extra', {}).get('workspace_info', {})
|
||||||
workflow_id = workspace_info.get('id', str(uuid.uuid4()))
|
workflow_id = workspace_info.get('id', str(uuid.uuid4()))
|
||||||
|
saveLock = workspace_info.get('saveLock', False)
|
||||||
|
cloudID = workspace_info.get('cloudID', None)
|
||||||
|
coverMediaPath = workspace_info.get('coverMediaPath', None)
|
||||||
# Update JSON data with new ID if needed and write back to file
|
# Update JSON data with new ID if needed and write back to file
|
||||||
if 'id' not in workspace_info:
|
if 'id' not in workspace_info:
|
||||||
if 'extra' not in json_data:
|
if 'extra' not in json_data:
|
||||||
@@ -66,6 +74,10 @@ def file_handle(name, fileList, file_path, metaInfoOnly):
|
|||||||
'name': name,
|
'name': name,
|
||||||
'type': "workflow",
|
'type': "workflow",
|
||||||
'id': workflow_id,
|
'id': workflow_id,
|
||||||
|
'path': file_path,
|
||||||
|
'saveLock': saveLock,
|
||||||
|
'cloudID': cloudID,
|
||||||
|
'coverMediaPath': coverMediaPath,
|
||||||
'createTime': createTime,
|
'createTime': createTime,
|
||||||
'updateTime': updateTime
|
'updateTime': updateTime
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
|
||||||
|
import server
|
||||||
|
import os
|
||||||
|
import folder_paths
|
||||||
|
import json
|
||||||
|
import asyncio
|
||||||
|
from aiohttp import web
|
||||||
|
from .db_service import DEFAULT_USER, read_table, db_dir_path
|
||||||
|
|
||||||
|
comfy_path = os.path.dirname(folder_paths.__file__)
|
||||||
|
|
||||||
|
@server.PromptServer.instance.routes.get("/workspace/get_settings")
|
||||||
|
def get_settings_endpoint(request):
|
||||||
|
settings = get_settings()
|
||||||
|
return web.json_response(text=json.dumps(settings), content_type='application/json')
|
||||||
|
|
||||||
|
def get_settings():
|
||||||
|
new_settings_path = os.path.join(db_dir_path, 'settings.json')
|
||||||
|
if os.path.exists(new_settings_path):
|
||||||
|
# to deprecate and remove legacy settings file
|
||||||
|
# if os.path.exists(f'{db_dir_path}/useSettings.json'):
|
||||||
|
# os.remove(f'{db_dir_path}/useSettings.json')
|
||||||
|
with open(new_settings_path, 'r') as file:
|
||||||
|
return json.load(file)
|
||||||
|
data = read_table('userSettings')
|
||||||
|
if (data):
|
||||||
|
records = json.loads(data)
|
||||||
|
if DEFAULT_USER in records and 'myWorkflowsDir' in records[DEFAULT_USER]:
|
||||||
|
return records[DEFAULT_USER]
|
||||||
|
return None
|
||||||
|
|
||||||
|
@server.PromptServer.instance.routes.post("/workspace/save_settings")
|
||||||
|
async def save_settings(request):
|
||||||
|
data = await request.json()
|
||||||
|
json_data = data
|
||||||
|
file_name = f'{db_dir_path}/settings.json'
|
||||||
|
# Offload file writing to a separate thread
|
||||||
|
def write_json_string_to_db(file_name, json_data):
|
||||||
|
if not os.path.exists(db_dir_path):
|
||||||
|
os.makedirs(db_dir_path)
|
||||||
|
# Write the JSON data to the specified file
|
||||||
|
with open(file_name, 'w') as file:
|
||||||
|
file.write(json.dumps(json_data, indent=4))
|
||||||
|
await asyncio.to_thread(write_json_string_to_db, file_name, json_data)
|
||||||
|
return web.Response(text=f"JSON saved to {file_name}")
|
||||||
|
|
||||||
|
def get_my_workflows_dir():
|
||||||
|
data = get_settings()
|
||||||
|
if (data):
|
||||||
|
if 'myWorkflowsDir' in data:
|
||||||
|
curDir = data['myWorkflowsDir']
|
||||||
|
|
||||||
|
# this is to be compatible of a bug that a dict is stored in userSettings.myWorkflowsDir
|
||||||
|
# should not be needed once all users refresh their settings
|
||||||
|
if not isinstance(curDir, str):
|
||||||
|
curDir = curDir.get('path', None)
|
||||||
|
|
||||||
|
if curDir and os.path.exists(curDir):
|
||||||
|
return curDir
|
||||||
|
return os.path.join(comfy_path, 'my_workflows')
|
||||||
@@ -4,7 +4,7 @@ from aiohttp import web
|
|||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import server
|
import server
|
||||||
from .db_service import get_my_workflows_dir
|
from .setting_service import get_my_workflows_dir
|
||||||
try:
|
try:
|
||||||
from send2trash import send2trash
|
from send2trash import send2trash
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|||||||
@@ -83,24 +83,6 @@ export async function deleteFile(file_path: string, deleteEmptyFolder = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function listBackup(dir: string) {
|
|
||||||
try {
|
|
||||||
const response = await fetchApi("/workspace/list_backup", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
dir: dir,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
const result = await response.text();
|
|
||||||
return result;
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error saving workspace:", error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getSystemDir(root?: string) {
|
export async function getSystemDir(root?: string) {
|
||||||
try {
|
try {
|
||||||
const response = await fetchApi("/workspace/get_system_dir", {
|
const response = await fetchApi("/workspace/get_system_dir", {
|
||||||
|
|||||||
+27
-36
@@ -25,18 +25,16 @@ const RecentFilesDrawer = React.lazy(
|
|||||||
);
|
);
|
||||||
const GalleryModal = React.lazy(() => import("./gallery/GalleryModal"));
|
const GalleryModal = React.lazy(() => import("./gallery/GalleryModal"));
|
||||||
import { IconExternalLink } from "@tabler/icons-react";
|
import { IconExternalLink } from "@tabler/icons-react";
|
||||||
import {
|
import { DRAWER_Z_INDEX, UPGRADE_TO_2WAY_SYNC_KEY } from "./const";
|
||||||
COMFYSPACE_TRACKING_FIELD_NAME,
|
|
||||||
DRAWER_Z_INDEX,
|
|
||||||
UPGRADE_TO_2WAY_SYNC_KEY,
|
|
||||||
} from "./const";
|
|
||||||
import ServerEventListener from "./model-manager/hooks/ServerEventListener";
|
import ServerEventListener from "./model-manager/hooks/ServerEventListener";
|
||||||
import { WorkspaceRoute } from "./types/types";
|
import { Session, WorkspaceRoute } from "./types/types";
|
||||||
import { useStateRef } from "./customHooks/useStateRef";
|
import { useStateRef } from "./customHooks/useStateRef";
|
||||||
import { indexdb } from "./db-tables/indexdb";
|
import { indexdb } from "./db-tables/indexdb";
|
||||||
import EnableTwowaySyncConfirm from "./settings/EnableTwowaySyncConfirm";
|
import EnableTwowaySyncConfirm from "./settings/EnableTwowaySyncConfirm";
|
||||||
import { api, app } from "./utils/comfyapp";
|
import { api, app } from "./utils/comfyapp";
|
||||||
import { fetchApi } from "./Api";
|
import { fetchApi } from "./Api";
|
||||||
|
import { serverInfo } from "./utils/OsPathUtils";
|
||||||
|
import { decodeKey } from "./utils/encryptUtils";
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const [curFlowName, setCurFlowName] = useState<string | null>(null);
|
const [curFlowName, setCurFlowName] = useState<string | null>(null);
|
||||||
@@ -44,7 +42,7 @@ export default function App() {
|
|||||||
const [loadingDB, setLoadingDB] = useState(true);
|
const [loadingDB, setLoadingDB] = useState(true);
|
||||||
const [flowID, setFlowID] = useState<string | null>(null);
|
const [flowID, setFlowID] = useState<string | null>(null);
|
||||||
const curFlowID = useRef<string | null>(null);
|
const curFlowID = useRef<string | null>(null);
|
||||||
|
const [session, setSession] = useState<Session | null>(null);
|
||||||
const [isDirty, setIsDirty] = useState(false);
|
const [isDirty, setIsDirty] = useState(false);
|
||||||
const workspaceContainerRef = useRef(null);
|
const workspaceContainerRef = useRef(null);
|
||||||
const { showDialog } = useDialog();
|
const { showDialog } = useDialog();
|
||||||
@@ -74,22 +72,11 @@ export default function App() {
|
|||||||
isAutoSave: false,
|
isAutoSave: false,
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
userSettingsTable?.settings?.autoSave &&
|
|
||||||
toast({
|
|
||||||
title: "Saved",
|
|
||||||
status: "success",
|
|
||||||
duration: 1000,
|
|
||||||
isClosable: true,
|
|
||||||
});
|
|
||||||
setIsDirty(false);
|
setIsDirty(false);
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const discardUnsavedChanges = async () => {
|
const discardUnsavedChanges = async () => {
|
||||||
if (userSettingsTable?.settings?.autoSave) {
|
|
||||||
alert("You cannot discard unsaved changes when auto save is enabled");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const userInput = confirm(
|
const userInput = confirm(
|
||||||
"Are you sure you want to discard unsaved changes? This will revert current workflow to your last saved version. You will lose all changes made since your last save.",
|
"Are you sure you want to discard unsaved changes? This will revert current workflow to your last saved version. You will lose all changes made since your last save.",
|
||||||
);
|
);
|
||||||
@@ -144,28 +131,22 @@ export default function App() {
|
|||||||
try {
|
try {
|
||||||
await loadDBs();
|
await loadDBs();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("error loading db", error);
|
console.error("🦄Workspace Manager - Error loading db", error);
|
||||||
}
|
}
|
||||||
setLoadingDB(false);
|
setLoadingDB(false);
|
||||||
|
|
||||||
const urlWorkflowID = getWorkflowIdInUrlHash();
|
const urlWorkflowID = getWorkflowIdInUrlHash();
|
||||||
if (urlWorkflowID == null) {
|
if (urlWorkflowID != null) {
|
||||||
const latestWf = localStorage.getItem("workflow");
|
|
||||||
if (latestWf) {
|
|
||||||
const workflow = JSON.parse(latestWf);
|
|
||||||
const id = workflow.extra?.[COMFYSPACE_TRACKING_FIELD_NAME]?.id;
|
|
||||||
if (id) {
|
|
||||||
const flow = await workflowsTable?.get(id);
|
|
||||||
flow && setCurFlowIDAndName(flow);
|
|
||||||
if (!flow?.saveLock && flow && flow.json != latestWf) {
|
|
||||||
setIsDirty(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
loadWorkflowIDImpl(urlWorkflowID);
|
loadWorkflowIDImpl(urlWorkflowID);
|
||||||
}
|
}
|
||||||
fetchApi("/workspace/deduplicate_workflow_ids");
|
fetchApi("/workspace/deduplicate_workflow_ids");
|
||||||
|
fetchApi("/workspace/get_os")
|
||||||
|
.then((resp) => resp.json())
|
||||||
|
.then((data) => {
|
||||||
|
if (data.os) {
|
||||||
|
serverInfo.os = data.os;
|
||||||
|
}
|
||||||
|
});
|
||||||
const twoway = await userSettingsTable?.getSetting("twoWaySync");
|
const twoway = await userSettingsTable?.getSetting("twoWaySync");
|
||||||
|
|
||||||
if (!twoway) {
|
if (!twoway) {
|
||||||
@@ -206,6 +187,15 @@ export default function App() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const encodedKey = localStorage.getItem("workspace_manager_shareKey");
|
||||||
|
if (encodedKey) {
|
||||||
|
const shareKey = decodeKey(encodedKey);
|
||||||
|
shareKey &&
|
||||||
|
setSession({
|
||||||
|
shareKey: shareKey,
|
||||||
|
username: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadWorkflowIDImpl = async (id: string, versionID?: string | null) => {
|
const loadWorkflowIDImpl = async (id: string, versionID?: string | null) => {
|
||||||
@@ -254,8 +244,8 @@ export default function App() {
|
|||||||
if (
|
if (
|
||||||
!isDirty ||
|
!isDirty ||
|
||||||
forceLoad ||
|
forceLoad ||
|
||||||
userSettingsTable?.settings?.autoSave ||
|
workflowsTable?.curWorkflow == null ||
|
||||||
workflowsTable?.curWorkflow == null
|
userSettingsTable?.settings?.disableUnsavedWarning
|
||||||
) {
|
) {
|
||||||
loadWorkflowIDImpl(id, versionID);
|
loadWorkflowIDImpl(id, versionID);
|
||||||
return;
|
return;
|
||||||
@@ -337,7 +327,6 @@ export default function App() {
|
|||||||
json: workflow.json,
|
json: workflow.json,
|
||||||
name: newFlowName || workflow.name,
|
name: newFlowName || workflow.name,
|
||||||
parentFolderID: workflow.parentFolderID,
|
parentFolderID: workflow.parentFolderID,
|
||||||
tags: workflow.tags,
|
|
||||||
});
|
});
|
||||||
flow && (await loadWorkflowID(flow.id));
|
flow && (await loadWorkflowID(flow.id));
|
||||||
};
|
};
|
||||||
@@ -419,6 +408,8 @@ export default function App() {
|
|||||||
curVersion: curVersion,
|
curVersion: curVersion,
|
||||||
setCurVersion: setCurVersion,
|
setCurVersion: setCurVersion,
|
||||||
setCurFlowIDAndName: setCurFlowIDAndName,
|
setCurFlowIDAndName: setCurFlowIDAndName,
|
||||||
|
session: session,
|
||||||
|
updateSession: setSession,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div ref={workspaceContainerRef} className="workspace_manager">
|
<div ref={workspaceContainerRef} className="workspace_manager">
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import FilesListFolderItemRightClickMenu from "./FilesListFolderItemRightClickMe
|
|||||||
import { ESortTypes, sortTypeLocalStorageKey } from "./types";
|
import { ESortTypes, sortTypeLocalStorageKey } from "./types";
|
||||||
import { Folder, Workflow } from "../types/dbTypes";
|
import { Folder, Workflow } from "../types/dbTypes";
|
||||||
import ItemsList from "./ItemsList";
|
import ItemsList from "./ItemsList";
|
||||||
|
import { getPathSep } from "../utils/OsPathUtils";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
folder: Folder;
|
folder: Folder;
|
||||||
@@ -82,8 +83,8 @@ export default memo(function FilesListFolderItem({ folder }: Props) {
|
|||||||
}, [isCollapsed]);
|
}, [isCollapsed]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const cur = workflowsTable?.curWorkflow;
|
const cur = workflowsTable?.curWorkflow;
|
||||||
const curWorkflowPath = cur?.parentFolderID + "/";
|
const curWorkflowPath = cur?.parentFolderID + getPathSep();
|
||||||
const folderPath = folder.id + "/";
|
const folderPath = folder.id + getPathSep();
|
||||||
const childreHasCurworkflow = curWorkflowPath.startsWith(folderPath);
|
const childreHasCurworkflow = curWorkflowPath.startsWith(folderPath);
|
||||||
if (childreHasCurworkflow) {
|
if (childreHasCurworkflow) {
|
||||||
setIsCollapsed(false);
|
setIsCollapsed(false);
|
||||||
|
|||||||
@@ -12,16 +12,21 @@ import {
|
|||||||
IconCopy,
|
IconCopy,
|
||||||
IconDotsVertical,
|
IconDotsVertical,
|
||||||
IconExternalLink,
|
IconExternalLink,
|
||||||
|
IconLink,
|
||||||
IconLock,
|
IconLock,
|
||||||
IconLockOpen,
|
IconLockOpen,
|
||||||
IconUpload,
|
IconUpload,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import AddTagToWorkflowPopover from "./AddTagToWorkflowPopover";
|
|
||||||
import { Workflow } from "../types/dbTypes";
|
import { Workflow } from "../types/dbTypes";
|
||||||
import { mediaTable, workflowsTable } from "../db-tables/WorkspaceDB";
|
import {
|
||||||
|
mediaTable,
|
||||||
|
userSettingsTable,
|
||||||
|
workflowsTable,
|
||||||
|
} from "../db-tables/WorkspaceDB";
|
||||||
import { WorkspaceContext } from "../WorkspaceContext";
|
import { WorkspaceContext } from "../WorkspaceContext";
|
||||||
import { openWorkflowInNewTab } from "../utils";
|
import { openWorkflowInNewTab } from "../utils";
|
||||||
import { fetchApi } from "../Api";
|
import { fetchApi } from "../Api";
|
||||||
|
import CopyShareLinkMenuItem from "../components/CopyShareLinkMenuItem";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
workflow: Workflow;
|
workflow: Workflow;
|
||||||
@@ -115,6 +120,7 @@ export default function MoreActionMenu({ workflow }: Props) {
|
|||||||
{isLocked ? "Unlock" : "Lock"}
|
{isLocked ? "Unlock" : "Lock"}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
<CopyShareLinkMenuItem curFlow={workflow} />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
icon={<IconUpload />}
|
icon={<IconUpload />}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
@@ -11,9 +11,7 @@ import {
|
|||||||
IconMoon,
|
IconMoon,
|
||||||
IconSettings,
|
IconSettings,
|
||||||
IconSun,
|
IconSun,
|
||||||
IconTag,
|
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import ManageTagsModal from "./ManageTagsModal";
|
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import WorkspaceSettingsModal from "./WorkspaceSettingsModal";
|
import WorkspaceSettingsModal from "./WorkspaceSettingsModal";
|
||||||
const ICON_SIZE = 16;
|
const ICON_SIZE = 16;
|
||||||
@@ -21,7 +19,6 @@ type Props = {
|
|||||||
// onclose: () => void;
|
// onclose: () => void;
|
||||||
};
|
};
|
||||||
export default function RecentFilesDrawerMenu({}: Props) {
|
export default function RecentFilesDrawerMenu({}: Props) {
|
||||||
const [isManageTagsOpen, setIsManageTagsOpen] = useState(false);
|
|
||||||
const [isSettingsOpen, setIsSettingsOpen] = useState(false);
|
const [isSettingsOpen, setIsSettingsOpen] = useState(false);
|
||||||
const { colorMode, toggleColorMode } = useColorMode();
|
const { colorMode, toggleColorMode } = useColorMode();
|
||||||
|
|
||||||
@@ -43,13 +40,6 @@ export default function RecentFilesDrawerMenu({}: Props) {
|
|||||||
>
|
>
|
||||||
Settings
|
Settings
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem
|
|
||||||
onClick={() => setIsManageTagsOpen(true)}
|
|
||||||
icon={<IconTag size={ICON_SIZE} />}
|
|
||||||
fontSize={16}
|
|
||||||
>
|
|
||||||
Manage Tags
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onClick={toggleColorMode}
|
onClick={toggleColorMode}
|
||||||
icon={
|
icon={
|
||||||
@@ -65,9 +55,6 @@ export default function RecentFilesDrawerMenu({}: Props) {
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
</MenuList>
|
</MenuList>
|
||||||
</Menu>
|
</Menu>
|
||||||
{isManageTagsOpen && (
|
|
||||||
<ManageTagsModal onclose={() => setIsManageTagsOpen(false)} />
|
|
||||||
)}
|
|
||||||
{isSettingsOpen && (
|
{isSettingsOpen && (
|
||||||
<WorkspaceSettingsModal onClose={() => setIsSettingsOpen(false)} />
|
<WorkspaceSettingsModal onClose={() => setIsSettingsOpen(false)} />
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -10,13 +10,12 @@ import {
|
|||||||
VStack,
|
VStack,
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { ShortcutSettings } from "../settings/ShortcutSettings";
|
import { ShortcutSettings } from "../settings/ShortcutSettings";
|
||||||
import FolderOnTopSettings from "../settings/FolderOnTopSettings";
|
|
||||||
import TwoWaySyncSettings from "../settings/TwoWaySyncSettings";
|
import TwoWaySyncSettings from "../settings/TwoWaySyncSettings";
|
||||||
import CommonCheckboxSettings from "../settings/CommonCheckboxSettings";
|
import CommonCheckboxSettings from "../settings/CommonCheckboxSettings";
|
||||||
import SelectMyWorkflowsDir from "../settings/SelectMyWorkflowsDir";
|
import SelectMyWorkflowsDir from "../settings/SelectMyWorkflowsDir";
|
||||||
import { CommonNumberSetting } from "../settings/CommonNumberSetting";
|
import { CommonNumberSetting } from "../settings/CommonNumberSetting";
|
||||||
import AutosaveSetting from "../settings/AutosaveSetting";
|
|
||||||
import CloudHostSetting from "../settings/CloudHostSetting";
|
import CloudHostSetting from "../settings/CloudHostSetting";
|
||||||
|
import SharekeySetting from "../settings/SharekeySetting";
|
||||||
|
|
||||||
export default function WorkspaceSettingsModal({
|
export default function WorkspaceSettingsModal({
|
||||||
onClose,
|
onClose,
|
||||||
@@ -39,13 +38,12 @@ export default function WorkspaceSettingsModal({
|
|||||||
w="100%"
|
w="100%"
|
||||||
>
|
>
|
||||||
<SelectMyWorkflowsDir />
|
<SelectMyWorkflowsDir />
|
||||||
<AutosaveSetting />
|
|
||||||
<ShortcutSettings />
|
<ShortcutSettings />
|
||||||
<TwoWaySyncSettings />
|
<TwoWaySyncSettings />
|
||||||
<FolderOnTopSettings />
|
<SharekeySetting />
|
||||||
<CommonCheckboxSettings
|
<CommonCheckboxSettings
|
||||||
settingKey="overwriteCurWorkflowWhenDroppingFileToCanvas"
|
settingKey="foldersOnTop"
|
||||||
text="Overwrite current workflow when drag and drop workflow file to canvas"
|
text={`Folders always on top`}
|
||||||
/>
|
/>
|
||||||
<CommonNumberSetting
|
<CommonNumberSetting
|
||||||
label={`Maximum number of save change history to store. This does not include
|
label={`Maximum number of save change history to store. This does not include
|
||||||
@@ -53,6 +51,11 @@ export default function WorkspaceSettingsModal({
|
|||||||
and has no limit.`}
|
and has no limit.`}
|
||||||
settingKey="maximumChangelogNumber"
|
settingKey="maximumChangelogNumber"
|
||||||
/>
|
/>
|
||||||
|
<CommonCheckboxSettings
|
||||||
|
settingKey="disableUnsavedWarning"
|
||||||
|
text={`Disable the "Save or Discard" warning when closing a workflow with unsaved changes. ⛔️Be careful, if you disable this reminder and forget to save your workflow, you will lose your changes.`}
|
||||||
|
/>
|
||||||
|
|
||||||
<CommonCheckboxSettings
|
<CommonCheckboxSettings
|
||||||
settingKey="hideCoverImage"
|
settingKey="hideCoverImage"
|
||||||
text="Hide thumbnail image in workflow list"
|
text="Hide thumbnail image in workflow list"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { createContext } from "react";
|
import { createContext } from "react";
|
||||||
import { Folder, Workflow, WorkflowVersion } from "./types/dbTypes";
|
import { Folder, Workflow, WorkflowVersion } from "./types/dbTypes";
|
||||||
import { WorkspaceRoute } from "./types/types";
|
import { Session, WorkspaceRoute } from "./types/types";
|
||||||
export type JsonDiff = {
|
export type JsonDiff = {
|
||||||
old: Object;
|
old: Object;
|
||||||
new: Object;
|
new: Object;
|
||||||
@@ -25,6 +25,8 @@ export const WorkspaceContext = createContext<{
|
|||||||
curVersion: WorkflowVersion | null;
|
curVersion: WorkflowVersion | null;
|
||||||
setCurVersion: (version: WorkflowVersion | null) => void;
|
setCurVersion: (version: WorkflowVersion | null) => void;
|
||||||
setCurFlowIDAndName: (workflow: Workflow | null) => void;
|
setCurFlowIDAndName: (workflow: Workflow | null) => void;
|
||||||
|
session: Session | null;
|
||||||
|
updateSession: (session: Session) => void;
|
||||||
}>({
|
}>({
|
||||||
curFlowID: null,
|
curFlowID: null,
|
||||||
loadWorkflowID: () => {},
|
loadWorkflowID: () => {},
|
||||||
@@ -39,6 +41,8 @@ export const WorkspaceContext = createContext<{
|
|||||||
setIsDirty: () => {},
|
setIsDirty: () => {},
|
||||||
setCurVersion: () => {},
|
setCurVersion: () => {},
|
||||||
setCurFlowIDAndName: () => {},
|
setCurFlowIDAndName: () => {},
|
||||||
|
session: null,
|
||||||
|
updateSession: () => {},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const RecentFilesContext = createContext<{
|
export const RecentFilesContext = createContext<{
|
||||||
|
|||||||
@@ -86,16 +86,6 @@ export namespace TwowaySyncAPI {
|
|||||||
console.error("Error deleting file:", error);
|
console.error("Error deleting file:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DuplicatesResponse {
|
|
||||||
duplicates: {
|
|
||||||
[id: string]: Array<{
|
|
||||||
path: string;
|
|
||||||
createTime: number;
|
|
||||||
}>;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function saveWorkflow(workflow: Workflow) {
|
export async function saveWorkflow(workflow: Workflow) {
|
||||||
const json = workflow.json;
|
const json = workflow.json;
|
||||||
const flow = JSON.parse(json);
|
const flow = JSON.parse(json);
|
||||||
@@ -103,6 +93,11 @@ export namespace TwowaySyncAPI {
|
|||||||
flow.extra[COMFYSPACE_TRACKING_FIELD_NAME] = {};
|
flow.extra[COMFYSPACE_TRACKING_FIELD_NAME] = {};
|
||||||
}
|
}
|
||||||
flow.extra[COMFYSPACE_TRACKING_FIELD_NAME].id = workflow.id;
|
flow.extra[COMFYSPACE_TRACKING_FIELD_NAME].id = workflow.id;
|
||||||
|
flow.extra[COMFYSPACE_TRACKING_FIELD_NAME].saveLock = workflow.saveLock;
|
||||||
|
flow.extra[COMFYSPACE_TRACKING_FIELD_NAME].cloudID = workflow.cloudID;
|
||||||
|
flow.extra[COMFYSPACE_TRACKING_FIELD_NAME].coverMediaPath =
|
||||||
|
workflow.coverMediaPath;
|
||||||
|
|
||||||
const response = await fetchApi("/workspace/file/save", {
|
const response = await fetchApi("/workspace/file/save", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -143,12 +138,8 @@ export namespace TwowaySyncAPI {
|
|||||||
console.error("Error deleting file:", error);
|
console.error("Error deleting file:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export async function createWorkflow({
|
export async function createWorkflow(workflow: Workflow) {
|
||||||
parentFolderID,
|
const { parentFolderID, name, json, id } = workflow;
|
||||||
name,
|
|
||||||
json,
|
|
||||||
id,
|
|
||||||
}: Workflow) {
|
|
||||||
let jsonObj: any = JSON.parse(json);
|
let jsonObj: any = JSON.parse(json);
|
||||||
if (jsonObj.extra == null) {
|
if (jsonObj.extra == null) {
|
||||||
jsonObj.extra = {};
|
jsonObj.extra = {};
|
||||||
@@ -157,6 +148,10 @@ export namespace TwowaySyncAPI {
|
|||||||
jsonObj.extra[COMFYSPACE_TRACKING_FIELD_NAME] = {};
|
jsonObj.extra[COMFYSPACE_TRACKING_FIELD_NAME] = {};
|
||||||
}
|
}
|
||||||
jsonObj.extra[COMFYSPACE_TRACKING_FIELD_NAME].id = id; // to avoid overwriting deps
|
jsonObj.extra[COMFYSPACE_TRACKING_FIELD_NAME].id = id; // to avoid overwriting deps
|
||||||
|
jsonObj.extra[COMFYSPACE_TRACKING_FIELD_NAME].saveLock = workflow.saveLock;
|
||||||
|
jsonObj.extra[COMFYSPACE_TRACKING_FIELD_NAME].cloudID = workflow.cloudID;
|
||||||
|
jsonObj.extra[COMFYSPACE_TRACKING_FIELD_NAME].coverMediaPath =
|
||||||
|
workflow.coverMediaPath;
|
||||||
const input: { parentFolderPath: string; name: string; json: string } = {
|
const input: { parentFolderPath: string; name: string; json: string } = {
|
||||||
parentFolderPath: sanitizeRelPath(parentFolderID ?? ""),
|
parentFolderPath: sanitizeRelPath(parentFolderID ?? ""),
|
||||||
name: name,
|
name: name,
|
||||||
@@ -196,7 +191,18 @@ export namespace TwowaySyncAPI {
|
|||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
}): Promise<{
|
}): Promise<{
|
||||||
json?: Object;
|
json?: {
|
||||||
|
extra: {
|
||||||
|
[COMFYSPACE_TRACKING_FIELD_NAME]: {
|
||||||
|
id: string;
|
||||||
|
saveLock: boolean;
|
||||||
|
cloudID: string | null;
|
||||||
|
coverMediaPath: string | null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
createTime?: number;
|
||||||
|
updateTime?: number;
|
||||||
error?: string;
|
error?: string;
|
||||||
}> {
|
}> {
|
||||||
const relPath = joinRelPath(parentFolderID ?? "", name + ".json");
|
const relPath = joinRelPath(parentFolderID ?? "", name + ".json");
|
||||||
@@ -235,7 +241,11 @@ export type ScanLocalFile = {
|
|||||||
type: "workflow";
|
type: "workflow";
|
||||||
name: string;
|
name: string;
|
||||||
id: string;
|
id: string;
|
||||||
|
path: string;
|
||||||
json: string;
|
json: string;
|
||||||
|
saveLock: boolean;
|
||||||
|
cloudID: string | null;
|
||||||
|
coverMediaPath: string | null;
|
||||||
createTime: number;
|
createTime: number;
|
||||||
updateTime: number;
|
updateTime: number;
|
||||||
lastOpenedTime?: number;
|
lastOpenedTime?: number;
|
||||||
@@ -244,6 +254,7 @@ export type ScanLocalFolder = {
|
|||||||
id: string;
|
id: string;
|
||||||
type: "folder";
|
type: "folder";
|
||||||
name: string;
|
name: string;
|
||||||
|
path: string;
|
||||||
parentFolderID: string;
|
parentFolderID: string;
|
||||||
};
|
};
|
||||||
export async function scanLocalFiles(
|
export async function scanLocalFiles(
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
import { COMFYSPACE_AUTH_REDIRECT_URL } from "../const";
|
|
||||||
|
|
||||||
const COGNITO_DOMAIN = import.meta.env.VITE_AWS_COGNITO_DOMAIN;
|
|
||||||
const CLIENT_ID = import.meta.env.VITE_AWS_COGNITO_CLIENT_ID;
|
|
||||||
const redirectUri = encodeURIComponent(COMFYSPACE_AUTH_REDIRECT_URL);
|
|
||||||
|
|
||||||
export function openCognitoPopup() {
|
|
||||||
const cognitoUrl = `${COGNITO_DOMAIN}/login`;
|
|
||||||
const responseType = "token";
|
|
||||||
|
|
||||||
const popupUrl = `${cognitoUrl}?response_type=${responseType}&client_id=${CLIENT_ID}&redirect_uri=${redirectUri}`;
|
|
||||||
const popupWindow = window.open(
|
|
||||||
popupUrl,
|
|
||||||
"ComfyspaceLogin",
|
|
||||||
"width=800,height=600",
|
|
||||||
);
|
|
||||||
|
|
||||||
popupWindow?.focus();
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import { HStack, MenuItem, Spinner, useToast } from "@chakra-ui/react";
|
||||||
|
import { IconLink } from "@tabler/icons-react";
|
||||||
|
import { useContext, useState } from "react";
|
||||||
|
import { WorkspaceContext } from "../WorkspaceContext";
|
||||||
|
import { copySharelink } from "./copySharelink";
|
||||||
|
import { Workflow } from "../types/dbTypes";
|
||||||
|
|
||||||
|
export default function CopyShareLinkMenuItem({
|
||||||
|
curFlow,
|
||||||
|
}: {
|
||||||
|
curFlow: Workflow;
|
||||||
|
}) {
|
||||||
|
const { session } = useContext(WorkspaceContext);
|
||||||
|
const toast = useToast();
|
||||||
|
const [loading, setloading] = useState(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<MenuItem
|
||||||
|
onClick={async () => {
|
||||||
|
if (!curFlow) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!session?.shareKey) {
|
||||||
|
alert(
|
||||||
|
"Please set your share key first in Settings to enable cloud share.",
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setloading(true);
|
||||||
|
const res = await copySharelink(session.shareKey, curFlow!);
|
||||||
|
if (res?.link) {
|
||||||
|
navigator.clipboard.writeText(res.link);
|
||||||
|
toast({
|
||||||
|
title: "Link copied",
|
||||||
|
status: "success",
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
toast({
|
||||||
|
title: "Failed to copy link",
|
||||||
|
status: "error",
|
||||||
|
description: res?.error,
|
||||||
|
duration: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
setloading(false);
|
||||||
|
}}
|
||||||
|
icon={loading ? <Spinner /> : <IconLink size={20} />}
|
||||||
|
iconSpacing={1}
|
||||||
|
alignItems={"center"}
|
||||||
|
isDisabled={loading}
|
||||||
|
>
|
||||||
|
<HStack>
|
||||||
|
<p>Copy share link</p>
|
||||||
|
</HStack>
|
||||||
|
</MenuItem>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Modal,
|
Modal,
|
||||||
ModalOverlay,
|
|
||||||
ModalContent,
|
ModalContent,
|
||||||
ModalHeader,
|
|
||||||
ModalCloseButton,
|
ModalCloseButton,
|
||||||
ModalBody,
|
ModalBody,
|
||||||
ModalFooter,
|
ModalFooter,
|
||||||
@@ -11,19 +9,30 @@ import {
|
|||||||
FormLabel,
|
FormLabel,
|
||||||
FormErrorMessage,
|
FormErrorMessage,
|
||||||
Input,
|
Input,
|
||||||
|
Stack,
|
||||||
|
useToast,
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { workflowVersionsTable } from "../db-tables/WorkspaceDB";
|
import { userSettingsTable, workflowsTable } from "../db-tables/WorkspaceDB";
|
||||||
import { useState, ChangeEvent } from "react";
|
import { useState, ChangeEvent, useContext } from "react";
|
||||||
|
import { WorkspaceContext } from "../WorkspaceContext";
|
||||||
|
import CreateVersionLogin from "../versionHistory/CreateVersionLogin";
|
||||||
|
import { ShareWorkflowData } from "../types/types";
|
||||||
import { app } from "../utils/comfyapp";
|
import { app } from "../utils/comfyapp";
|
||||||
|
import { EWorkflowPrivacy } from "../types/dbTypes";
|
||||||
|
import { getCurDateString, getNodeDefs } from "../share/shareUtils";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
workflowId: string;
|
workflowId: string;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
}
|
}
|
||||||
export default function CreateVersionDialog({ workflowId, onClose }: Props) {
|
export default function CreateVersionDialog({ onClose }: Props) {
|
||||||
const [newVersionName, setNewVersionName] = useState("");
|
const [newVersionName, setNewVersionName] = useState(
|
||||||
|
"v" + getCurDateString(),
|
||||||
|
);
|
||||||
const [submitError, setSubmitError] = useState("");
|
const [submitError, setSubmitError] = useState("");
|
||||||
|
const { session } = useContext(WorkspaceContext);
|
||||||
|
const toast = useToast();
|
||||||
|
const [submitting, setSubmitting] = useState(false);
|
||||||
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
||||||
setNewVersionName(event.target.value);
|
setNewVersionName(event.target.value);
|
||||||
submitError && setSubmitError("");
|
submitError && setSubmitError("");
|
||||||
@@ -32,31 +41,81 @@ export default function CreateVersionDialog({ workflowId, onClose }: Props) {
|
|||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
const trimName = newVersionName.trim();
|
const trimName = newVersionName.trim();
|
||||||
setNewVersionName(trimName);
|
setNewVersionName(trimName);
|
||||||
const versionList =
|
if (!workflowsTable?.curWorkflow) {
|
||||||
(await workflowVersionsTable?.listByWorkflowID(workflowId)) ?? [];
|
throw new Error("No workflow selected");
|
||||||
if (versionList.some((version) => version.name === trimName)) {
|
|
||||||
setSubmitError(
|
|
||||||
"The name is duplicated, please modify it and submit again.",
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
const graphJson = JSON.stringify(app.graph.serialize());
|
|
||||||
await workflowVersionsTable?.add({
|
|
||||||
name: newVersionName,
|
|
||||||
workflowID: workflowId,
|
|
||||||
createTime: Date.now(),
|
|
||||||
json: graphJson,
|
|
||||||
});
|
|
||||||
onClose();
|
|
||||||
}
|
}
|
||||||
|
setSubmitting(true);
|
||||||
|
const prompt = await app.graphToPrompt();
|
||||||
|
const graph = app.graph.serialize();
|
||||||
|
if (!graph.extra) {
|
||||||
|
graph.extra = {};
|
||||||
|
}
|
||||||
|
graph.extra.apiPrompt = prompt.output ?? null;
|
||||||
|
const input: ShareWorkflowData = {
|
||||||
|
workflow: {
|
||||||
|
name: workflowsTable?.curWorkflow?.name,
|
||||||
|
cloudID: workflowsTable?.curWorkflow?.cloudID,
|
||||||
|
},
|
||||||
|
version: {
|
||||||
|
name: trimName,
|
||||||
|
json: JSON.stringify(graph),
|
||||||
|
},
|
||||||
|
nodeDefs: getNodeDefs(),
|
||||||
|
privacy: EWorkflowPrivacy.PRIVATE,
|
||||||
|
};
|
||||||
|
const data = await fetch(
|
||||||
|
userSettingsTable?.settings?.cloudHost + "/api/createCloudflow",
|
||||||
|
{
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Authorization: `Bearer ${session?.shareKey}`,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(input),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.then((resp) => resp.json())
|
||||||
|
.then(async (data) => {
|
||||||
|
if (data?.data) {
|
||||||
|
const cloudID = data.data.workflowID;
|
||||||
|
await workflowsTable?.updateMetaInfo(
|
||||||
|
workflowsTable?.curWorkflow?.id!,
|
||||||
|
{
|
||||||
|
cloudID,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
toast({
|
||||||
|
title: "Version created",
|
||||||
|
status: "success",
|
||||||
|
duration: 3000,
|
||||||
|
});
|
||||||
|
onClose();
|
||||||
|
} else {
|
||||||
|
setSubmitError("Failed to create version. " + (data?.error ?? ""));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
setSubmitError("Failed to create version");
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
setSubmitting(false);
|
||||||
};
|
};
|
||||||
|
if (!session?.shareKey) {
|
||||||
|
return <CreateVersionLogin onClose={onClose} />;
|
||||||
|
}
|
||||||
|
const domain = new URL(userSettingsTable!.settings!.cloudHost).hostname;
|
||||||
return (
|
return (
|
||||||
<Modal isOpen={true} onClose={onClose}>
|
<Modal isOpen={true} onClose={onClose}>
|
||||||
<ModalOverlay />
|
|
||||||
<ModalContent>
|
<ModalContent>
|
||||||
<ModalHeader>Create Version</ModalHeader>
|
|
||||||
<ModalCloseButton />
|
<ModalCloseButton />
|
||||||
<ModalBody>
|
<ModalBody>
|
||||||
|
<Stack mb={5}>
|
||||||
|
<p style={{ fontSize: 20, fontWeight: "bold" }}>Create Version</p>
|
||||||
|
<p style={{ color: "GrayText" }}>
|
||||||
|
Saving to{" "}
|
||||||
|
<a href={userSettingsTable?.settings?.cloudHost}> {domain}</a>
|
||||||
|
</p>
|
||||||
|
</Stack>
|
||||||
<FormControl isInvalid={!!submitError}>
|
<FormControl isInvalid={!!submitError}>
|
||||||
<FormLabel>Name</FormLabel>
|
<FormLabel>Name</FormLabel>
|
||||||
<Input
|
<Input
|
||||||
@@ -78,7 +137,8 @@ export default function CreateVersionDialog({ workflowId, onClose }: Props) {
|
|||||||
colorScheme="teal"
|
colorScheme="teal"
|
||||||
mr={3}
|
mr={3}
|
||||||
onClick={onSubmit}
|
onClick={onSubmit}
|
||||||
isDisabled={!newVersionName || !!submitError}
|
isDisabled={!newVersionName}
|
||||||
|
isLoading={submitting}
|
||||||
>
|
>
|
||||||
Create
|
Create
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import {
|
|||||||
DarkMode,
|
DarkMode,
|
||||||
Tag,
|
Tag,
|
||||||
HStack,
|
HStack,
|
||||||
|
useToast,
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import {
|
import {
|
||||||
IconArrowBackUpDouble,
|
IconArrowBackUpDouble,
|
||||||
@@ -47,6 +48,7 @@ import { TOPBAR_BUTTON_HEIGHT } from "../const";
|
|||||||
import { downloadJsonFile } from "../utils/downloadJsonFile";
|
import { downloadJsonFile } from "../utils/downloadJsonFile";
|
||||||
import { SharedTopbarButton } from "../share/SharedTopbarButton";
|
import { SharedTopbarButton } from "../share/SharedTopbarButton";
|
||||||
import { app } from "../utils/comfyapp";
|
import { app } from "../utils/comfyapp";
|
||||||
|
import CopyShareLinkMenuItem from "./CopyShareLinkMenuItem";
|
||||||
|
|
||||||
export default function DropdownTitle() {
|
export default function DropdownTitle() {
|
||||||
const {
|
const {
|
||||||
@@ -56,6 +58,7 @@ export default function DropdownTitle() {
|
|||||||
saveCurWorkflow,
|
saveCurWorkflow,
|
||||||
setRoute,
|
setRoute,
|
||||||
route,
|
route,
|
||||||
|
session,
|
||||||
} = useContext(WorkspaceContext);
|
} = useContext(WorkspaceContext);
|
||||||
|
|
||||||
const [isOpenNewVersion, setIsOpenNewVersion] = useState(false);
|
const [isOpenNewVersion, setIsOpenNewVersion] = useState(false);
|
||||||
@@ -83,7 +86,7 @@ export default function DropdownTitle() {
|
|||||||
setNewFlowName(event.target.value);
|
setNewFlowName(event.target.value);
|
||||||
submitError && setSubmitError("");
|
submitError && setSubmitError("");
|
||||||
};
|
};
|
||||||
|
const toast = useToast();
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
if (!curFlowID) {
|
if (!curFlowID) {
|
||||||
alert("Flow ID is required");
|
alert("Flow ID is required");
|
||||||
@@ -145,17 +148,15 @@ export default function DropdownTitle() {
|
|||||||
>
|
>
|
||||||
Save
|
Save
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
{!userSettingsTable?.settings?.autoSave && (
|
<Tooltip label="Revert workflow to your last saved version. You will lose all changes made since your last save.">
|
||||||
<Tooltip label="Revert workflow to your last saved version. You will lose all changes made since your last save.">
|
<MenuItem
|
||||||
<MenuItem
|
onClick={discardUnsavedChanges}
|
||||||
onClick={discardUnsavedChanges}
|
icon={<IconArrowBackUpDouble size={20} />}
|
||||||
icon={<IconArrowBackUpDouble size={20} />}
|
iconSpacing={1}
|
||||||
iconSpacing={1}
|
>
|
||||||
>
|
Discard unsaved changes
|
||||||
Discard unsaved changes
|
</MenuItem>
|
||||||
</MenuItem>
|
</Tooltip>
|
||||||
</Tooltip>
|
|
||||||
)}
|
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onClick={handleDownload}
|
onClick={handleDownload}
|
||||||
icon={<IconDownload size={20} />}
|
icon={<IconDownload size={20} />}
|
||||||
@@ -196,6 +197,9 @@ export default function DropdownTitle() {
|
|||||||
<SharedTopbarButton />
|
<SharedTopbarButton />
|
||||||
</HStack>
|
</HStack>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
{workflowsTable?.curWorkflow && (
|
||||||
|
<CopyShareLinkMenuItem curFlow={workflowsTable?.curWorkflow} />
|
||||||
|
)}
|
||||||
</MenuList>
|
</MenuList>
|
||||||
</Menu>
|
</Menu>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,35 +52,5 @@ export default function MediaPreview({
|
|||||||
src={`/workspace/view_media?filename=${mediaLocalPath}`}
|
src={`/workspace/view_media?filename=${mediaLocalPath}`}
|
||||||
alt="workflow image renamed or moved from output folder"
|
alt="workflow image renamed or moved from output folder"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : null;
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
width: size + "px",
|
|
||||||
height: size + `px`,
|
|
||||||
overflow: "hidden",
|
|
||||||
position: "relative",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<video
|
|
||||||
width={size}
|
|
||||||
height={size}
|
|
||||||
src={`/workspace/view_media?filename=${mediaLocalPath}`}
|
|
||||||
loop={true}
|
|
||||||
autoPlay={autoPlay ?? false}
|
|
||||||
muted={true}
|
|
||||||
style={{
|
|
||||||
// for video to crop to center
|
|
||||||
objectFit: "cover",
|
|
||||||
width: "100%",
|
|
||||||
height: "100%",
|
|
||||||
// position: "absolute",
|
|
||||||
// top: "50%", // Align the center of the video with the center of the container vertically
|
|
||||||
// left: "50%", // Align the center of the video with the center of the container horizontally
|
|
||||||
// transform: "translate(-50%, -50%)", // Offset the video to ensure it is centered
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<track kind="captions" />
|
|
||||||
</video>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,25 +21,28 @@ import {
|
|||||||
import { IconX } from "@tabler/icons-react";
|
import { IconX } from "@tabler/icons-react";
|
||||||
import {
|
import {
|
||||||
changelogsTable,
|
changelogsTable,
|
||||||
|
userSettingsTable,
|
||||||
workflowsTable,
|
workflowsTable,
|
||||||
workflowVersionsTable,
|
workflowVersionsTable,
|
||||||
} from "../db-tables/WorkspaceDB";
|
} from "../db-tables/WorkspaceDB";
|
||||||
import { useContext, useEffect, useState } from "react";
|
import { useContext, useEffect, useState } from "react";
|
||||||
import { WorkspaceContext } from "../WorkspaceContext";
|
import { WorkspaceContext } from "../WorkspaceContext";
|
||||||
import { formatTimestamp } from "../utils";
|
|
||||||
import { Changelog, WorkflowVersion } from "../types/dbTypes";
|
import { Changelog, WorkflowVersion } from "../types/dbTypes";
|
||||||
import DeleteConfirm from "./DeleteConfirm";
|
import DeleteConfirm from "./DeleteConfirm";
|
||||||
import { app } from "../utils/comfyapp";
|
import { app } from "../utils/comfyapp";
|
||||||
|
|
||||||
export function VersionHistoryDrawer({ onClose }: { onClose: () => void }) {
|
export function VersionHistoryDrawer({ onClose }: { onClose: () => void }) {
|
||||||
const toast = useToast();
|
const { isDirty, loadWorkflowID, curVersion, session } =
|
||||||
const { curFlowID, isDirty, loadWorkflowID, curVersion } =
|
|
||||||
useContext(WorkspaceContext);
|
useContext(WorkspaceContext);
|
||||||
const [active, setActive] = useState(0); // 0: version、1: changelog
|
const [active, setActive] = useState(0); // 0: version、1: changelog
|
||||||
const [selectedVersion, setSelectedVersion] = useState<string | null>(null);
|
const [selectedVersion, setSelectedVersion] = useState<string | null>(null);
|
||||||
const [changelogs, setChangelogs] = useState<Changelog[]>([]);
|
const [changelogs, setChangelogs] = useState<Changelog[]>([]);
|
||||||
const [versions, setVersions] = useState<WorkflowVersion[]>([]);
|
const [versions, setVersions] = useState<
|
||||||
|
(WorkflowVersion & { isCloud?: boolean })[]
|
||||||
|
>([]);
|
||||||
|
const curFlow = workflowsTable?.curWorkflow;
|
||||||
|
const cloudHost = userSettingsTable?.settings?.cloudHost;
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
const loadChangeLogs = async (flowId: string) => {
|
const loadChangeLogs = async (flowId: string) => {
|
||||||
const workflow = await workflowsTable?.get(flowId);
|
const workflow = await workflowsTable?.get(flowId);
|
||||||
const changelogs = await changelogsTable?.listByWorkflowID(flowId);
|
const changelogs = await changelogsTable?.listByWorkflowID(flowId);
|
||||||
@@ -52,8 +55,38 @@ export function VersionHistoryDrawer({ onClose }: { onClose: () => void }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const loadVersions = async () => {
|
const loadVersions = async () => {
|
||||||
const vers =
|
let vers =
|
||||||
(await workflowVersionsTable?.listByWorkflowID(curFlowID!)) ?? [];
|
(await workflowVersionsTable?.listByWorkflowID(curFlow!.id)) ?? [];
|
||||||
|
if (session?.shareKey && curFlow?.cloudID) {
|
||||||
|
setLoading(true);
|
||||||
|
await fetch(
|
||||||
|
userSettingsTable?.settings?.cloudHost! +
|
||||||
|
"/api/listWorkflowVersionsByWorkflowID?workflowID=" +
|
||||||
|
curFlow?.cloudID,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
authorization: `Bearer ${session?.shareKey}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.then((resp) => resp.json())
|
||||||
|
.then((data) => {
|
||||||
|
if (data.items) {
|
||||||
|
const cloudVers = data.items.map((v: any) => {
|
||||||
|
return {
|
||||||
|
...v,
|
||||||
|
isCloud: true,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
vers = vers.concat(cloudVers as WorkflowVersion[]);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
console.error(e);
|
||||||
|
});
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
|
||||||
setVersions(vers);
|
setVersions(vers);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -69,7 +102,7 @@ export function VersionHistoryDrawer({ onClose }: { onClose: () => void }) {
|
|||||||
loadVersions();
|
loadVersions();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
loadChangeLogs(curFlowID!);
|
loadChangeLogs(curFlow!.id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}, [active]);
|
}, [active]);
|
||||||
@@ -116,7 +149,16 @@ export function VersionHistoryDrawer({ onClose }: { onClose: () => void }) {
|
|||||||
</TabList>
|
</TabList>
|
||||||
<TabPanels>
|
<TabPanels>
|
||||||
<TabPanel>
|
<TabPanel>
|
||||||
|
{session?.shareKey && (
|
||||||
|
<Text color="GrayText" mb={3}>
|
||||||
|
Connected to{" "}
|
||||||
|
<a href={cloudHost} target="_blank">
|
||||||
|
{cloudHost}
|
||||||
|
</a>
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
<Stack divider={<StackDivider />} spacing={2}>
|
<Stack divider={<StackDivider />} spacing={2}>
|
||||||
|
{loading && <Text>Loading...</Text>}
|
||||||
{versions?.map((version) => {
|
{versions?.map((version) => {
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
@@ -130,11 +172,27 @@ export function VersionHistoryDrawer({ onClose }: { onClose: () => void }) {
|
|||||||
borderRadius={4}
|
borderRadius={4}
|
||||||
>
|
>
|
||||||
<Stack textAlign={"left"} gap={0}>
|
<Stack textAlign={"left"} gap={0}>
|
||||||
<Text fontWeight={"500"}>
|
{version.isCloud ? (
|
||||||
{version.name ?? "untitled"}
|
<a
|
||||||
</Text>
|
target="_blank"
|
||||||
|
href={`${cloudHost}/workflow/${version.workflowID}/${version.id}`}
|
||||||
|
>
|
||||||
|
{version.name ?? "untitled"}
|
||||||
|
</a>
|
||||||
|
) : (
|
||||||
|
<Text fontWeight={"500"}>
|
||||||
|
{version.name ?? "untitled"}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
|
||||||
<Text color={"GrayText"} fontSize={"sm"}>
|
<Text color={"GrayText"} fontSize={"sm"}>
|
||||||
Created: {formatTimestamp(version.createTime)}
|
Created:{" "}
|
||||||
|
{new Date(
|
||||||
|
version.createTime ??
|
||||||
|
version.createdAt ??
|
||||||
|
version.created_at ??
|
||||||
|
"",
|
||||||
|
).toLocaleString()}
|
||||||
</Text>
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Flex alignItems="center" gap={2}>
|
<Flex alignItems="center" gap={2}>
|
||||||
@@ -148,18 +206,19 @@ export function VersionHistoryDrawer({ onClose }: { onClose: () => void }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
app.loadGraphData(JSON.parse(version.json));
|
app.loadGraphData(JSON.parse(version.json));
|
||||||
loadWorkflowID(curFlowID!, version.id);
|
|
||||||
onClose();
|
onClose();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Load
|
Load
|
||||||
</Button>
|
</Button>
|
||||||
<DeleteConfirm
|
{!version.isCloud && (
|
||||||
promptMessage="Are you sure you want to delete this version?"
|
<DeleteConfirm
|
||||||
onDelete={() => {
|
promptMessage="Are you sure you want to delete this version?"
|
||||||
onDelete(version.id);
|
onDelete={() => {
|
||||||
}}
|
onDelete(version.id);
|
||||||
/>
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
@@ -184,9 +243,6 @@ export function VersionHistoryDrawer({ onClose }: { onClose: () => void }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
app.loadGraphData(JSON.parse(c.json));
|
app.loadGraphData(JSON.parse(c.json));
|
||||||
workflowsTable?.updateFlow(curFlowID!, {
|
|
||||||
json: c.json,
|
|
||||||
});
|
|
||||||
onClose();
|
onClose();
|
||||||
}}
|
}}
|
||||||
isActive={c.id === selectedVersion}
|
isActive={c.id === selectedVersion}
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import { userSettingsTable, workflowsTable } from "../db-tables/WorkspaceDB";
|
||||||
|
import { getNodeDefs } from "../share/shareUtils";
|
||||||
|
import { EWorkflowPrivacy, Workflow } from "../types/dbTypes";
|
||||||
|
import { ShareWorkflowData } from "../types/types";
|
||||||
|
import { app } from "../utils/comfyapp";
|
||||||
|
|
||||||
|
export async function copySharelink(
|
||||||
|
shareKey: string,
|
||||||
|
curWorkflow: Workflow,
|
||||||
|
): Promise<{
|
||||||
|
link?: string | null;
|
||||||
|
error?: string | null;
|
||||||
|
} | null> {
|
||||||
|
if (curWorkflow.cloudID) {
|
||||||
|
const link =
|
||||||
|
userSettingsTable?.settings?.cloudHost +
|
||||||
|
"/workflow/" +
|
||||||
|
curWorkflow.cloudID;
|
||||||
|
return {
|
||||||
|
link,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const prompt = await app.graphToPrompt();
|
||||||
|
const graph = app.graph.serialize();
|
||||||
|
if (!graph.extra) {
|
||||||
|
graph.extra = {};
|
||||||
|
}
|
||||||
|
graph.extra.apiPrompt = prompt.output ?? null;
|
||||||
|
const input: ShareWorkflowData = {
|
||||||
|
workflow: {
|
||||||
|
name: curWorkflow?.name ?? "Untitled",
|
||||||
|
cloudID: curWorkflow?.cloudID,
|
||||||
|
},
|
||||||
|
version: {
|
||||||
|
name: "v1",
|
||||||
|
json: JSON.stringify(graph),
|
||||||
|
},
|
||||||
|
nodeDefs: getNodeDefs(),
|
||||||
|
privacy: EWorkflowPrivacy.UNLISTED,
|
||||||
|
};
|
||||||
|
return await fetch(
|
||||||
|
userSettingsTable?.settings?.cloudHost + "/api/createCloudflow",
|
||||||
|
{
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Authorization: `Bearer ${shareKey}`,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(input),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.then((resp) => resp.json())
|
||||||
|
.then((data) => {
|
||||||
|
if (data?.data) {
|
||||||
|
const cloudID = data.data.workflowID;
|
||||||
|
workflowsTable?.updateMetaInfo(curWorkflow?.id!, {
|
||||||
|
cloudID,
|
||||||
|
});
|
||||||
|
|
||||||
|
const link =
|
||||||
|
userSettingsTable?.settings?.cloudHost + "/workflow/" + cloudID;
|
||||||
|
return {
|
||||||
|
link,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
error: "Failed to create version. " + (data?.error ?? ""),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
return {
|
||||||
|
error: "Failed to create version. " + (e?.error ?? ""),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -35,8 +35,6 @@ export class MediaTable extends TableBase<Media> {
|
|||||||
});
|
});
|
||||||
// save indexdb
|
// save indexdb
|
||||||
indexdb.media.put(md);
|
indexdb.media.put(md);
|
||||||
// save disk file db
|
|
||||||
this.saveDiskDB();
|
|
||||||
return md;
|
return md;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ export class TableBase<T extends TableBaseModel> {
|
|||||||
this.tableName = tableName;
|
this.tableName = tableName;
|
||||||
}
|
}
|
||||||
protected async saveDiskDB() {
|
protected async saveDiskDB() {
|
||||||
|
// diable save diskdb
|
||||||
|
return;
|
||||||
const objs = (await indexdb[this.tableName].toArray()) as TableBaseModel[];
|
const objs = (await indexdb[this.tableName].toArray()) as TableBaseModel[];
|
||||||
const backup: Record<string, TableBaseModel> = {};
|
const backup: Record<string, TableBaseModel> = {};
|
||||||
objs.forEach((f) => {
|
objs.forEach((f) => {
|
||||||
@@ -43,23 +45,19 @@ export class TableBase<T extends TableBaseModel> {
|
|||||||
newItem.createTime = Date.now();
|
newItem.createTime = Date.now();
|
||||||
}
|
}
|
||||||
await indexdb[this.tableName].add(newItem as any);
|
await indexdb[this.tableName].add(newItem as any);
|
||||||
await this.saveDiskDB();
|
|
||||||
return newItem as T;
|
return newItem as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async put(newItem: T): Promise<T> {
|
public async put(newItem: T): Promise<T> {
|
||||||
await indexdb[this.tableName].put(newItem as any);
|
await indexdb[this.tableName].put(newItem as any);
|
||||||
await this.saveDiskDB();
|
|
||||||
return newItem;
|
return newItem;
|
||||||
}
|
}
|
||||||
public async bulkPut(newItems: T[]): Promise<void> {
|
public async bulkPut(newItems: T[]): Promise<void> {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
await indexdb[this.tableName].bulkPut(newItems as any);
|
await indexdb[this.tableName].bulkPut(newItems as any);
|
||||||
this.saveDiskDB();
|
|
||||||
}
|
}
|
||||||
public async update(id: string, changes: Partial<T>): Promise<T | null> {
|
public async update(id: string, changes: Partial<T>): Promise<T | null> {
|
||||||
await indexdb[this.tableName].update(id, changes);
|
await indexdb[this.tableName].update(id, changes);
|
||||||
this.saveDiskDB();
|
|
||||||
return (await this.get(id)) ?? null;
|
return (await this.get(id)) ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +104,6 @@ export class TableBase<T extends TableBaseModel> {
|
|||||||
|
|
||||||
public async delete(id: string) {
|
public async delete(id: string) {
|
||||||
await indexdb[this.tableName].delete(id);
|
await indexdb[this.tableName].delete(id);
|
||||||
this.saveDiskDB();
|
|
||||||
}
|
}
|
||||||
public async listByIndex(index: keyof T, value: string): Promise<T[]> {
|
public async listByIndex(index: keyof T, value: string): Promise<T[]> {
|
||||||
const list = await indexdb[this.tableName]
|
const list = await indexdb[this.tableName]
|
||||||
|
|||||||
@@ -1,29 +1,19 @@
|
|||||||
import type { UserSettings } from "../types/dbTypes";
|
import type { UserSettings } from "../types/dbTypes";
|
||||||
import { TableBase } from "./TableBase";
|
import { TableBase } from "./TableBase";
|
||||||
import { MODEL_TYPE_TO_FOLDER_MAPPING } from "../model-manager/install-models/util/modelTypes";
|
import { MODEL_TYPE_TO_FOLDER_MAPPING } from "../model-manager/install-models/util/modelTypes";
|
||||||
import { fetchMyWorkflowsDir } from "../Api";
|
import { fetchApi, fetchMyWorkflowsDir } from "../Api";
|
||||||
|
|
||||||
export class UserSettingsTable extends TableBase<UserSettings> {
|
export class UserSettingsTable extends TableBase<UserSettings> {
|
||||||
public defaultSettings: UserSettings;
|
public defaultSettings: UserSettings;
|
||||||
public readonly DEFAULT_USER = "guest";
|
public readonly DEFAULT_USER = "guest";
|
||||||
static readonly TABLE_NAME = "userSettings";
|
static readonly TABLE_NAME = "userSettings";
|
||||||
|
|
||||||
/**
|
|
||||||
* Because in App.js we will use window.addEventListener("beforeunload", handleBeforeUnload); to remind the user to save the workflow when the user leaves the page.
|
|
||||||
* The autoSave needs to be obtained in the handleBeforeUnload function. If it is obtained through getSetting, the handleBeforeUnload function will become an async function, which will cause the "beforeunload" event to fail.
|
|
||||||
* So we maintain an autoSave here that is always up to date.
|
|
||||||
*/
|
|
||||||
private _autoSave: boolean = false;
|
|
||||||
private _settings: UserSettings | undefined = undefined;
|
private _settings: UserSettings | undefined = undefined;
|
||||||
|
|
||||||
get settings() {
|
get settings() {
|
||||||
return this._settings;
|
return this._settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
get autoSave() {
|
|
||||||
return this._autoSave;
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("userSettings");
|
super("userSettings");
|
||||||
this.defaultSettings = {
|
this.defaultSettings = {
|
||||||
@@ -44,7 +34,6 @@ export class UserSettingsTable extends TableBase<UserSettings> {
|
|||||||
twoWaySync: false,
|
twoWaySync: false,
|
||||||
foldersOnTop: false,
|
foldersOnTop: false,
|
||||||
cloudHost: "https://www.nodecafe.co",
|
cloudHost: "https://www.nodecafe.co",
|
||||||
overwriteCurWorkflowWhenDroppingFileToCanvas: false,
|
|
||||||
maximumChangelogNumber: 80,
|
maximumChangelogNumber: 80,
|
||||||
hideCoverImage: false,
|
hideCoverImage: false,
|
||||||
disableUnsavedWarning: false,
|
disableUnsavedWarning: false,
|
||||||
@@ -65,6 +54,14 @@ export class UserSettingsTable extends TableBase<UserSettings> {
|
|||||||
}
|
}
|
||||||
return currentUserSettings?.[key] ?? this.defaultSettings[key];
|
return currentUserSettings?.[key] ?? this.defaultSettings[key];
|
||||||
}
|
}
|
||||||
|
public async get(_id: string): Promise<UserSettings | undefined> {
|
||||||
|
const obj = await fetchApi("/workspace/get_settings", {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
}).then((res) => res.json());
|
||||||
|
return obj as any;
|
||||||
|
}
|
||||||
|
|
||||||
public async upsert(newPairs: Partial<UserSettings>) {
|
public async upsert(newPairs: Partial<UserSettings>) {
|
||||||
const oldSettings =
|
const oldSettings =
|
||||||
@@ -73,7 +70,13 @@ export class UserSettingsTable extends TableBase<UserSettings> {
|
|||||||
...oldSettings,
|
...oldSettings,
|
||||||
...newPairs,
|
...newPairs,
|
||||||
};
|
};
|
||||||
await this.put(newSettings);
|
await fetchApi("/workspace/save_settings", {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify(newSettings),
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
});
|
||||||
this._settings = {
|
this._settings = {
|
||||||
...this.defaultSettings,
|
...this.defaultSettings,
|
||||||
...newSettings,
|
...newSettings,
|
||||||
@@ -87,13 +90,15 @@ export class UserSettingsTable extends TableBase<UserSettings> {
|
|||||||
instance.defaultSettings.myWorkflowsDir = myWorkflowsDir.path!;
|
instance.defaultSettings.myWorkflowsDir = myWorkflowsDir.path!;
|
||||||
|
|
||||||
await instance.get(instance.DEFAULT_USER).then((res) => {
|
await instance.get(instance.DEFAULT_USER).then((res) => {
|
||||||
instance._autoSave = res?.autoSave ?? false;
|
|
||||||
instance._settings = {
|
instance._settings = {
|
||||||
...instance.defaultSettings,
|
...instance.defaultSettings,
|
||||||
...res,
|
...res,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
if (instance.defaultSettings.cloudHost.includes("comfyspace.art")) {
|
if (
|
||||||
|
instance._settings?.cloudHost?.includes("nodecafe.org") ||
|
||||||
|
instance._settings?.cloudHost?.includes("comfyspace.art")
|
||||||
|
) {
|
||||||
// overwrite legacy comfyspace.art
|
// overwrite legacy comfyspace.art
|
||||||
await instance.upsert({
|
await instance.upsert({
|
||||||
cloudHost: instance.defaultSettings.cloudHost,
|
cloudHost: instance.defaultSettings.cloudHost,
|
||||||
|
|||||||
@@ -131,8 +131,6 @@ export class WorkflowsTable extends TableBase<Workflow> {
|
|||||||
};
|
};
|
||||||
//add to IndexDB
|
//add to IndexDB
|
||||||
await indexdb.workflows.add(newWorkflow);
|
await indexdb.workflows.add(newWorkflow);
|
||||||
// add to disk file db
|
|
||||||
this.saveDiskDB();
|
|
||||||
// add to my_workflows/
|
// add to my_workflows/
|
||||||
const twoWaySyncEnabled = await userSettingsTable?.getSetting("twoWaySync");
|
const twoWaySyncEnabled = await userSettingsTable?.getSetting("twoWaySync");
|
||||||
if (twoWaySyncEnabled) {
|
if (twoWaySyncEnabled) {
|
||||||
@@ -174,7 +172,6 @@ export class WorkflowsTable extends TableBase<Workflow> {
|
|||||||
if (this._curWorkflow && this._curWorkflow.id === id) {
|
if (this._curWorkflow && this._curWorkflow.id === id) {
|
||||||
this._curWorkflow = newWorkflow;
|
this._curWorkflow = newWorkflow;
|
||||||
}
|
}
|
||||||
this.saveDiskDB();
|
|
||||||
return newWorkflow;
|
return newWorkflow;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,7 +274,6 @@ export class WorkflowsTable extends TableBase<Workflow> {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await indexdb.workflows.bulkAdd(newWorkflows);
|
await indexdb.workflows.bulkAdd(newWorkflows);
|
||||||
this.saveDiskDB();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("batchCreateFlows error", e);
|
console.error("batchCreateFlows error", e);
|
||||||
}
|
}
|
||||||
@@ -295,7 +291,6 @@ export class WorkflowsTable extends TableBase<Workflow> {
|
|||||||
}
|
}
|
||||||
//add to IndexDB
|
//add to IndexDB
|
||||||
await indexdb.workflows.delete(id);
|
await indexdb.workflows.delete(id);
|
||||||
this.saveDiskDB();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async batchDeleteFlow(ids: string[]) {
|
public async batchDeleteFlow(ids: string[]) {
|
||||||
@@ -309,7 +304,6 @@ export class WorkflowsTable extends TableBase<Workflow> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
await indexdb.workflows.bulkDelete(ids);
|
await indexdb.workflows.bulkDelete(ids);
|
||||||
this.saveDiskDB();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async listFolderContent(
|
public async listFolderContent(
|
||||||
|
|||||||
@@ -61,86 +61,4 @@ export async function loadDBs() {
|
|||||||
loadMedia(),
|
loadMedia(),
|
||||||
loadWorkflowVersions(),
|
loadWorkflowVersions(),
|
||||||
]);
|
]);
|
||||||
if (localStorage.getItem("WORKSPACE_INDEXDB_BACKFILL") !== "true") {
|
|
||||||
await backfillIndexdb();
|
|
||||||
localStorage.setItem("WORKSPACE_INDEXDB_BACKFILL", "true");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function backfillIndexdb() {
|
|
||||||
const backfillWorkflows = async () => {
|
|
||||||
try {
|
|
||||||
const all = await workflowsTable?.getRecords();
|
|
||||||
all && (await indexdb.workflows.bulkPut(Object.values(all)));
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const backfillFolders = async () => {
|
|
||||||
try {
|
|
||||||
const all = await foldersTable?.getRecords();
|
|
||||||
all && (await indexdb.folders.bulkPut(Object.values(all)));
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const backfillMedia = async () => {
|
|
||||||
try {
|
|
||||||
const all = await mediaTable?.getRecords();
|
|
||||||
all && (await indexdb.media.bulkPut(Object.values(all)));
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const backfillChangelogs = async () => {
|
|
||||||
try {
|
|
||||||
const all = await changelogsTable?.getRecords();
|
|
||||||
all && (await indexdb.changelogs.bulkPut(Object.values(all)));
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const backfillTags = async () => {
|
|
||||||
try {
|
|
||||||
const all = await tagsTable?.getRecords();
|
|
||||||
all && (await indexdb.tags.bulkPut(Object.values(all)));
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const backfillUserSettings = async () => {
|
|
||||||
try {
|
|
||||||
const tableInstance = userSettingsTable!;
|
|
||||||
const backupData = await tableInstance.getRecords().then((data) => {
|
|
||||||
if (!data[tableInstance.DEFAULT_USER]) {
|
|
||||||
// legacy
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
return data[tableInstance.DEFAULT_USER];
|
|
||||||
});
|
|
||||||
await indexdb.userSettings.put({
|
|
||||||
...tableInstance.defaultSettings,
|
|
||||||
...backupData,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const backfillWorkflowVersions = async () => {
|
|
||||||
try {
|
|
||||||
const all = await workflowVersionsTable?.getRecords();
|
|
||||||
all && (await indexdb.workflowVersions.bulkPut(Object.values(all)));
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
await Promise.all([
|
|
||||||
backfillWorkflows(),
|
|
||||||
backfillFolders(),
|
|
||||||
backfillMedia(),
|
|
||||||
backfillChangelogs(),
|
|
||||||
backfillTags(),
|
|
||||||
backfillUserSettings(),
|
|
||||||
backfillWorkflowVersions(),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { FC } from "react";
|
import { FC } from "react";
|
||||||
import { Flex, Select } from "@chakra-ui/react";
|
import { Flex, Select } from "@chakra-ui/react";
|
||||||
import { FormItem } from "./types.ts";
|
|
||||||
import { PromptNodeInputItem } from "../MetaBox/utils.ts";
|
import { PromptNodeInputItem } from "../MetaBox/utils.ts";
|
||||||
|
|
||||||
export const SelectBase: FC<
|
export const SelectBase: FC<
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { MetaData, getMetadataFromUrl } from "../../utils.ts";
|
import { getMetadataFromUrl } from "../../utils.ts";
|
||||||
import { Flex, HStack, Switch } from "@chakra-ui/react";
|
import { Flex, HStack, Switch } from "@chakra-ui/react";
|
||||||
import { Media } from "../../../types/dbTypes.ts";
|
import { Media } from "../../../types/dbTypes.ts";
|
||||||
import TopForm from "../TopForm/TopForm.tsx";
|
import TopForm from "../TopForm/TopForm.tsx";
|
||||||
import AllPromptForm from "../AllPromptForm/AllPromptForm.tsx";
|
import AllPromptForm from "../AllPromptForm/AllPromptForm.tsx";
|
||||||
import { useContext, useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { FormItem } from "../FormItem/types.ts";
|
import { FormItem } from "../FormItem/types.ts";
|
||||||
import {
|
import {
|
||||||
calcInputListRecursive,
|
calcInputListRecursive,
|
||||||
@@ -11,8 +11,6 @@ import {
|
|||||||
PromptNodeInputItem,
|
PromptNodeInputItem,
|
||||||
} from "./utils.ts";
|
} from "./utils.ts";
|
||||||
import { MetaBoxContext } from "./metaBoxContext.ts";
|
import { MetaBoxContext } from "./metaBoxContext.ts";
|
||||||
import { workflowsTable } from "../../../db-tables/WorkspaceDB.ts";
|
|
||||||
import { WorkspaceContext } from "../../../WorkspaceContext.ts";
|
|
||||||
import { app } from "../../../utils/comfyapp.ts";
|
import { app } from "../../../utils/comfyapp.ts";
|
||||||
export type TopFieldType = {
|
export type TopFieldType = {
|
||||||
promptKey: string | number;
|
promptKey: string | number;
|
||||||
@@ -34,7 +32,6 @@ export const isInTopField = (
|
|||||||
|
|
||||||
export default function MetadataForm({ media }: { media: Media | null }) {
|
export default function MetadataForm({ media }: { media: Media | null }) {
|
||||||
const [calcInputList, setCalcInputList] = useState<PromptNodeInputItem[]>([]);
|
const [calcInputList, setCalcInputList] = useState<PromptNodeInputItem[]>([]);
|
||||||
const { curFlowID } = useContext(WorkspaceContext);
|
|
||||||
const [imagePrompt, setImagePrompt] = useState<ImagePrompt>();
|
const [imagePrompt, setImagePrompt] = useState<ImagePrompt>();
|
||||||
const [showAllInputs, setShowAllInputs] = useState(true);
|
const [showAllInputs, setShowAllInputs] = useState(true);
|
||||||
const [showNodeName, setShowNodeName] = useState(true);
|
const [showNodeName, setShowNodeName] = useState(true);
|
||||||
@@ -63,18 +60,6 @@ export default function MetadataForm({ media }: { media: Media | null }) {
|
|||||||
|
|
||||||
const [topFields, setTopFields] = useState<TopFieldType[]>([]);
|
const [topFields, setTopFields] = useState<TopFieldType[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
(async () => {
|
|
||||||
if (curFlowID) {
|
|
||||||
const topFieldsConfig = (await workflowsTable?.get(curFlowID))
|
|
||||||
?.topFieldsConfig;
|
|
||||||
if (topFieldsConfig) {
|
|
||||||
setTopFields(topFieldsConfig);
|
|
||||||
setShowAllInputs(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
}, [curFlowID]);
|
|
||||||
const updateTopField = (field: TopFieldType) => {
|
const updateTopField = (field: TopFieldType) => {
|
||||||
if (
|
if (
|
||||||
isInTopField(topFields, {
|
isInTopField(topFields, {
|
||||||
@@ -87,19 +72,9 @@ export default function MetadataForm({ media }: { media: Media | null }) {
|
|||||||
(v) => v.name !== field.name || v.promptKey !== field.promptKey,
|
(v) => v.name !== field.name || v.promptKey !== field.promptKey,
|
||||||
);
|
);
|
||||||
setTopFields(topFieldsConfig);
|
setTopFields(topFieldsConfig);
|
||||||
if (curFlowID) {
|
|
||||||
workflowsTable?.updateTopFields(curFlowID, {
|
|
||||||
topFieldsConfig,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
const topFieldsConfig = [...topFields, field];
|
const topFieldsConfig = [...topFields, field];
|
||||||
setTopFields(topFieldsConfig);
|
setTopFields(topFieldsConfig);
|
||||||
if (curFlowID) {
|
|
||||||
workflowsTable?.updateTopFields(curFlowID, {
|
|
||||||
topFieldsConfig,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+38
-16
@@ -4,9 +4,8 @@ import { ColorModeScript, type StyleFunctionProps } from "@chakra-ui/react";
|
|||||||
import { ChakraProvider, extendTheme } from "@chakra-ui/react";
|
import { ChakraProvider, extendTheme } from "@chakra-ui/react";
|
||||||
import { AlertDialogProvider } from "./components/AlertDialogProvider.tsx";
|
import { AlertDialogProvider } from "./components/AlertDialogProvider.tsx";
|
||||||
import CSSReset from "./MyCSSReset.tsx";
|
import CSSReset from "./MyCSSReset.tsx";
|
||||||
|
import { waitForApp } from "./utils/comfyapp.ts";
|
||||||
|
|
||||||
const topbar = document.createElement("div");
|
|
||||||
document.body.append(topbar);
|
|
||||||
const App = React.lazy(() =>
|
const App = React.lazy(() =>
|
||||||
import("./App.tsx").then(({ default: App }) => ({
|
import("./App.tsx").then(({ default: App }) => ({
|
||||||
default: App,
|
default: App,
|
||||||
@@ -51,20 +50,6 @@ const theme = extendTheme({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
ReactDOM.createRoot(topbar).render(
|
|
||||||
<React.StrictMode>
|
|
||||||
<ChakraProvider resetCSS={false} disableGlobalStyle={true} theme={theme}>
|
|
||||||
<CSSReset scope=".workspace_manager" />
|
|
||||||
<ColorModeScript initialColorMode="dark" />
|
|
||||||
<AlertDialogProvider>
|
|
||||||
<Suspense>
|
|
||||||
<App />
|
|
||||||
</Suspense>
|
|
||||||
</AlertDialogProvider>
|
|
||||||
</ChakraProvider>
|
|
||||||
</React.StrictMode>,
|
|
||||||
);
|
|
||||||
|
|
||||||
// hacky fix for chakra add extra className (chakra-ui-light) into body
|
// hacky fix for chakra add extra className (chakra-ui-light) into body
|
||||||
// and resulted in user unable to copy new nodes into clipboard, because of this check: e.target.className === "litegraph"
|
// and resulted in user unable to copy new nodes into clipboard, because of this check: e.target.className === "litegraph"
|
||||||
// (https://github.com/comfyanonymous/ComfyUI/blob/57926635e8d84ae9eea4a0416cc75e363f5ede45/web/scripts/app.js#L861)
|
// (https://github.com/comfyanonymous/ComfyUI/blob/57926635e8d84ae9eea4a0416cc75e363f5ede45/web/scripts/app.js#L861)
|
||||||
@@ -96,3 +81,40 @@ const callback = function (
|
|||||||
};
|
};
|
||||||
const observer = new MutationObserver(callback);
|
const observer = new MutationObserver(callback);
|
||||||
observer.observe(targetNode, observerConfig);
|
observer.observe(targetNode, observerConfig);
|
||||||
|
|
||||||
|
function waitForDocumentBody() {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
if (document.body) {
|
||||||
|
return resolve(document.body);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
resolve(document.body);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// wait for document.body to load so that the top menu is loaded and my react component has a place to mount
|
||||||
|
waitForDocumentBody()
|
||||||
|
.then(() => waitForApp())
|
||||||
|
.then(() => {
|
||||||
|
const topbar = document.createElement("div");
|
||||||
|
document.body.append(topbar);
|
||||||
|
ReactDOM.createRoot(topbar).render(
|
||||||
|
<React.StrictMode>
|
||||||
|
<ChakraProvider
|
||||||
|
resetCSS={false}
|
||||||
|
disableGlobalStyle={true}
|
||||||
|
theme={theme}
|
||||||
|
>
|
||||||
|
<CSSReset scope=".workspace_manager" />
|
||||||
|
<ColorModeScript initialColorMode="dark" />
|
||||||
|
<AlertDialogProvider>
|
||||||
|
<Suspense>
|
||||||
|
<App />
|
||||||
|
</Suspense>
|
||||||
|
</AlertDialogProvider>
|
||||||
|
</ChakraProvider>
|
||||||
|
</React.StrictMode>,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|||||||
@@ -59,11 +59,8 @@ export default function InatallModelsModal({
|
|||||||
>(MODEL_TYPE_TO_FOLDER_MAPPING);
|
>(MODEL_TYPE_TO_FOLDER_MAPPING);
|
||||||
const loadData = useCallback(async () => {
|
const loadData = useCallback(async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
// if (!searchQuery) {
|
const models = await getModelFromCivitAPi(modelType, searchQuery);
|
||||||
// const models = await getModelFromCivitAPi(modelType);
|
// const models = await getModelFromSearch(searchQuery, modelType);
|
||||||
// setModels(models);
|
|
||||||
// } else {
|
|
||||||
const models = await getModelFromSearch(searchQuery, modelType);
|
|
||||||
setModels(models);
|
setModels(models);
|
||||||
const folders_list = await getAllFoldersList();
|
const folders_list = await getAllFoldersList();
|
||||||
folders_list && setFoldersList(folders_list);
|
folders_list && setFoldersList(folders_list);
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { userSettingsTable } from "../../../db-tables/WorkspaceDB";
|
|
||||||
import { indexdb } from "../../../db-tables/indexdb";
|
import { indexdb } from "../../../db-tables/indexdb";
|
||||||
import { CivitiModel } from "../../types";
|
import { CivitiModel } from "../../types";
|
||||||
import { CACHE_EXPIRY_DAYS, MODEL_TYPE } from "./modelTypes";
|
import { CACHE_EXPIRY_DAYS, MODEL_TYPE } from "./modelTypes";
|
||||||
@@ -7,20 +6,19 @@ type CivitModelQueryParams = {
|
|||||||
types?: MODEL_TYPE;
|
types?: MODEL_TYPE;
|
||||||
query?: string;
|
query?: string;
|
||||||
limit?: string;
|
limit?: string;
|
||||||
nsfw?: boolean;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function getModelFromCivitAPi(
|
export async function getModelFromCivitAPi(
|
||||||
types?: MODEL_TYPE,
|
types?: MODEL_TYPE,
|
||||||
|
query?: string,
|
||||||
): Promise<CivitiModel[]> {
|
): Promise<CivitiModel[]> {
|
||||||
const showNsfwThumbnail = await userSettingsTable?.getSetting(
|
|
||||||
"showNsfwModelThumbnail",
|
|
||||||
);
|
|
||||||
const params: CivitModelQueryParams = {
|
const params: CivitModelQueryParams = {
|
||||||
limit: "30",
|
limit: "30",
|
||||||
nsfw: showNsfwThumbnail ?? false,
|
|
||||||
types,
|
types,
|
||||||
};
|
};
|
||||||
|
if (query) {
|
||||||
|
params.query = query;
|
||||||
|
}
|
||||||
|
|
||||||
const queryString = new URLSearchParams(params).toString();
|
const queryString = new URLSearchParams(params).toString();
|
||||||
const fullURL = `https://civitai.com/api/v1/models?${queryString}`;
|
const fullURL = `https://civitai.com/api/v1/models?${queryString}`;
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ export default function CloudHostSetting() {
|
|||||||
getSettings();
|
getSettings();
|
||||||
}, []);
|
}, []);
|
||||||
const submitChange = async (text: string) => {
|
const submitChange = async (text: string) => {
|
||||||
|
text = text.trim();
|
||||||
|
if (text.endsWith("/")) text = text.slice(0, -1);
|
||||||
await userSettingsTable?.upsert({ cloudHost: text });
|
await userSettingsTable?.upsert({ cloudHost: text });
|
||||||
getSettings();
|
getSettings();
|
||||||
toast({
|
toast({
|
||||||
@@ -35,6 +37,11 @@ export default function CloudHostSetting() {
|
|||||||
value={text}
|
value={text}
|
||||||
onChange={(e) => setText(e.target.value)}
|
onChange={(e) => setText(e.target.value)}
|
||||||
onBlur={() => submitChange(text)}
|
onBlur={() => submitChange(text)}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === "Enter") {
|
||||||
|
submitChange(text);
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
size={"sm"}
|
size={"sm"}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ export default function CommonCheckboxSettings({
|
|||||||
<Checkbox
|
<Checkbox
|
||||||
isChecked={checked}
|
isChecked={checked}
|
||||||
onChange={async (e) => {
|
onChange={async (e) => {
|
||||||
|
setChecked(e.target.checked);
|
||||||
await userSettingsTable?.upsert({ [settingKey]: e.target.checked });
|
await userSettingsTable?.upsert({ [settingKey]: e.target.checked });
|
||||||
getSetting();
|
getSetting();
|
||||||
toast({
|
toast({
|
||||||
|
|||||||
@@ -108,6 +108,13 @@ export default function SelectMyWorkflowsDir() {
|
|||||||
setCurrentDirectory(getNewPath);
|
setCurrentDirectory(getNewPath);
|
||||||
isManualEntry && setNoPermission(false);
|
isManualEntry && setNoPermission(false);
|
||||||
onCloseEditDirectory();
|
onCloseEditDirectory();
|
||||||
|
toast({
|
||||||
|
title: "Directory saved successfully. Please refresh the page.",
|
||||||
|
status: "success",
|
||||||
|
duration: 4000,
|
||||||
|
position: "top",
|
||||||
|
isClosable: true,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async (manualEntry?: string) => {
|
const onSubmit = async (manualEntry?: string) => {
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import { Input, Stack, useToast, Text, Flex, Button } from "@chakra-ui/react";
|
||||||
|
import { useContext, useEffect, useState } from "react";
|
||||||
|
import { userSettingsTable } from "../db-tables/WorkspaceDB";
|
||||||
|
import { WorkspaceContext } from "../WorkspaceContext";
|
||||||
|
import { saveShareKey } from "../utils/saveShareKey";
|
||||||
|
|
||||||
|
export default function SharekeySetting() {
|
||||||
|
const toast = useToast();
|
||||||
|
const { session, updateSession } = useContext(WorkspaceContext);
|
||||||
|
const [text, setText] = useState("");
|
||||||
|
const cloudDomain = new URL(userSettingsTable?.settings?.cloudHost!).hostname;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setText(session?.shareKey ?? "");
|
||||||
|
}, [session]);
|
||||||
|
const submitChange = async (text: string) => {
|
||||||
|
saveShareKey(text);
|
||||||
|
updateSession({ username: session?.username ?? null, shareKey: text });
|
||||||
|
toast({
|
||||||
|
title: "Setting saved. Please refresh to see the changes.",
|
||||||
|
status: "success",
|
||||||
|
duration: 4000,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack gap={3}>
|
||||||
|
<p style={{ fontWeight: "bold" }}>Cloud Backup [Beta]</p>
|
||||||
|
<p>
|
||||||
|
<a
|
||||||
|
href={userSettingsTable?.settings?.cloudHost + "/auth/shareKey"}
|
||||||
|
target="_blank"
|
||||||
|
style={{ textDecoration: "underline" }}
|
||||||
|
>
|
||||||
|
<Button size={"sm"}>👉Copy your share key from here</Button>
|
||||||
|
</a>{" "}
|
||||||
|
and paste it below to start saving workflow versions to cloud at{" "}
|
||||||
|
<a href={userSettingsTable?.settings?.cloudHost!} target="_blank">
|
||||||
|
{cloudDomain}
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<Flex alignItems={"center"}>
|
||||||
|
<Input
|
||||||
|
value={text}
|
||||||
|
placeholder="Paste your share key here"
|
||||||
|
onChange={(e) => setText(e.target.value)}
|
||||||
|
onBlur={() => submitChange(text)}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === "Enter") {
|
||||||
|
submitChange(text);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Flex>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -49,9 +49,8 @@ export default function TwoWaySyncSettings() {
|
|||||||
return (
|
return (
|
||||||
<Stack>
|
<Stack>
|
||||||
<Text>
|
<Text>
|
||||||
Only for legacy two way sync users to get back their data. Do not
|
Only for legacy two way sync users to get back their data. [DO NOT
|
||||||
disable two way sync if you have already enabled it. It may cause some
|
DISABLE]
|
||||||
unexpected issues.
|
|
||||||
</Text>
|
</Text>
|
||||||
<Checkbox isChecked={checked} onChange={onTwoWaySyncChange}>
|
<Checkbox isChecked={checked} onChange={onTwoWaySyncChange}>
|
||||||
Enable two way sync
|
Enable two way sync
|
||||||
|
|||||||
@@ -17,7 +17,11 @@ import {
|
|||||||
Text,
|
Text,
|
||||||
useToast,
|
useToast,
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { WorkflowPrivacy, WorkflowVersion } from "../types/dbTypes";
|
import {
|
||||||
|
EWorkflowPrivacy,
|
||||||
|
WorkflowPrivacy,
|
||||||
|
WorkflowVersion,
|
||||||
|
} from "../types/dbTypes";
|
||||||
import { useContext, useEffect, useState } from "react";
|
import { useContext, useEffect, useState } from "react";
|
||||||
import CustomSelector from "../components/CustomSelector";
|
import CustomSelector from "../components/CustomSelector";
|
||||||
import { IconCopy, IconExternalLink } from "@tabler/icons-react";
|
import { IconCopy, IconExternalLink } from "@tabler/icons-react";
|
||||||
@@ -28,6 +32,7 @@ import {
|
|||||||
PrivacyLabel,
|
PrivacyLabel,
|
||||||
fetchCloudWorkflowPrivacy,
|
fetchCloudWorkflowPrivacy,
|
||||||
generateRandomKey,
|
generateRandomKey,
|
||||||
|
getCurDateString,
|
||||||
getNodeDefs,
|
getNodeDefs,
|
||||||
privacyOptions,
|
privacyOptions,
|
||||||
} from "./shareUtils";
|
} from "./shareUtils";
|
||||||
@@ -35,7 +40,6 @@ import {
|
|||||||
import ResourceDepsForm from "../spacejson/ResourceDepsForm";
|
import ResourceDepsForm from "../spacejson/ResourceDepsForm";
|
||||||
import { app } from "../utils/comfyapp";
|
import { app } from "../utils/comfyapp";
|
||||||
import { useStateRef } from "../customHooks/useStateRef";
|
import { useStateRef } from "../customHooks/useStateRef";
|
||||||
import { nanoid } from "nanoid";
|
|
||||||
import { WorkspaceContext } from "../WorkspaceContext";
|
import { WorkspaceContext } from "../WorkspaceContext";
|
||||||
import {
|
import {
|
||||||
DepsResult,
|
DepsResult,
|
||||||
@@ -44,6 +48,7 @@ import {
|
|||||||
} from "../spacejson/handleDownloadSpaceJson";
|
} from "../spacejson/handleDownloadSpaceJson";
|
||||||
import { fetchApi } from "../Api";
|
import { fetchApi } from "../Api";
|
||||||
import { COMFYSPACE_TRACKING_FIELD_NAME } from "../const";
|
import { COMFYSPACE_TRACKING_FIELD_NAME } from "../const";
|
||||||
|
import { ShareWorkflowData } from "../types/types";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
@@ -70,20 +75,18 @@ export default function ShareDialog({ onClose }: Props) {
|
|||||||
const detail = event.data;
|
const detail = event.data;
|
||||||
if (
|
if (
|
||||||
// event.origin !== cloudHostRef.current ||
|
// event.origin !== cloudHostRef.current ||
|
||||||
detail.type !== "share_workflow_success"
|
detail.type !== "share_workflow_success" ||
|
||||||
|
!workflow
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const localID = detail.localWorkflowID;
|
|
||||||
const cloudVersionID = detail.version.id;
|
const cloudVersionID = detail.version.id;
|
||||||
const cloudID = detail.version.workflowID;
|
const cloudID = detail.version.workflowID;
|
||||||
|
|
||||||
cloudID &&
|
cloudID &&
|
||||||
localID &&
|
(await workflowsTable?.updateMetaInfo(workflow.id, {
|
||||||
(await workflowsTable?.updateMetaInfo(localID, {
|
|
||||||
cloudID: cloudID,
|
cloudID: cloudID,
|
||||||
privacy: privacyRef.current,
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
loadData();
|
loadData();
|
||||||
@@ -138,7 +141,7 @@ export default function ShareDialog({ onClose }: Props) {
|
|||||||
|
|
||||||
await saveCurWorkflow();
|
await saveCurWorkflow();
|
||||||
|
|
||||||
const apiPrompt = await app
|
await app
|
||||||
.graphToPrompt(app.graph)
|
.graphToPrompt(app.graph)
|
||||||
.then((data: { output: any; workflow: any }) => {
|
.then((data: { output: any; workflow: any }) => {
|
||||||
graph.extra[COMFYSPACE_TRACKING_FIELD_NAME].apiPrompt = data.output;
|
graph.extra[COMFYSPACE_TRACKING_FIELD_NAME].apiPrompt = data.output;
|
||||||
@@ -153,12 +156,8 @@ export default function ShareDialog({ onClose }: Props) {
|
|||||||
: "http://localhost:3000";
|
: "http://localhost:3000";
|
||||||
let nodeDefs: Object;
|
let nodeDefs: Object;
|
||||||
nodeDefs = getNodeDefs();
|
nodeDefs = getNodeDefs();
|
||||||
const version: WorkflowVersion = {
|
const version: Omit<WorkflowVersion, "id" | "workflowID" | "createTime"> = {
|
||||||
id: nanoid(),
|
|
||||||
workflowID: workflow!.id,
|
|
||||||
name: versionNameRef.current,
|
name: versionNameRef.current,
|
||||||
createTime: Date.now(),
|
|
||||||
api_prompt: JSON.stringify(apiPrompt),
|
|
||||||
json: jsonToShare ?? JSON.stringify(app.graph.serialize()),
|
json: jsonToShare ?? JSON.stringify(app.graph.serialize()),
|
||||||
};
|
};
|
||||||
const protocol = window.location.protocol;
|
const protocol = window.location.protocol;
|
||||||
@@ -174,16 +173,23 @@ export default function ShareDialog({ onClose }: Props) {
|
|||||||
const handleChildReady = (event: MessageEvent) => {
|
const handleChildReady = (event: MessageEvent) => {
|
||||||
if (event.origin === host && event.data === "child_ready") {
|
if (event.origin === host && event.data === "child_ready") {
|
||||||
const curWorkflow = workflowsTable?.curWorkflow;
|
const curWorkflow = workflowsTable?.curWorkflow;
|
||||||
// Send data to the new window after it loads
|
if (!curWorkflow) {
|
||||||
sharePopup!.postMessage(
|
return;
|
||||||
{
|
}
|
||||||
workflow: curWorkflow,
|
const input: ShareWorkflowData = {
|
||||||
version: version,
|
workflow: {
|
||||||
nodeDefs: nodeDefs,
|
name: curWorkflow.name,
|
||||||
privacy: privacyRef.current,
|
cloudID: curWorkflow.cloudID,
|
||||||
},
|
},
|
||||||
host,
|
version: {
|
||||||
);
|
name: versionNameRef.current,
|
||||||
|
json: jsonToShare,
|
||||||
|
},
|
||||||
|
nodeDefs: nodeDefs,
|
||||||
|
privacy: privacyRef.current as EWorkflowPrivacy,
|
||||||
|
};
|
||||||
|
// Send data to the new window after it loads
|
||||||
|
sharePopup!.postMessage(input, host);
|
||||||
window.removeEventListener("message", handleChildReady);
|
window.removeEventListener("message", handleChildReady);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -199,18 +205,22 @@ export default function ShareDialog({ onClose }: Props) {
|
|||||||
// .filter((i) => !i.url)
|
// .filter((i) => !i.url)
|
||||||
.map((i) => i.filename);
|
.map((i) => i.filename);
|
||||||
if (imageDepsToUpload.length) {
|
if (imageDepsToUpload.length) {
|
||||||
const uploadResp = await fetchApi("/workspace/upload_image", {
|
try {
|
||||||
method: "POST",
|
const uploadResp = await fetchApi("/workspace/upload_image", {
|
||||||
body: JSON.stringify({
|
method: "POST",
|
||||||
images: imageDepsToUpload,
|
body: JSON.stringify({
|
||||||
}),
|
images: imageDepsToUpload,
|
||||||
});
|
}),
|
||||||
const json = (await uploadResp.json()) as Record<string, string>;
|
});
|
||||||
Object.keys(json).forEach((key) => {
|
const json = (await uploadResp.json()) as Record<string, string>;
|
||||||
if (imageDeps?.[key]) {
|
Object.keys(json).forEach((key) => {
|
||||||
imageDeps[key].url = json[key];
|
if (imageDeps?.[key]) {
|
||||||
}
|
imageDeps[key].url = json[key];
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error uploading images:", error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setUploadingImage(false);
|
setUploadingImage(false);
|
||||||
}
|
}
|
||||||
@@ -343,12 +353,3 @@ export default function ShareDialog({ onClose }: Props) {
|
|||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCurDateString() {
|
|
||||||
const currentDate = new Date();
|
|
||||||
const year = currentDate.getFullYear();
|
|
||||||
const month = String(currentDate.getMonth() + 1).padStart(2, "0"); // Months are 0-based in JS
|
|
||||||
const day = String(currentDate.getDate()).padStart(2, "0");
|
|
||||||
|
|
||||||
return `${year}-${month}-${day}`;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { IconLink, IconLock, IconWorld } from "@tabler/icons-react";
|
|||||||
import { CustomSelectorOption } from "../components/CustomSelector";
|
import { CustomSelectorOption } from "../components/CustomSelector";
|
||||||
import { Workflow, WorkflowPrivacy } from "../types/dbTypes";
|
import { Workflow, WorkflowPrivacy } from "../types/dbTypes";
|
||||||
import { app } from "../utils/comfyapp";
|
import { app } from "../utils/comfyapp";
|
||||||
|
import { userSettingsTable } from "../db-tables/WorkspaceDB";
|
||||||
|
|
||||||
export function generateRandomKey(length: number) {
|
export function generateRandomKey(length: number) {
|
||||||
// Generate a random array of bytes
|
// Generate a random array of bytes
|
||||||
@@ -60,10 +61,7 @@ export const getNodeDefs = () => {
|
|||||||
export async function fetchCloudWorkflowPrivacy(
|
export async function fetchCloudWorkflowPrivacy(
|
||||||
workflow: Workflow,
|
workflow: Workflow,
|
||||||
): Promise<WorkflowPrivacy> {
|
): Promise<WorkflowPrivacy> {
|
||||||
const cloudOrigin = workflow.cloudOrigin;
|
const cloudOrigin = userSettingsTable?.settings?.cloudHost;
|
||||||
if (!cloudOrigin) {
|
|
||||||
throw Error("cloudURL is required");
|
|
||||||
}
|
|
||||||
return fetch(cloudOrigin + `/api/getWorkflow?id=${workflow.cloudID}`)
|
return fetch(cloudOrigin + `/api/getWorkflow?id=${workflow.cloudID}`)
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((json) => {
|
.then((json) => {
|
||||||
@@ -99,3 +97,12 @@ export function PrivacyLabel({
|
|||||||
}
|
}
|
||||||
return <span>{text}</span>;
|
return <span>{text}</span>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getCurDateString() {
|
||||||
|
const currentDate = new Date();
|
||||||
|
// const year = currentDate.getFullYear();
|
||||||
|
const month = String(currentDate.getMonth() + 1).padStart(2, "0"); // Months are 0-based in JS
|
||||||
|
const day = String(currentDate.getDate()).padStart(2, "0");
|
||||||
|
|
||||||
|
return `${month}-${day}`;
|
||||||
|
}
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ async function fetchModelData(
|
|||||||
): Promise<DepsResultModel> {
|
): Promise<DepsResultModel> {
|
||||||
const res =
|
const res =
|
||||||
(await indexdb.models.where("fileName").equals(filename).toArray()) ?? [];
|
(await indexdb.models.where("fileName").equals(filename).toArray()) ?? [];
|
||||||
console.log("fetch modeldata", res);
|
|
||||||
const first = res.at(0);
|
const first = res.at(0);
|
||||||
const modelFile: DepsResultModel = {
|
const modelFile: DepsResultModel = {
|
||||||
name: filename,
|
name: filename,
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
import { useContext, useEffect, useRef, useState } from "react";
|
import { useContext, useEffect, useRef } from "react";
|
||||||
import { WorkspaceContext } from "../WorkspaceContext";
|
import { WorkspaceContext } from "../WorkspaceContext";
|
||||||
import {
|
import { workflowsTable } from "../db-tables/WorkspaceDB";
|
||||||
changelogsTable,
|
|
||||||
userSettingsTable,
|
|
||||||
workflowsTable,
|
|
||||||
} from "../db-tables/WorkspaceDB";
|
|
||||||
import { Tag, Tooltip } from "@chakra-ui/react";
|
|
||||||
import { matchShortcut } from "../utils";
|
import { matchShortcut } from "../utils";
|
||||||
import { EShortcutKeys } from "../types/dbTypes";
|
import { EShortcutKeys } from "../types/dbTypes";
|
||||||
import useDebounceFn from "../customHooks/useDebounceFn";
|
import useDebounceFn from "../customHooks/useDebounceFn";
|
||||||
@@ -24,8 +19,6 @@ export default function AppIsDirtyEventListener() {
|
|||||||
setCurFlowIDAndName,
|
setCurFlowIDAndName,
|
||||||
} = useContext(WorkspaceContext);
|
} = useContext(WorkspaceContext);
|
||||||
const isDirtRef = useRef(isDirty);
|
const isDirtRef = useRef(isDirty);
|
||||||
const [isOutdated, setIsOutdated] = useState(false);
|
|
||||||
const autoSaveTimer = useRef<number | null>(null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
isDirtRef.current = isDirty;
|
isDirtRef.current = isDirty;
|
||||||
@@ -66,6 +59,33 @@ export default function AppIsDirtyEventListener() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const restoreCurWorkflow = async () => {
|
||||||
|
if (!app?.graph) {
|
||||||
|
console.error(
|
||||||
|
"🦄 Error in workspace manager! app.graph is not available in restoreCurWorkflow()",
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const id = app.graph.extra?.[COMFYSPACE_TRACKING_FIELD_NAME]?.id;
|
||||||
|
console.log("🦄 Restoring workflow... id=", id);
|
||||||
|
if (id) {
|
||||||
|
const flow = await workflowsTable?.get(id);
|
||||||
|
console.log(
|
||||||
|
"🦄 Restored workflow",
|
||||||
|
flow?.parentFolderID + "/" + flow?.name,
|
||||||
|
);
|
||||||
|
flow && setCurFlowIDAndName(flow);
|
||||||
|
|
||||||
|
if (
|
||||||
|
!flow?.saveLock &&
|
||||||
|
flow &&
|
||||||
|
flow.json !== JSON.stringify(app.graph.serialize())
|
||||||
|
) {
|
||||||
|
setIsDirty(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const originalOnConfigure = app.graph.onConfigure;
|
const originalOnConfigure = app.graph.onConfigure;
|
||||||
app.graph.onConfigure = function () {
|
app.graph.onConfigure = function () {
|
||||||
originalOnConfigure?.apply(this, arguments);
|
originalOnConfigure?.apply(this, arguments);
|
||||||
@@ -90,41 +110,11 @@ export default function AppIsDirtyEventListener() {
|
|||||||
});
|
});
|
||||||
document.addEventListener("keydown", keydownListener);
|
document.addEventListener("keydown", keydownListener);
|
||||||
|
|
||||||
if (
|
restoreCurWorkflow();
|
||||||
userSettingsTable?.settings?.autoSave &&
|
|
||||||
userSettingsTable.settings.autoSaveDuration
|
|
||||||
) {
|
|
||||||
autoSaveTimer.current = setInterval(() => {
|
|
||||||
// auto save workflow every 5s
|
|
||||||
autoSaveWorkflow();
|
|
||||||
}, userSettingsTable.settings.autoSaveDuration * 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
document.removeEventListener("keydown", keydownListener);
|
document.removeEventListener("keydown", keydownListener);
|
||||||
autoSaveTimer.current && clearInterval(autoSaveTimer.current);
|
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
const autoSaveWorkflow = async () => {
|
|
||||||
// autosave workflow if enabled
|
|
||||||
if (
|
|
||||||
workflowsTable?.curWorkflow?.saveLock ||
|
|
||||||
!workflowsTable?.curWorkflow?.id ||
|
|
||||||
!isDirtRef.current
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const graphJson = JSON.stringify(app.graph.serialize());
|
|
||||||
await workflowsTable?.updateFlow(workflowsTable.curWorkflow.id, {
|
|
||||||
json: graphJson,
|
|
||||||
});
|
|
||||||
changelogsTable?.create({
|
|
||||||
workflowID: workflowsTable.curWorkflow.id,
|
|
||||||
isAutoSave: true,
|
|
||||||
json: graphJson,
|
|
||||||
});
|
|
||||||
setIsDirty(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onIsDirty = async () => {
|
const onIsDirty = async () => {
|
||||||
if (workflowsTable?.curWorkflow?.saveLock || isDirtRef.current) return;
|
if (workflowsTable?.curWorkflow?.saveLock || isDirtRef.current) return;
|
||||||
@@ -133,22 +123,8 @@ export default function AppIsDirtyEventListener() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setIsDirty(true);
|
setIsDirty(true);
|
||||||
if (
|
|
||||||
userSettingsTable?.settings?.autoSave &&
|
|
||||||
workflowsTable?.curWorkflow?.id &&
|
|
||||||
!isOutdated
|
|
||||||
) {
|
|
||||||
const isLatest = await workflowsTable?.latestVersionCheck();
|
|
||||||
if (!isLatest) {
|
|
||||||
setIsOutdated(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
const [debounceOnIsDirty, _] = useDebounceFn(onIsDirty, 900);
|
const [debounceOnIsDirty, _] = useDebounceFn(onIsDirty, 900);
|
||||||
|
|
||||||
return isOutdated ? (
|
return null;
|
||||||
<Tooltip label="This workflow was changed by another tab, so you are not working on the latest version. Please refresh page to see the latest version of this workflow.">
|
|
||||||
<Tag colorScheme="yellow">⚠️Outdated version</Tag>
|
|
||||||
</Tooltip>
|
|
||||||
) : null;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +1,48 @@
|
|||||||
import { Tooltip, Button } from "@chakra-ui/react";
|
import { Tooltip, Button } from "@chakra-ui/react";
|
||||||
import { IconDeviceFloppy, IconPlus } from "@tabler/icons-react";
|
import { IconDeviceFloppy } from "@tabler/icons-react";
|
||||||
import { useContext } from "react";
|
import { useContext } from "react";
|
||||||
import { WorkspaceContext } from "../WorkspaceContext";
|
import { WorkspaceContext } from "../WorkspaceContext";
|
||||||
import { TOPBAR_BUTTON_HEIGHT } from "../const";
|
import { COMFYSPACE_TRACKING_FIELD_NAME, TOPBAR_BUTTON_HEIGHT } from "../const";
|
||||||
import { app } from "../utils/comfyapp";
|
import { app } from "../utils/comfyapp";
|
||||||
import { workflowsTable } from "../db-tables/WorkspaceDB";
|
import { workflowsTable } from "../db-tables/WorkspaceDB";
|
||||||
|
import { nanoid } from "nanoid";
|
||||||
|
|
||||||
export default function TopbarNewWorkflowButton() {
|
export default function TopbarNewWorkflowButton() {
|
||||||
const { loadNewWorkflow, setCurFlowIDAndName, curFlowID } =
|
const { setCurFlowIDAndName, curFlowID } = useContext(WorkspaceContext);
|
||||||
useContext(WorkspaceContext);
|
|
||||||
const saveNewWorkflow = async () => {
|
const saveNewWorkflow = async () => {
|
||||||
const graph = JSON.stringify(app.graph.serialize());
|
|
||||||
const workflowName = prompt("Enter workflow name", "Untitled");
|
const workflowName = prompt("Enter workflow name", "Untitled");
|
||||||
if (!workflowName) return;
|
if (!workflowName) return;
|
||||||
|
const id = nanoid();
|
||||||
|
const graph = app.graph.serialize();
|
||||||
|
if (!graph.extra) {
|
||||||
|
graph.extra = {};
|
||||||
|
}
|
||||||
|
if (!graph.extra[COMFYSPACE_TRACKING_FIELD_NAME]) {
|
||||||
|
graph.extra[COMFYSPACE_TRACKING_FIELD_NAME] = {};
|
||||||
|
}
|
||||||
|
graph.extra[COMFYSPACE_TRACKING_FIELD_NAME].id = id;
|
||||||
const flow = await workflowsTable?.createFlow({
|
const flow = await workflowsTable?.createFlow({
|
||||||
json: graph,
|
id,
|
||||||
|
json: JSON.stringify(graph),
|
||||||
name: workflowName,
|
name: workflowName,
|
||||||
});
|
});
|
||||||
flow && setCurFlowIDAndName(flow);
|
flow && setCurFlowIDAndName(flow);
|
||||||
};
|
};
|
||||||
|
if (curFlowID) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<Tooltip label={curFlowID ? "New workflow" : "Save workflow"}>
|
<Tooltip label={"Save workflow"}>
|
||||||
<Button
|
<Button
|
||||||
size={"sm"}
|
size={"sm"}
|
||||||
variant={"outline"}
|
variant={"outline"}
|
||||||
colorScheme="teal"
|
colorScheme="teal"
|
||||||
aria-label="new workflow"
|
aria-label="new workflow"
|
||||||
height={TOPBAR_BUTTON_HEIGHT + "px"}
|
height={TOPBAR_BUTTON_HEIGHT + "px"}
|
||||||
onClick={() => (curFlowID ? loadNewWorkflow() : saveNewWorkflow())}
|
onClick={() => saveNewWorkflow()}
|
||||||
px={1}
|
px={1}
|
||||||
>
|
>
|
||||||
{curFlowID ? (
|
<IconDeviceFloppy size={16} color={"white"} />
|
||||||
<IconPlus size={16} color={"white"} />
|
|
||||||
) : (
|
|
||||||
<IconDeviceFloppy size={16} color={"white"} />
|
|
||||||
)}
|
|
||||||
</Button>
|
</Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -11,14 +11,16 @@ export interface Workflow extends SortableItem {
|
|||||||
id: string;
|
id: string;
|
||||||
json: string;
|
json: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
coverMediaPath?: string | null;
|
||||||
|
saveLock?: boolean;
|
||||||
|
cloudID?: string | null;
|
||||||
createTime: number;
|
createTime: number;
|
||||||
|
|
||||||
|
// will be deprecated
|
||||||
privacy?: WorkflowPrivacy;
|
privacy?: WorkflowPrivacy;
|
||||||
tags?: string[];
|
tags?: string[];
|
||||||
parentFolderID?: string | null; //TODO remove undefined, use null only
|
parentFolderID?: string | null; //TODO remove undefined, use null only
|
||||||
coverMediaPath?: string;
|
|
||||||
cloudID?: string; // TODO will be deprecated
|
|
||||||
cloudOrigin?: string;
|
cloudOrigin?: string;
|
||||||
saveLock?: boolean;
|
|
||||||
latestImage?: string;
|
latestImage?: string;
|
||||||
topFieldsConfig?: TopFieldType[];
|
topFieldsConfig?: TopFieldType[];
|
||||||
}
|
}
|
||||||
@@ -64,10 +66,9 @@ export type WorkflowVersion = {
|
|||||||
name: string;
|
name: string;
|
||||||
workflowID: string;
|
workflowID: string;
|
||||||
json: string;
|
json: string;
|
||||||
createTime: number;
|
createTime?: number;
|
||||||
api_prompt: string;
|
createdAt?: string;
|
||||||
cloudID?: string;
|
created_at?: string;
|
||||||
cloudOrigin?: string;
|
|
||||||
authorID?: string;
|
authorID?: string;
|
||||||
nodeDefs?: string; //for cloud workflow version
|
nodeDefs?: string; //for cloud workflow version
|
||||||
};
|
};
|
||||||
@@ -95,7 +96,6 @@ export type UserSettings = {
|
|||||||
foldersOnTop?: boolean;
|
foldersOnTop?: boolean;
|
||||||
showNsfwModelThumbnail?: boolean;
|
showNsfwModelThumbnail?: boolean;
|
||||||
cloudHost: string;
|
cloudHost: string;
|
||||||
overwriteCurWorkflowWhenDroppingFileToCanvas: boolean;
|
|
||||||
defaultFolders: Record<MODEL_TYPE, string>;
|
defaultFolders: Record<MODEL_TYPE, string>;
|
||||||
maximumChangelogNumber: number;
|
maximumChangelogNumber: number;
|
||||||
hideCoverImage: boolean;
|
hideCoverImage: boolean;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { EWorkflowPrivacy } from "./dbTypes";
|
||||||
|
|
||||||
export type WorkspaceRoute =
|
export type WorkspaceRoute =
|
||||||
| "root"
|
| "root"
|
||||||
| "customNodes"
|
| "customNodes"
|
||||||
@@ -10,3 +12,21 @@ export type WorkspaceRoute =
|
|||||||
| "downloadSpaceJson"
|
| "downloadSpaceJson"
|
||||||
| "installModels"
|
| "installModels"
|
||||||
| "share";
|
| "share";
|
||||||
|
|
||||||
|
export type Session = {
|
||||||
|
username: string | null;
|
||||||
|
shareKey: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ShareWorkflowData = {
|
||||||
|
version: {
|
||||||
|
name: string;
|
||||||
|
json: string;
|
||||||
|
};
|
||||||
|
workflow: {
|
||||||
|
name: string;
|
||||||
|
cloudID?: string | null;
|
||||||
|
};
|
||||||
|
nodeDefs: Object;
|
||||||
|
privacy: EWorkflowPrivacy;
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
import type { Workflow } from "../types/dbTypes";
|
import type { Workflow } from "../types/dbTypes";
|
||||||
|
|
||||||
|
export const serverInfo: {
|
||||||
|
os: "Windows" | "Linux" | "Darwin" | "Java" | null;
|
||||||
|
} = {
|
||||||
|
os: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getPathSep = () => (serverInfo.os === "Windows" ? "\\" : "/");
|
||||||
|
|
||||||
export function joinRelPath(...segments: string[]) {
|
export function joinRelPath(...segments: string[]) {
|
||||||
const rel = segments.filter((segment) => segment !== "").join("/");
|
const rel = segments.filter((segment) => segment !== "").join("/");
|
||||||
return sanitizeRelPath(rel);
|
return sanitizeRelPath(rel);
|
||||||
@@ -15,6 +23,10 @@ export function sanitizeRelPath(path: string) {
|
|||||||
// Remove leading slashes to ensure the path is treated as relative
|
// Remove leading slashes to ensure the path is treated as relative
|
||||||
sanitizedPath = sanitizedPath.replace(/^\/+/, "");
|
sanitizedPath = sanitizedPath.replace(/^\/+/, "");
|
||||||
|
|
||||||
|
if (serverInfo.os === "Windows") {
|
||||||
|
sanitizedPath = segments.replace(/\//g, "\\");
|
||||||
|
}
|
||||||
|
|
||||||
return sanitizedPath;
|
return sanitizedPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,14 @@ const api_base = location.pathname.split("/").slice(0, -1).join("/");
|
|||||||
|
|
||||||
export let api: any | null = null;
|
export let api: any | null = null;
|
||||||
|
|
||||||
import(api_base + "/scripts/api.js").then((apiJs) => {
|
export async function waitForApp() {
|
||||||
api = apiJs?.api;
|
await Promise.all([
|
||||||
});
|
import(api_base + "/scripts/api.js").then((apiJs) => {
|
||||||
|
api = apiJs?.api;
|
||||||
|
}),
|
||||||
|
|
||||||
import(api_base + "/scripts/app.js").then((appJs) => {
|
import(api_base + "/scripts/app.js").then((appJs) => {
|
||||||
app = appJs?.app;
|
app = appJs?.app;
|
||||||
});
|
}),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// utils/encryptUtils
|
||||||
|
const defaultSalt = import.meta.env.VITE_SHARE_KEY_ENCODE_KEY;
|
||||||
|
|
||||||
|
export function encodeKey(text: string, salt: string = defaultSalt): string {
|
||||||
|
const randomLength = Math.floor(Math.random() * 13) + 1; // Random length between 1 and 13
|
||||||
|
const randomPadding = Math.random()
|
||||||
|
.toString(36)
|
||||||
|
.substring(2, 2 + randomLength);
|
||||||
|
const input = randomPadding + salt + text;
|
||||||
|
return btoa(encodeURIComponent(input));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function decodeKey(encoded: string, salt: string = defaultSalt): string {
|
||||||
|
const decoded = decodeURIComponent(atob(encoded));
|
||||||
|
const saltIndex = decoded.indexOf(salt);
|
||||||
|
if (saltIndex === -1) throw new Error("Invalid encoded string or salt");
|
||||||
|
return decoded.slice(saltIndex + salt.length);
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { encodeKey } from "./encryptUtils";
|
||||||
|
|
||||||
|
export function saveShareKey(sharekey: string) {
|
||||||
|
const key = encodeKey(sharekey);
|
||||||
|
localStorage.setItem("workspace_manager_shareKey", key);
|
||||||
|
}
|
||||||
@@ -35,17 +35,22 @@ export async function scanMyWorkflowsDir(
|
|||||||
} else {
|
} else {
|
||||||
// is workflow
|
// is workflow
|
||||||
|
|
||||||
const existingWorkflow = (await indexdb.workflows
|
const existingWorkflow = await indexdb.workflows
|
||||||
?.get(file.id)
|
?.get(file.id)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error("Error getting workflow from indexdb", err);
|
console.error(
|
||||||
|
"Error getting workflow from indexdb",
|
||||||
|
file.id,
|
||||||
|
relPath,
|
||||||
|
err,
|
||||||
|
);
|
||||||
return null;
|
return null;
|
||||||
})) ?? {
|
});
|
||||||
createTime: Date.now(),
|
|
||||||
updateTime: Date.now(),
|
|
||||||
};
|
|
||||||
|
|
||||||
const newWorkflow: Workflow = {
|
const newWorkflow: Workflow = {
|
||||||
|
cloudID: file.cloudID,
|
||||||
|
coverMediaPath: file.coverMediaPath,
|
||||||
|
saveLock: file.saveLock,
|
||||||
...existingWorkflow,
|
...existingWorkflow,
|
||||||
id: file.id,
|
id: file.id,
|
||||||
json: file.json ?? "{}",
|
json: file.json ?? "{}",
|
||||||
@@ -54,7 +59,7 @@ export async function scanMyWorkflowsDir(
|
|||||||
createTime: file.createTime,
|
createTime: file.createTime,
|
||||||
// setting updateTime will result latestVersionChcek() always fail if in
|
// setting updateTime will result latestVersionChcek() always fail if in
|
||||||
// workflow.get() not pull updateTime from file
|
// workflow.get() not pull updateTime from file
|
||||||
// updateTime: file.updateTime,
|
updateTime: file.updateTime,
|
||||||
};
|
};
|
||||||
return newWorkflow;
|
return newWorkflow;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Flex,
|
||||||
|
Input,
|
||||||
|
Modal,
|
||||||
|
ModalBody,
|
||||||
|
ModalContent,
|
||||||
|
Stack,
|
||||||
|
useToast,
|
||||||
|
} from "@chakra-ui/react";
|
||||||
|
import { userSettingsTable } from "../db-tables/WorkspaceDB";
|
||||||
|
import { useContext } from "react";
|
||||||
|
import { WorkspaceContext } from "../WorkspaceContext";
|
||||||
|
import { saveShareKey } from "../utils/saveShareKey";
|
||||||
|
|
||||||
|
export default function CreateVersionLogin({
|
||||||
|
onClose,
|
||||||
|
}: {
|
||||||
|
onClose: () => void;
|
||||||
|
}) {
|
||||||
|
const cloudHost = userSettingsTable?.settings?.cloudHost;
|
||||||
|
const toast = useToast();
|
||||||
|
const { updateSession } = useContext(WorkspaceContext);
|
||||||
|
return (
|
||||||
|
<Modal isOpen={true} onClose={onClose} size={"xl"}>
|
||||||
|
<ModalContent width={"90vw"}>
|
||||||
|
<ModalBody>
|
||||||
|
<Stack p={"10px 10px"} gap={3}>
|
||||||
|
<h2
|
||||||
|
style={{
|
||||||
|
fontSize: "1.2rem",
|
||||||
|
fontWeight: "bold",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
✨New Version Control Exprience [beta]
|
||||||
|
</h2>
|
||||||
|
<p>
|
||||||
|
We have a new version control experience. Now your versions will
|
||||||
|
be stored <b>privately</b> and securely in cloud at{" "}
|
||||||
|
<a href="www.nodecafe.co">www.nodecafe.co</a>
|
||||||
|
</p>
|
||||||
|
<h3 style={{ fontWeight: "bold" }}>Why cloud?</h3>
|
||||||
|
<p>
|
||||||
|
Previously workflow versions are stored locally in your browser
|
||||||
|
storage. But people reported inconsistent versions when they
|
||||||
|
switched browser or device. Therefore we are moving to cloud. So
|
||||||
|
you can view your workflow versions from any devices, even your
|
||||||
|
phone.
|
||||||
|
</p>
|
||||||
|
<h3 style={{ fontWeight: "bold" }}>🤩Get Started</h3>
|
||||||
|
<Flex alignItems={"center"} gap={2} mb={3}>
|
||||||
|
<a href={cloudHost + "/auth/shareKey"} target="_blank">
|
||||||
|
<Button colorScheme="blue">Login</Button>
|
||||||
|
</a>
|
||||||
|
<p> then copy your share key to below</p>
|
||||||
|
</Flex>
|
||||||
|
<Input
|
||||||
|
placeholder="Paste your share key here"
|
||||||
|
onChange={(e) => {
|
||||||
|
if (
|
||||||
|
!e.target.value ||
|
||||||
|
e.target.value === "" ||
|
||||||
|
e.target.value.length < 20
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
saveShareKey(e.target.value);
|
||||||
|
updateSession({
|
||||||
|
shareKey: e.target.value,
|
||||||
|
username: null,
|
||||||
|
});
|
||||||
|
toast({
|
||||||
|
title: "Share key saved. You can create versions now.",
|
||||||
|
status: "success",
|
||||||
|
duration: 5000,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
</ModalBody>
|
||||||
|
</ModalContent>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@ const rewriteImportPlugin = ({ isDev }) => {
|
|||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig(({ mode }) => ({
|
export default defineConfig(({ mode }) => ({
|
||||||
|
base: "./",
|
||||||
envDir: ".",
|
envDir: ".",
|
||||||
build: {
|
build: {
|
||||||
watch: {
|
watch: {
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
1.1.0
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
import urllib.request
|
|
||||||
import zipfile
|
|
||||||
import io
|
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
import tempfile
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
def get_remote_version(url):
|
|
||||||
try:
|
|
||||||
with urllib.request.urlopen(url) as response:
|
|
||||||
return response.read().decode('utf-8').strip()
|
|
||||||
except urllib.error.HTTPError as http_err:
|
|
||||||
print(f"[Workspace Manager] HTTP error occurred: {http_err}")
|
|
||||||
return None
|
|
||||||
|
|
||||||
def is_update_needed(local_version_file, remote_version_url):
|
|
||||||
if not os.path.exists(local_version_file):
|
|
||||||
return True # Local version file doesn't exist, needs update
|
|
||||||
|
|
||||||
with open(local_version_file, 'r') as file:
|
|
||||||
local_version = file.read().strip()
|
|
||||||
|
|
||||||
remote_version = get_remote_version(remote_version_url)
|
|
||||||
# print(f"[Workspace Manager] Current version: {local_version}, latest version: {remote_version}")
|
|
||||||
if remote_version and local_version != remote_version:
|
|
||||||
return True # Versions are different
|
|
||||||
else:
|
|
||||||
return False # No update needed
|
|
||||||
|
|
||||||
def download_and_extract_repo(url, extract_to):
|
|
||||||
print(f"[Workspace Manager] Downloading from {url} to {extract_to}")
|
|
||||||
try:
|
|
||||||
# Create a temporary directory to extract the zip file
|
|
||||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
|
||||||
with urllib.request.urlopen(url) as response:
|
|
||||||
with zipfile.ZipFile(io.BytesIO(response.read())) as zip_ref:
|
|
||||||
# Extract to the temporary directory
|
|
||||||
zip_ref.extractall(tmp_dir)
|
|
||||||
# Assuming the first directory in the zip is the one we want
|
|
||||||
extracted_folder = os.path.join(tmp_dir, os.listdir(tmp_dir)[0])
|
|
||||||
|
|
||||||
# Move contents to the desired location
|
|
||||||
for filename in os.listdir(extracted_folder):
|
|
||||||
shutil.move(os.path.join(extracted_folder, filename), os.path.join(extract_to, filename))
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print(f"[Workspace Manager] Error occurred during download and extraction: {e}")
|
|
||||||
|
|
||||||
def fetch_and_merge_main():
|
|
||||||
try:
|
|
||||||
# Fetch the latest changes from the remote
|
|
||||||
subprocess.run(["git", "fetch"], check=True)
|
|
||||||
# Checkout the local main branch
|
|
||||||
subprocess.run(["git", "checkout", "main"], check=True)
|
|
||||||
# Merge the remote main branch into the local main branch
|
|
||||||
subprocess.run(["git", "merge", "origin/main"], check=True)
|
|
||||||
print("[Workspace Manager] main branch updated successfully.")
|
|
||||||
|
|
||||||
except subprocess.CalledProcessError as e:
|
|
||||||
print(f"[Workspace Manager] An error occurred: {e}")
|
|
||||||
|
|
||||||
#main function
|
|
||||||
def update_version_if_outdated():
|
|
||||||
# URLs and file paths
|
|
||||||
repo_url = 'https://github.com/11cafe/comfyui-workspace-manager/archive/refs/heads/main.zip'
|
|
||||||
version_file_local =os.path.join(os.path.dirname(__file__),'version.txt')
|
|
||||||
version_file_remote = 'https://raw.githubusercontent.com/11cafe/comfyui-workspace-manager/main/version.txt'
|
|
||||||
|
|
||||||
# Check if update is needed
|
|
||||||
if is_update_needed(version_file_local, version_file_remote):
|
|
||||||
print("[Workspace Manager] Update is needed. Downloading latest version...")
|
|
||||||
fetch_and_merge_main()
|
|
||||||
return True
|
|
||||||
# download_and_extract_repo(repo_url, os.path.dirname(__file__))
|
|
||||||
return False
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user