From 97b5751d2a53d440b5f5747602a32dad29763659 Mon Sep 17 00:00:00 2001 From: Ross Leitch Date: Mon, 11 Sep 2023 19:42:48 +1200 Subject: [PATCH 1/2] Lambdas --- package.json | 13 ++++--------- .../command-electrical-editor/src/panes/pages.tsx | 6 +++--- packages/core/command-schematic-export/src/index.ts | 7 ++++++- .../infrastructure/main/src/export-lambda/index.ts | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 0bb90812a..82ce27a8d 100644 --- a/package.json +++ b/package.json @@ -4,14 +4,9 @@ "description": "", "main": "index.js", "private": true, - "workspaces": { - "packages": [ - "packages/**/*" - ], - "nohoist": [ - "packages/lambdas/**" - ] - }, + "workspaces": [ + "packages/**/*" + ], "repository": { "type": "git", "url": "git+https://github.com/TheTechCompany/HiveCommandClient.git" @@ -59,4 +54,4 @@ "@types/react": "17.0.2" }, "packageManager": "yarn@3.6.0" -} +} \ No newline at end of file diff --git a/packages/core-ui/command-electrical-editor/src/panes/pages.tsx b/packages/core-ui/command-electrical-editor/src/panes/pages.tsx index bc92a59ea..567772da5 100644 --- a/packages/core-ui/command-electrical-editor/src/panes/pages.tsx +++ b/packages/core-ui/command-electrical-editor/src/panes/pages.tsx @@ -79,8 +79,8 @@ export const PagesPane = (props: any) => { }} /> - - + + Pages @@ -89,7 +89,7 @@ export const PagesPane = (props: any) => { - + {pages?.slice()?.sort((a,b) => (a.rank || '').localeCompare(b.rank || ''))?.map((page) => ( diff --git a/packages/core/command-schematic-export/src/index.ts b/packages/core/command-schematic-export/src/index.ts index f053b50b7..7d2d37993 100644 --- a/packages/core/command-schematic-export/src/index.ts +++ b/packages/core/command-schematic-export/src/index.ts @@ -3,6 +3,7 @@ import path from 'path'; import express from 'express'; import { PDFDocument } from 'pdf-lib'; import { writeFileSync } from 'fs'; +import chromium from 'chrome-aws-lambda'; const html_index = require.resolve('@hive-command/export-page'); @@ -29,7 +30,11 @@ export const export_schematic = async (schematic: {pages: any[]}) => { if(typeof(address) != 'string'){ - const browser = await puppeteer.launch({headless: false}); + const browser = await puppeteer.launch({ + args: chromium.args, + headless: chromium.headless, + executablePath: await chromium.executablePath + }); const page = await browser.newPage(); diff --git a/packages/infrastructure/main/src/export-lambda/index.ts b/packages/infrastructure/main/src/export-lambda/index.ts index f4563822b..32f196013 100644 --- a/packages/infrastructure/main/src/export-lambda/index.ts +++ b/packages/infrastructure/main/src/export-lambda/index.ts @@ -22,14 +22,14 @@ export const ExportLambda = () => { const lambda = archive.getFile({ type: "zip", - sourceDir: path.join(__dirname, "/../../../lambdas/export-schematic/"), + sourceDir: path.join(__dirname, "/../../../../lambdas/export-schematic/"), outputPath: "lambda_function_payload.zip", }); const fn = new Function(`hivecommand-export-schematic-fn`, { code: new pulumi.asset.FileArchive("lambda_function_payload.zip"), role: iamForLambda.arn, - handler: "index.test", + handler: "index.handler", runtime: "nodejs18.x" }) From 9f691505259b619276c1e6585809054bbb4c5700 Mon Sep 17 00:00:00 2001 From: Ross Leitch Date: Mon, 11 Sep 2023 19:50:00 +1200 Subject: [PATCH 2/2] Function editor --- .../src/views/function-editor/index.tsx | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/packages/app/hivecommand-frontend/src/views/function-editor/index.tsx b/packages/app/hivecommand-frontend/src/views/function-editor/index.tsx index 9977ef9f0..437175d8d 100644 --- a/packages/app/hivecommand-frontend/src/views/function-editor/index.tsx +++ b/packages/app/hivecommand-frontend/src/views/function-editor/index.tsx @@ -34,6 +34,11 @@ export const FunctionEditor = () => { id } + children { + id + name + label + } rank } @@ -66,8 +71,8 @@ export const FunctionEditor = () => { }) - -const [ editingPage, setEditingPage ] = useState(null); + + const [ editingPage, setEditingPage ] = useState(null); const [ value, setValue ] = useState(''); @@ -76,6 +81,25 @@ const [ editingPage, setEditingPage ] = useState(null); const [ nodes, setNodes, onNodesChange ] = useNodesState([]); const [ edges, setEdges, onEdgesChange] = useEdgesState([]); + useEffect(() => { + setNodes(editingPage?.children?.map((x, ix) => ({ + id: x?.id, + label: x?.name, + position: { + x: 50, + y: ix * 50 + }, + data: { + label: x?.name + // label: node.label, + // width: node.width, + // height: node.height + } + }))) + setEdges(editingPage?.children?.map((x, ix) => ({id: x?.id, source: x?.id, target: editingPage?.children?.[ix + 1]?.id}))) + + }, [editingPage]) + useEffect(() => { const g = new dagre.graphlib.Graph()