Skip to content

Commit

Permalink
Merge pull request #100 from DLHTX/flow
Browse files Browse the repository at this point in the history
  • Loading branch information
DLHTX authored Apr 13, 2023
2 parents 346695b + bc4f213 commit 648932f
Show file tree
Hide file tree
Showing 18 changed files with 60 additions and 502 deletions.
19 changes: 13 additions & 6 deletions src/components/DeveloperIDE/Flow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ReactFlow, { Background, Controls, MarkerType, NodeTypes } from 'reactflo
import { useStore } from '@/store/index';
import { generateNodeGroupMenu, generateReactFlowNode, NodeIcon, NodeMenuItem } from '@/components/FlowNode';
import 'reactflow/dist/style.css';
import { INodeType } from '@/server/nodes/types';
import { INodeType } from '@/lib/nodes/types';
import { helper } from '@/lib/helper';
import { FlowNode } from '@/store/standard/Node';
import { hooks } from '@/lib/hooks';
Expand All @@ -19,7 +19,7 @@ import { Flows, IndexDb } from '@/lib/dexie';
import { Box, Button, Collapse, Flex, Text } from '@chakra-ui/react';
import { getSelectedStyles } from '../ToolBar';
import { DeleteIcon } from '@chakra-ui/icons';
import { VscDebugStart } from 'react-icons/vsc';
import { VscDebugStart, VscDebugPause } from 'react-icons/vsc';

const MenuItemCollapse = ({ nodeMenuItem, addNode }: { nodeMenuItem: NodeMenuItem; addNode: (event: any, nodeInstance: INodeType) => void }) => {
// const { classes } = useStyles();
Expand Down Expand Up @@ -274,7 +274,7 @@ const Flow = observer(() => {
minZoom={0.5}
maxZoom={1.5}
onInit={flow.onInit}
nodes={flow.nodes.map((i) => ({ ...i, dragHandle:".drag-handle" }))}
nodes={flow.nodes.map((i) => ({ ...i, dragHandle: '.drag-handle' }))}
edges={flow.edges}
onNodesChange={flow.onNodesChange}
onEdgesChange={flow.onEdgesChange}
Expand Down Expand Up @@ -314,12 +314,19 @@ const Flow = observer(() => {
color: '#fff',
cursor: 'pointer'
}}
rightIcon={<VscDebugStart color="white" />}
// VscDebugPause
rightIcon={flow.curFlowRunning ? <VscDebugPause /> : <VscDebugStart />}
onClick={() => {
flow.executeFlow();
if (flow.curFlowRunning) {
flow.curFlowRunning = false;
return;
} else {
flow.curFlowRunning = true;
flow.executeFlow();
}
}}
>
Start
{flow.curFlowRunning ? 'Pause' : 'Start'}
</Button>
</Flex>
</>
Expand Down
2 changes: 1 addition & 1 deletion src/components/FlowNode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ImEqualizer } from 'react-icons/im';
import { Handle, NodeTypes, Position } from 'reactflow';
import { observer, useLocalObservable } from 'mobx-react-lite';
import { useStore } from '@/store/index';
import { INodeGroup, INodeIconType, INodeType } from '@/server/nodes/types';
import { INodeGroup, INodeIconType, INodeType } from '@/lib/nodes/types';
import { hooks } from '@/lib/hooks';
import { FlowNode } from '@/store/standard/Node';
import { Radar2 } from 'tabler-icons-react';
Expand Down
16 changes: 6 additions & 10 deletions src/components/JSONFormWidgets/RuntimeConsoleWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,12 @@ const RuntimeConsole = observer(({ label, required, value, readonly, onChange, o
return (
<Flex userSelect={'text'}>
<Flex color="#d892ff" mr={2} whiteSpace="nowrap">
[wasmvm
{/* {
<>
<Box color="#ffd300" ml={1}>
{dayjs(i?.['@ts']).format('hh:mm:ss')}
</Box>
</>
} */}
]
</Flex>{' '}
<>
<Box color="#ffd300" ml={1}>
{dayjs(i?.['@ts']).format('hh:mm:ss')}
</Box>
</>
</Flex>
<Flex wordBreak={'break-all'}>{JSON.stringify(i)}</Flex>
</Flex>
);
Expand Down
68 changes: 0 additions & 68 deletions src/components/JSONRender/WebhookSubmitWidget/index.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions src/components/JSONRender/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import React, { AllHTMLAttributes, useEffect } from 'react';
import { useLocalObservable, observer } from 'mobx-react-lite';
import { _ } from '@/lib/lodash';
import { extendObservable, makeAutoObservable, toJS } from 'mobx';
import { JSONForm } from '../JSONForm';
import WebhookSubmitWidget from './WebhookSubmitWidget';
import { helper } from '@/lib/helper';
import { Box } from '@chakra-ui/react';

// export let JSONRenderComponentsMap = {
// div: Box,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ return faker.helpers.multiple(createRandomUser, {
export const dataSimulationNodeSchema = {
type: 'object',
properties: {
triggerInterval: { type: 'number', title: 'Trigger Interval (Seconds)' },
code: { type: 'string', title: 'Code' }
},
required: ['id', 'code']
required: ['triggerInterval', 'code']
} as const;

export type dataSimulationNodeSchemaType = FromSchema<typeof dataSimulationNodeSchema>;
Expand Down Expand Up @@ -106,7 +107,8 @@ export class SimulationNode extends BaseNode {
}
},
value: {
code: ''
code: '',
triggerInterval: '2'
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/server/nodes/baseNode.ts → src/lib/nodes/baseNode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IFormType, INodeType, INodeTypeDescription } from './types';
import { v4 as uuid } from 'uuid';
import { FlowNode } from '../types';
import { FlowNode } from '../../server/types';
export const BaseNodeSettingSchema = {
type: 'object',
properties: {
Expand Down Expand Up @@ -53,4 +53,6 @@ export abstract class BaseNode implements INodeType {
const jsonForm = this.form.formList[formIndex]?.form?.find((item) => item.component === 'JSONForm');
jsonForm && (jsonForm.props.formState.value = value);
};


}
File renamed without changes.
16 changes: 0 additions & 16 deletions src/server/nodes/index.ts → src/lib/nodes/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { INodeType } from './types';
import { CodeNode } from './codeNode';
import { WebhookNode } from './webhookNode';
import { CarNode } from './Trigger/SmartCar';
import { RadarNode } from './Trigger/Radar';
import { SimulationNode } from './Trigger/SimulationNode';
import { WasmNode } from './Code/WasmNode';
import { VmRunTimeNode } from './Runtime/VmRunTimeNode';
Expand All @@ -12,21 +8,12 @@ export class NodeManager {
nodeClassMap: Record<string, any> = {};
nodesJSON: any[] = [];

// getNodeInstancesMap(): Record<string, INodeType> {
// if (!this.nodes.length) this.registerNode();
// return this.nodes.reduce((acc, cur) => {
// acc[cur.description.name] = cur;
// return acc;
// }, {});
// }

getClass(name: string) {
return this.nodeClassMap[name];
}

constructor() {
this.registerNode();
// console.log(this.nodes);
}

registerNode() {
Expand All @@ -42,9 +29,6 @@ export class NodeManager {
//@ts-ignore
this.nodes = Object.values(this.nodeClassMap).map((i) => new i());
this.nodesJSON = this.nodes.map((node) => node.toJSON());

// console.log(this.nodes);
// console.log('nodesJSON', this.nodesJSON);
return this.nodes;
}

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/pages/api/nodes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NextApiRequest, NextApiResponse } from 'next';
import { nodeManager } from '../../server/nodes/index';
import { nodeManager } from '../../lib/nodes/index';

const handler = (req: NextApiRequest, res: NextApiResponse) => {
try {
Expand Down
Loading

0 comments on commit 648932f

Please sign in to comment.