Please Note that v2.0.0 includes breaking changes from v1, please see the CHANGELOG for details.
A Node-RED web user interface builder. UIbuilder Aims to Provide an easy to use way to create dynamic web interfaces using any (or no) front end libraries for convenience.
The key features and benefits are:
- Designed as an alternative to the Node-RED official Dashboard. Without the overheads and restrictions.
- Control everything from the Node-RED admin ui. Edit your front-end resource files, manage front-end packages. No need to access the servers command line.
- Installs VueJS and bootstrap-vue by default giving you a very easy start with minimal boiler-plate.
- Have as many custom user interfaces as you want. Just 1 node is needed for each entry point. Use link nodes to send data from other parts of your flows.
- Has a control interface separate to the message interface. Know when a browser connects or disconnects, send cached data.
- Much lighter in weight and more mobile friendly than the Node-RED official Dashboard (assuming you don't use Angular as your framework).
- Finds these front-end framework packages automatically and makes them available: vue, bootstrap, bootstrap-vue, jquery, moonjs, reactjs, riot, angular, picnic,umbrellajs (note this list may expand).
- Use any front-end framework you like. Tested with at least JQuery, VueJS, MoonJS, REACT, UmbrellaJS and Riot.
- Use without any front-end framework if you like. Keep it light and simple.
- The included front-end library provides connectivity to Node-RED and msg event handling.
- Write your own HTML, CSS and JavaScript to define the perfect front-end user interface for your needs.
- Edit your custom front-end code from within the Node-RED Editor, little to no need for access to the server's filing system.
- Needs almost no boilerplate in your front-end code in order to work.
- Simple included example works out-of-the-box, no need to install anything other than the node.
- VueJS, MoonJS extended and caching example flows included.
- Optional index web page listing of available files.
Current limitations are:
- You have to write your own HTML, uibuilder doesn't (yet) do it for you. This is by design. I hope to have a component design available at some point which will give additional options and make the UI building easier.
- You have to know the front-end library locations for installed libraries and edit your HTML accordingly. The
uibindex
admin API (accessible from any node's admin ui) shows you all of the root folders and what the package authors report as the main entry point for all active packages. - You cannot yet compile/compress your custom front-end code (HMTL, JS, SCSS, etc.) for efficiency. This will be added soon.
- You cannot yet edit source files in sub-folders. This will be added soon.
uibuilder is rather the opposite of Node-RED's Dashboard. Whereas that is designed to make it very easy to create a UI but trades that off with some limitations, this is designed to let you do anything you can think of with any framework but at the trade off of having to write your own front-end code. This node should also be a lot faster and more resource efficient in use than Dashboard though that obviously depends on what front-end libraries and frameworks you choose to use.
- node-red-contrib-uibuilder
There is a lot more information available in the WIKI.
To install the current live version, please use Node-RED's Palette Manager.
To install a specific development or test branch from GitHub, use npm install TotallyInformation/node-red-contrib-uibuilder#<BRANCH-NAME> --save
from the command line on the server, having first changed to the userDir
folder (normally ~/.node-red
).
To install a specific release from npm, use npm install node-red-contrib-uibuilder@<VERSION>
. In addition to release versions (e.g. 1.2.2), you can also use latest
and v1-last
. Sometimes, next
may also be available. Check out the Versions tab on the npm site for available versions.
NOTE: When installing v2.x, you may get a warning from the install:
npm WARN bootstrap@4.3.1 requires a peer of jquery@1.9.1 - 3 but none is installed. You must install peer dependencies yourself
It is safe to ignore that warning unless you want to take control of bootstrap yourself since vue-bootstrap doesn't actually need it.
Once installed, add a simple flow consisting of a trigger, a uibuilder and a debug node all connected in order. Deploy the changes then double click on the uibuilder node, click on the web page url.
That will show you a simple page that makes use of VueJS and bootstrap-vue. It shows the messages being sent and recieved and has a button that inrements a counter while sending the updated count back to Node-RED.
From the node's configuration panel in the Editor, click on "Edit Source Files" to see the front-end code. Make some changes to see what happens.
If you need more space for the editor, click on the ⤡ button underneath the text editor. To get back, press the same button (which is now highlighted) or the Esc key.
Click on the Save button to save changes, Reset to revert to the saved file, Close to exit the editor. Note that the close button isn't available while there are outstanding changes, press Save or Reset first. The Editor's red Done button is also disabled while there are still outstanding changes.
You can create a new file and delete files as well with the appropriate buttons. If you delete one of the default index.(html|css|js)
files and have the Copy Index flag set (in advanced settings), the file will be replaced automatically with the default template file. Useful if you get into a complete mess.
The default included VueJS, bootstrap and bootstrap-vue packages make for a really easy to use initial setup that is very easy to use but powerful to build any kind of web user interface. The default template files should give you some ideas on how to use everything.
If the default VueJS, bootstrap and bootstrap-vue libraries are either not enough for you or you want to use a different framework, click the "Manage front-end libraries" button. Then click the + add button and type in the name of the package as it is defined in npm.
You can also remove installed libraries from here.
The uibuilder Detailed Information API page (link in the configuration panel) shows details of all packages installed, their URL for your html pages and their physical location on the server (so that you can track down the right file to include in your HTML).
Check out the WIKI for more information, help and examples.
In addition to various examples, the WIKI includes:
- v2 URL Paths
- v2 Breaking Changes
- Structure & type of control messages
- Front-end library available properties & methods
- How to cache and replay messages
- Creating pages in sub-folders
- Getting Started with VueJS
-
A single node is used to define an end-point (by its URL path). The node can be included in flows as many times as you like - but each instance must have a unique URL path name.
-
Each node instance gets its own Socket.IO namespace matching the URL path setting. Note that Socket.IO will efficiently share sockets while keeping traffic separated by namespace.
-
There is a front-end library
uibuilderfe.min.js
oruibuilderfe.js
that hides all the complexities of using Socket.IO so that your own FE code is easy to write. It provides a simple event handling system so that you can subscribe to changes and process them as they happen. The defaultindex.js
file has details and examples of use. The library is written so that it can be sourced via html or included via a build step (e.g. webpack).Handling incoming messages from Node-RED is as simple as:
uibuilder.onChange('msg', function(newVal){ console.info('[uibuilder.onChange] property msg changed!', newVal) })
Sending a message back to Node-RED is a simple as:
uibuilder.send( { 'topic': 'from-the-front', 'payload': 42 } )
-
npm packages can be installed (or removed or updated) using the node's admin ui in Node-RED. This allows you to manage the availability of front-end libraries very easily. No need to have access to the servers command line. Any front-end library that is available as an npm package can be managed this way. Installed packages will be made available to your web app.
-
The node's module contains default html, JavaScript and CSS master template files that are copied to your local src folder for you to edit as required. This can be turned off via a flag. It gives you a simple to follow template that kick-starts your web app development.
-
Messages sent from Node-RED to your web app can have a
msg.script
andmsg.style
property that will dynamically add that code to the web page - if allowed by the settings (default is off). -
Including a
_socketId
attribute on messages sent from Node-RED will send to that ID only.Note that an ID is associated with a specific browser tab and is reset when the page is reloaded.
The
_socketId
attribute is added to any msg sent from the client to Node-RED. See the WIKI for more information. -
A second output port gives access to some control messages.
This allows additional processing when a client connects or disconnects, an instance is (re)deployed or there is a socket error.
A common use for this is to send cached information back to a newly connected client (or one that has had the page reloaded).
Other uses could include outputing some standard information when a new client connects. Or you could use the information to keep utilisation metrics. See the Control Message Structure page in the WIKI for details.
-
On deployment of the first instance of uibuilder, a new folder is created within your Node-RED user directory (typically
~/.node-red
) with a fixed name ofuibuilder
.If you are using Node-RED's projects feature, the folder will be created within your project folder instead.
-
On deployment of any new instance, a new sub-folder within
uibuilder
is created.The name is the same as the URL path specified in the node instance's settings. (defaults to
uibuilder
).src
anddist
sub-folders are also created. Theurl
name is limited to a maximum of 20 characters and cannot betemplates
as this is reserved.The files in these folders can be edited from within the node's configuration panel in Node-RED's Editor. No need for command line or other file access on the server.
-
If the local
dist
folder contains anindex.html
file, thedist
folder will be served, otherwise thesrc
folder will be served. This allows you to run a build step (e.g. webpack/babel). The WIKI has instructions on how to do a build step. -
Any resource (html, css, js, image, etc) placed within the
dist
/src
sub-folder is available to the browser client. The default URL would behttp://localhost:1880/uibuilder
(where the path is set as per the point above). That URL will loadindex.html
. Resource URL's take thehttpNodeRoot
Node-RED setting into account. -
An additional "common" folder is created in the uibuilder root folder (e.g.
~/.node-red/uibuilder/common
)This is made available to each node instance and is used to make common resources available to multiple web apps.
See the URI Paths page in the WIKI for details of all URI's available to your web apps.
I don't believe any of the current issues make the node unusable. They are mainly things to be aware of & that I'd like to tidy up at some point.
-
It is common to need to send a number of messages from Node-RED to the front-end, specifically when a new client is loaded or a user refreshes the client browser. The 2nd output port of the node provides the control messages needed to handle this.
See the Caching page on the WIKI for how to easily handle new or updated client connections with minimal code.
-
Socket.IO isn't secured by default Use uibuilder's ExpressJS and socket middleware feature to secure things properly before considering use over the Internet.
Note, however that the socket middleware is only called on initial socket connection. Once the connection upgrades to websocket, this is no longer called.
I hope to improve this in a future release.
You could also work around this by using a proxy such as NGINX or HAproxy to be the TLS endpoint. Just make sure you proxy the websocket traffic as well as the standard web traffic.
Use the Dashboard
category in the Node-RED Discourse forum or the #uibuilder channel in the Node-RED Slack for general discussion about this node.
Or use the GitHub issues log for raising issues or contributing suggestions and enhancements.
If you would like to contribute to this node, you can contact Totally Information via GitHub or raise a request in the GitHub issues log.
Please refer to the contributing guidelines for more information.
- Julian Knight - the designer and main author.
- Colin Law - many thanks for testing, corrections and pull requests.
- Steve Rickus - many thanks for testing, corrections and contributed code.
- Ellie Lee - many thanks for the PR fixing duplicate msgs.
- Thomas Wagner - thanks for the steer and PR on using projects folder if active.
- Arlena Derksen - thanks for suggestions, bug checks and Issue #59/PR #60.
- cflurin - thanks for the cache example.
Please also check out my blog, Much Ado About IT, it has information about all sorts of topics, mainly IT related, including Node-RED.