-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #317 from arayabrain/feature/microscope-node
implement microscope data reader nodes
- Loading branch information
Showing
28 changed files
with
265 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
frontend/src/components/Workspace/FlowChart/FlowChartNode/MicroscopeFileNode.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { memo } from "react" | ||
import { useSelector, useDispatch } from "react-redux" | ||
import { Handle, Position, NodeProps } from "reactflow" | ||
|
||
import { FileSelect } from "components/Workspace/FlowChart/FlowChartNode/FileSelect" | ||
import { | ||
toHandleId, | ||
isValidConnection, | ||
} from "components/Workspace/FlowChart/FlowChartNode/FlowChartUtils" | ||
import { useHandleColor } from "components/Workspace/FlowChart/FlowChartNode/HandleColorHook" | ||
import { NodeContainer } from "components/Workspace/FlowChart/FlowChartNode/NodeContainer" | ||
import { HANDLE_STYLE } from "const/flowchart" | ||
import { deleteFlowNodeById } from "store/slice/FlowElement/FlowElementSlice" | ||
import { setInputNodeFilePath } from "store/slice/InputNode/InputNodeActions" | ||
import { | ||
selectMicroscopeInputNodeSelectedFilePath, | ||
selectInputNodeDefined, | ||
} from "store/slice/InputNode/InputNodeSelectors" | ||
import { FILE_TYPE_SET } from "store/slice/InputNode/InputNodeType" | ||
|
||
export const MicroscopeFileNode = memo(function MicroscopeFileNode( | ||
element: NodeProps, | ||
) { | ||
const defined = useSelector(selectInputNodeDefined(element.id)) | ||
if (defined) { | ||
return <MicroscopeFileNodeImple {...element} /> | ||
} else { | ||
return null | ||
} | ||
}) | ||
|
||
const MicroscopeFileNodeImple = memo(function MicroscopeFileNodeImple({ | ||
id: nodeId, | ||
selected: elementSelected, | ||
}: NodeProps) { | ||
const dispatch = useDispatch() | ||
const filePath = useSelector( | ||
selectMicroscopeInputNodeSelectedFilePath(nodeId), | ||
) | ||
const onChangeFilePath = (path: string) => { | ||
dispatch(setInputNodeFilePath({ nodeId, filePath: path })) | ||
} | ||
|
||
const returnType = "MicroscopeData" | ||
const microscopeColor = useHandleColor(returnType) | ||
|
||
const onClickDeleteIcon = () => { | ||
dispatch(deleteFlowNodeById(nodeId)) | ||
} | ||
|
||
return ( | ||
<NodeContainer nodeId={nodeId} selected={elementSelected}> | ||
<button | ||
className="flowbutton" | ||
onClick={onClickDeleteIcon} | ||
style={{ color: "black", position: "absolute", top: -10, right: 10 }} | ||
> | ||
× | ||
</button> | ||
<FileSelect | ||
nodeId={nodeId} | ||
onChangeFilePath={(path) => { | ||
if (!Array.isArray(path)) { | ||
onChangeFilePath(path) | ||
} | ||
}} | ||
fileType={FILE_TYPE_SET.MICROSCOPE} | ||
filePath={filePath ?? ""} | ||
/> | ||
<Handle | ||
type="source" | ||
position={Position.Right} | ||
id={toHandleId(nodeId, "microscope", returnType)} | ||
style={{ | ||
...HANDLE_STYLE, | ||
background: microscopeColor, | ||
}} | ||
isValidConnection={isValidConnection} | ||
/> | ||
</NodeContainer> | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.