Skip to content

Commit 6a5d5f9

Browse files
committed
Build commands, first run seeding, default flow on workspace create bug fix, subflow cascade delete, static and dynamic route updates, handle source/target feature, Info panel in top right corner for deleting edges/nodes
1 parent 189b33a commit 6a5d5f9

File tree

16 files changed

+314
-81
lines changed

16 files changed

+314
-81
lines changed

.vscode/tasks.json

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,46 @@
44
"version": "2.0.0",
55
"tasks": [
66
{
7-
"label": "Build Windows Executable",
7+
"label": "Build App",
88
"type": "shell",
9-
"command": "pyinstaller",
9+
"dependsOn": [
10+
"Build React App",
11+
"Build Python App"
12+
],
13+
"dependsOrder": "sequence",
14+
"command": "xcopy",
15+
"args": [
16+
"/E",
17+
"/I",
18+
"server\\gql",
19+
"dist\\gql",
20+
"/y",
21+
"&&",
22+
"copy",
23+
"desktop\\splash.html",
24+
"dist",
25+
"/y",
26+
"&&",
27+
"mkdir",
28+
"dist\\data",
29+
],
30+
"problemMatcher": []
31+
},
32+
{
33+
"label": "Build Python App",
34+
"type": "shell",
35+
"command": ".venv\\Scripts\\activate.bat && pyinstaller",
1036
"args": [
1137
"--onefile",
1238
"--noconsole",
1339
"--icon=favicon.ico",
40+
// "flow.py",
1441
"flow.pyw"
1542
],
1643
"problemMatcher": []
1744
},
1845
{
19-
"label": "Build React APP",
46+
"label": "Build React App",
2047
"type": "shell",
2148
"command": "npm",
2249
"args": [

desktop/gui.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import os
12
import time
23
import webview
4+
import pickle as pk
35
from threading import Thread
46

7+
from server.db import seed_types
58
from server.server import run_app
69

710

@@ -10,13 +13,29 @@ def splash_close(window):
1013
server = Thread(target=run_app, daemon=True)
1114
server.start()
1215

16+
# Seed the database with node and edge types on first run
17+
if (os.path.exists('settings.p')):
18+
settings = pk.load(open('settings.p', 'rb'))
19+
20+
if not settings.get('seed_db', False):
21+
seed_types.seed()
22+
settings['seed_db'] = True
23+
pk.dump(settings, open('settings.p', 'wb'))
24+
25+
else:
26+
seed_types.seed()
27+
pk.dump({'seed_db': True}, open('settings.p', 'wb'))
28+
1329
# Close splash screen
1430
time.sleep(7)
1531
window.destroy()
1632

1733

1834
# Create splash screen
19-
splash_screen = webview.create_window('Flow Control', html=(open('splash.html', 'r').read()), frameless=True, width=480, height=307)
35+
if os.path.exists('splash.html'):
36+
splash_screen = webview.create_window('Flow Control', html=(open('splash.html', 'r').read()), frameless=True, width=480, height=307)
37+
else:
38+
splash_screen = webview.create_window('Flow Control', html=(open('desktop\splash.html', 'r').read()), frameless=True, width=480, height=307)
2039
webview.start(splash_close, (splash_screen,), http_server=False)
2140

2241
# Open main window

desktop/splash.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

server/resolvers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def createWorkspace(_, info, **kwargs):
4444
# Create the default main flow for the workspace
4545
flow = Flow(name='Main', workspace=workspace, description='The main flow for this workspace.', default=True)
4646
session.add(flow)
47-
workspace.default = flow
47+
workspace.default_flow_id = flow.id
4848
session.commit()
4949

5050
# Return the new workspace
@@ -166,6 +166,11 @@ def updateNode(_, info, **kwargs):
166166
def deleteNode(_, info, **kwargs):
167167
node = session.query(Node).filter_by(nid=kwargs.get('nid')).first()
168168
session.delete(node)
169+
170+
if node.node_type.slug == 'subflow':
171+
flow = session.query(Flow).filter_by(slug=loads(node.node)['data']['slug'], workspace_id=node.workspace_id).first()
172+
session.delete(flow)
173+
169174
session.commit()
170175
return {'node': node}
171176

server/server.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@
7878
mutation.set_field("deleteEdge", deleteEdge)
7979

8080

81+
# Web App initialization
82+
app = web.Application()
83+
8184
# Build schema
8285
if os.path.exists('assets'):
8386
type_defs = gql(load_schema_from_path("gql/"))
@@ -127,27 +130,24 @@ async def graphql_api_options(_: web.Request) -> web.Response:
127130
# headers={key: value for key, value in response.headers.items()},
128131
# )
129132

133+
if os.path.exists('assets'):
134+
app.add_routes([web.static('/assets', './assets')])
135+
routes.static('/assets', './assets')
136+
else:
137+
app.add_routes([web.static('/assets', 'dist/assets')])
138+
routes.static('/assets', 'dist/assets')
139+
130140
# Server index.html file
131-
@routes.get('/')
141+
@routes.route('*', "/{tail:.*}")
132142
async def index(request: web.Request):
143+
print('Received request')
133144
if os.path.exists('assets'):
134145
return web.FileResponse('index.html')
135146
else:
136147
return web.FileResponse('dist/index.html')
137148

138-
# Web App initialization
139-
app = web.Application()
140149
app.add_routes(routes)
141150

142-
if os.path.exists('assets'):
143-
print('Using assets static path')
144-
app.add_routes([web.static('/', './')])
145-
routes.static('/', './')
146-
else:
147-
print('Using dist static path')
148-
app.add_routes([web.static('/', 'dist')])
149-
routes.static('/', 'dist')
150-
151151
def run_app():
152152
logging.basicConfig(level=logging.DEBUG)
153153
loop = asyncio.new_event_loop()

src/custom/card.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ function CardNode({ data, selected }: { data: any, selected: any }) {
2121
</div>
2222
<Handle type="target" position={Position.Top} id="a" />
2323
<Handle type="source" position={Position.Bottom} id="b" />
24+
<Handle type="source" position={Position.Top} id="c" />
25+
<Handle type="target" position={Position.Bottom} id="d" />
2426
</div>
2527
</>
2628
);

src/custom/default.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ function Default({ data, selected }: { data: any, selected: any }) {
1616
{data.label}
1717
<Handle type="target" position={Position.Top} id="a" />
1818
<Handle type="source" position={Position.Bottom} id="b" />
19+
<Handle type="source" position={Position.Top} id="c" />
20+
<Handle type="target" position={Position.Bottom} id="d" />
1921
</div>
2022
</>
2123
);

src/custom/input.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function Input({ data, selected }: { data: any, selected: any }) {
1515
<div className="source-node">
1616
{data.label}
1717
<Handle type="source" position={Position.Bottom} id="a" />
18+
<Handle type="target" position={Position.Bottom} id="b" />
1819
</div>
1920
</>
2021
);

src/custom/output.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function Output({ data, selected }: { data: any, selected: any }) {
1515
<div className="source-node">
1616
{data.label}
1717
<Handle type="target" position={Position.Top} id="a" />
18+
<Handle type="source" position={Position.Top} id="b" />
1819
</div>
1920
</>
2021
);

src/custom/subflow.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ function SubFlowNode({ data, selected }: { data: any, selected: any }) {
3939
</div>
4040
<Handle type="target" position={Position.Top} id="a" />
4141
<Handle type="source" position={Position.Bottom} id="b" />
42+
<Handle type="source" position={Position.Top} id="c" />
43+
<Handle type="target" position={Position.Bottom} id="d" />
4244
</div>
4345
</>
4446
);

0 commit comments

Comments
 (0)