Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate GUI to Typescript + React + ES6 #143

Open
wants to merge 6 commits into
base: test
Choose a base branch
from
Open

Conversation

zls29
Copy link
Collaborator

@zls29 zls29 commented Mar 5, 2017

📖 Summary

Migrating the GUI to Typescript + React + ES6.

🔍 Details

To use more modern design practices, the GUI is being migrated to a component based architecture (via React).

Typescript is being used to create tighter contracts with the backend, hopefully reducing the likelihood of changes to server dto's silently breaking the GUI.

ES6 is being used to get some nice modern features (arrow syntax)...

Some modifications to the initial design were made (see the third commit) for the sake of performance. They were necessary to avoid rendering the entire component tree with every status message (several times per second).

Installation/Setup

cd public/flightControl
npm install

✔️ Testing

  • Simulate
    • All drones
    • Only 1 nonzero drone
  • Real Life
    • All drones
    • Only 1 nonzero drone

✔️ Verification

  • Checked for memory leaks

<link async rel="stylesheet" href="/node_modules/roboto-fontface/css/roboto/roboto-fontface.css">
<link async rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
<link async rel="stylesheet" href="node_modules/material-design-lite/material.min.css">
<link async rel="stylesheet" href="node_modules/bootstrap-material-design/dist/css/ripples.min.css">
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmz38 I was getting a failure in loading styles related to this:
screen shot 2017-03-04 at 11 26 31 pm

Not really breaking anything, I can look at fixing it later.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this and the style other style issues.

@@ -12,6 +12,14 @@ export class Button extends React.Component<ButtonProps, undefined> {
super(props);
}

public shouldComponentUpdate(nextProps: ButtonProps): boolean {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are to avoid unnecessary re-rendering of large chunks of the DOM.

Makefile Outdated
@@ -7,7 +7,8 @@ build: build_socketio_cpp
git submodule update --init --recursive
mkdir -p build
rm -f config/gazebo/models/x340/x340.sdf
cd build; cmake ..; make
cd build; cmake ..; make;
cd public/flightControl; webpack;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ./node_modules/.bin/webpack to avoid having to install it globally

@@ -28,13 +28,13 @@ void messaging_init() {
}


void send_message(const json &msg) {
void send_message(const string type, const json &msg) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this better? Having this seems to just add more redundant code to node/socket.js

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this was more desirable than defining listeners for a generic msg type and relying on the json for a specific type, but I can do it that way if you prefer.

src/gcs.cpp Outdated
jsonPosition.push_back(vehicles[i]->state.position.y());
jsonPosition.push_back(vehicles[i]->state.position.z());
jsonVehicle["position"] = jsonPosition;
jsonVehicle["position"] = {
Copy link
Owner

@dennisss dennisss Mar 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any benefit in this change? Sending vectors as 3-tuples is pretty standard. (Changing it for the purpose of typescript is not a good reason)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, I'll put it back to the way it was (we aren't using the data at the moment anyway).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was using it on my branch for the viewer for wanted to avoid conflicts

value: string
}

export class FileSelector extends React.Component<FileSelectProps, FileSelectState> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO if the react component doesn't really do anything but wrap an input, you probably don't need an extra component. But, either way, this component does not need to have it's own state. Use getDefaultProps instead. Having the state also prevents validation by the parent.

…steners when components are unbound, and other CR feedback.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants