Skip to content

Instantly share code, notes, and snippets.

@seanmtracey
Last active April 10, 2018 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanmtracey/fbecae40da3428ad5aa5a44af2a4a0b7 to your computer and use it in GitHub Desktop.
Save seanmtracey/fbecae40da3428ad5aa5a44af2a4a0b7 to your computer and use it in GitHub Desktop.

Web components to hook up client-side applications to Node-RED nodes in a standardised way.

Rationale

Node-RED is incredibly good at letting people prototype their ideas without a great deal of programming knowledge. However, the dashboard, whilst great connecting service A -> C via. B, it doesn't lend itself especially well to being hooked up to a custom application running on said server in quite the same way.

I believe Web Components could allow for more web apps to be built and integrated with Node-RED nodes as seemlessly as creating a flow is now, but with a greater ability to customise that JS/CSS/HTML afford up-and-coming developers.

How would this work?

  1. A developer would drop a node onto the canvas, just as they always have (say, for a camera), and give it a unique name.
  2. The developer would include a <script> tag in a web page they are delivering from the same Node-RED instance
  3. The developer would then add a node (in markup) that corresponds to the node that they dropped onto their canvas
  <!-- Something like... -->
  <node-red-camera data--nr-name="Unique name from step 1." data--nr-flags="video"></node-red-camera>
  1. These two nodes are now connected, and messages can pass between them.
  2. Each node has a GUI which will be rendered (with the shadow-DOM where possible) which corresponds to the actions of this node - and . For instance, the camera will have a capture still button, or start/stop video recording button.
  3. Once these buttons have been pressed, the captured data/media will be sent to the node on the Node-RED side, where it can be handled by any flow there

Benefits

  • More polished prototype apps can be built by those new to programming, but still have a basic command of HTML and CSS.
  • Complex things like handling Blob objects through a multipart form never have to be thought about again.
  • People can delight in seeing their application work in real-time in a web page they've partially built/designed.

Ideas for/Proposed Nodes

  1. An image node for capturing still images, and snippets of video.
  2. A file selector
  3. An audio capture node for recording sound
  4. An output node for the server to send data to a client from within a Node-RED flow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment