-
Notifications
You must be signed in to change notification settings - Fork 47
Fzchriha/labgraph UI #71
Changes from all commits
1a2af23
41cd833
fd8200f
f1d55ed
12256a4
2aaaa05
ab92ab0
8751c80
330c763
820f365
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ This extension is an interactive visualization tool to monitor and make real-tim | |
| **Prerequisites**: | ||
|
|
||
| - [Node.js](https://nodejs.org/en/) | ||
| - [Yarn](https://classic.yarnpkg.com/lang/en/docs/install) | ||
| - [Yarn](https://classic.yarnpkg.com/lang/en/docs/install) (**RECOMMENDED**) | ||
|
|
||
| Check that node and yarn were properly installed by running the following commands | ||
|
|
||
|
|
@@ -21,28 +21,31 @@ yarn -v | |
|
|
||
| **Set up the application** | ||
|
|
||
| (!) The following tutorial utilizes **yarn** (recommended) however **npm** can be utilized as well. | ||
|
|
||
| 1. Be sure that you are inside **extensions/prototypes/labgraph_monitor** directory | ||
|
|
||
| ``` | ||
| cd extensions/prototypes/labgraph_monitor | ||
| labgraph> cd extensions/prototypes/labgraph_monitor | ||
| labgraph\extensions\prototypes\labgraph_monitor> | ||
| ``` | ||
|
|
||
| 2. Install dependencies by running **yarn** command | ||
|
|
||
| ``` | ||
| yarn | ||
| labgraph\extensions\prototypes\labgraph_monitor> yarn | ||
| ``` | ||
|
|
||
| 3. Test the application by running the following command | ||
|
|
||
| ``` | ||
| yarn test --watchAll=false | ||
| labgraph\extensions\prototypes\labgraph_monitor> yarn test --watchAll=false | ||
| ``` | ||
|
|
||
| 4. Run the application | ||
|
|
||
| ``` | ||
| yarn start | ||
| labgraph\extensions\prototypes\labgraph_monitor> yarn start | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An empty UI has launched after running this line.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ``` | ||
|
|
||
| (!) The application will be running on **localhost:3000** by default | ||
|
|
@@ -71,7 +74,8 @@ REACT_APP_WS_API="ws://127.0.0.1:9000" | |
|
|
||
| (!) LabGraph Websocket server runs on localhost:9000 by default | ||
|
|
||
| 2. Run Labgraph Websockets server. The following tutorial shows how to run LabGraph Websocket server properly : [tutorial](https://github.com/facebookresearch/labgraph/pull/58/files#diff-247005c77570899ce53f81a83b2a5fe6e7535616cc96564d67378fe7f73dac49) | ||
| 2. Run Labgraph Websockets server. | ||
| `python3 extensions/yaml_support/labgraph_monitor/examples/labgraph_monitor_example.py` | ||
|
|
||
| 3. Under LabGraph Monitor settings panel click on REALTIME option and click connect. | ||
|
|
||
|
|
@@ -82,7 +86,7 @@ To see the information related to a specific node or edge, just click on it, the | |
| <table> | ||
| <tr> | ||
| <td>Node</td> | ||
| <td>Edge</td> | ||
| <td>edge</td> | ||
| </tr> | ||
| <tr> | ||
| <td><img src="https://i.ibb.co/MnB045Z/node-frame.png"></td> | ||
|
|
@@ -93,3 +97,19 @@ To see the information related to a specific node or edge, just click on it, the | |
| **Nodes** : currently when a node is clicked its name will be displayed, However, this feature will be updated in the future to include more information. | ||
|
|
||
| **Edges** : currently when an edge is clicked the "message_name", "message_fields" and "fields_datatypes" will be displayed, However, this feature will be updated in the future to include more information (E.g: the field value in realtime). | ||
|
|
||
| ## Architecture Overview | ||
|
|
||
| This is a bird's-eye view of the architecture of Labgraph Monitor. | ||
|
|
||
| <image src="https://i.ibb.co/chtfM5R/lg-Architecture.png" width="500px" alt="labgraph monitor's architecture overview"/> | ||
|
|
||
| This web application is composed of multiple components (redux, pages, mocks, contextx, and components) below is the overview diagram for each: | ||
|
|
||
| ### Redux diagram: | ||
|
|
||
| <image src="https://i.ibb.co/LznCmt7/redux-Diagram.png" width="500px" alt=""/> | ||
|
|
||
| ### Redux & Edge Settings | ||
|
|
||
| <image src="https://i.ibb.co/0qGRLr0/edge-redux.png" width="500px" alt=""/> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,16 +12,19 @@ import { | |
| SettingsApplicationsRounded, | ||
| AlignHorizontalLeftOutlined, | ||
| AlignVerticalTopOutlined, | ||
| Mode, | ||
| } from '@mui/icons-material'; | ||
| import React, { useCallback } from 'react'; | ||
| import SettingTabs from './SettingTabs'; | ||
| import { makeStyles } from '@mui/styles'; | ||
| import { useUIContext } from '../../contexts'; | ||
| import { RootState } from '../../redux/store'; | ||
| import { useSelector, useDispatch } from 'react-redux'; | ||
| import { setPanel } from '../../redux/reducers/config/configReducer'; | ||
|
|
||
| const PANEL_WIDTH = 280; | ||
|
|
||
| export const DEFAULT_PANEL_WIDTH = 280; | ||
| export const MIN_PANEL_WIDTH = 280; | ||
| export const MAX_PANEL_WIDTH = 600; | ||
| const useStyles = makeStyles({ | ||
| root: { | ||
| display: 'flex', | ||
|
|
@@ -41,10 +44,10 @@ const useStyles = makeStyles({ | |
| }, | ||
|
|
||
| settingPanel: { | ||
| width: PANEL_WIDTH, | ||
| width: DEFAULT_PANEL_WIDTH, | ||
| flexShrink: 0, | ||
| '& .MuiDrawer-paper': { | ||
| width: PANEL_WIDTH, | ||
| width: DEFAULT_PANEL_WIDTH, | ||
| }, | ||
| }, | ||
|
|
||
|
|
@@ -55,6 +58,30 @@ const useStyles = makeStyles({ | |
| alignItem: 'center', | ||
| padding: '2px 4px 2px 4px', | ||
| }, | ||
| dragger_light: { | ||
| width: '5px', | ||
| cursor: 'ew-resize', | ||
| padding: '4px 0 0', | ||
| borderTop: '1px solid #ddd', | ||
| position: 'absolute', | ||
| top: 0, | ||
| left: 0, | ||
| bottom: 0, | ||
| zIndex: '100', | ||
| backgroundColor: '#f4f7f9', | ||
| }, | ||
| dragger_dark: { | ||
| width: '5px', | ||
| cursor: 'ew-resize', | ||
| padding: '4px 0 0', | ||
| borderTop: '1px solid #111827', | ||
| position: 'absolute', | ||
| top: 0, | ||
| left: 0, | ||
| bottom: 0, | ||
| zIndex: '100', | ||
| backgroundColor: '#1f2b3c', | ||
| }, | ||
| }); | ||
|
|
||
| /** | ||
|
|
@@ -68,7 +95,22 @@ const SettingPanel: React.FC = (): JSX.Element => { | |
| const { mode, layout, toggleMode, toggleLayout } = useUIContext(); | ||
| const { panelOpen } = useSelector((state: RootState) => state.config); | ||
| const dispatch = useDispatch(); | ||
|
|
||
| const [panelWidth, setPanelWidth] = React.useState(DEFAULT_PANEL_WIDTH); | ||
| const handleMouseDown = () => { | ||
| document.addEventListener('mouseup', handleMouseUp, true); | ||
| document.addEventListener('mousemove', handleMouseMove, true); | ||
| }; | ||
| const handleMouseUp = () => { | ||
| document.removeEventListener('mouseup', handleMouseUp, true); | ||
|
Comment on lines
+103
to
+104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit confused on what's going on here. The function is The |
||
| document.removeEventListener('mousemove', handleMouseMove, true); | ||
| }; | ||
| const handleMouseMove = useCallback((e) => { | ||
| const newWidth = | ||
| document.body.offsetLeft + document.body.offsetWidth - e.clientX; | ||
| if (newWidth > MIN_PANEL_WIDTH && newWidth < MAX_PANEL_WIDTH) { | ||
| setPanelWidth(newWidth); | ||
| } | ||
| }, []); | ||
| return ( | ||
| <Box className={classes.root} data-testid="setting-panel"> | ||
| <CssBaseline /> | ||
|
|
@@ -96,6 +138,7 @@ const SettingPanel: React.FC = (): JSX.Element => { | |
| className={classes.settingPanel} | ||
| variant="persistent" | ||
| anchor="right" | ||
| PaperProps={{ style: { width: panelWidth } }} | ||
| open={panelOpen} | ||
| > | ||
| <Box> | ||
|
|
@@ -106,6 +149,17 @@ const SettingPanel: React.FC = (): JSX.Element => { | |
| <ChevronRight /> | ||
| </IconButton> | ||
| </Box> | ||
|
|
||
| <div | ||
| id="dragger" | ||
| onMouseDown={() => handleMouseDown()} | ||
| className={ | ||
| mode === 'light' | ||
| ? classes.dragger_light | ||
| : classes.dragger_dark | ||
| } | ||
| /> | ||
|
|
||
| <Divider /> | ||
| <Box className={classes.themeBar}> | ||
| <IconButton | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.