This is a top navigation bar template for node-red-contrib-uibuilder v5.1.1.
( It uses Vue 2, bootstrap-vue and vue-router for the navigation between pages )
Each page is a seperate .vue component file (Single File Component) that loads in the parent App.vue
using vue-router. We use a SFC for each page to seperate and make the design cleaner with its own code and functionality.
Folder structure :
Because we are using .vue files and modern javascript syntax in our application, we'll need a bundler to build/translate that code into plain javascript so the browser can understand. In this project we use Vite.
You dont have to worry about installing or configuring anything with Vite, it gets installed when you run npm install
as it is in package.json
devDependencies, along with two script commands npm run build
to build your app and npm run dev
which spins a dev server and watches for any file changes with Hot Module Reloading, which makes development much faster.
Enough with the intro .. lets get coding.
- Configure a uibuilder node on your Node-Red flow with the URL set to e.g. :
navbar
- In Template Settings, select
Load an external template using Degit
and load the template from
unborn-andy/uib-template-vue-navbar
- In Advanced settings, set it to serve files from the
/dist
folder. - From
~/.node-red/uibuilder/navbar
runnpm install
to install all the dependencies of the app based on the package.json file. - Run
npm run build
so Vite will build the app into the/dist
folder. - Run
npm run dev
so Vite will spin up a dev server with Hot Module Reloading.
- During the installation steps I used as an example the uibuilder url
navbar
.
If you used something else more appropriate for your project, then you have to make some changes for the navigation to work. Inrouter.js
changebase: "navbar",
and inapp.js
change the ioNamespace subpath of :
uibuilder.start({ ioNamespace: `https://${document.location.hostname}:1880/navbar`, ioPath: "/uibuilder/vendor/socket.io", loadStylesheet: false });
- If you want to rename any of the pages in /components folder to something more descriptive to your project,
then rename them and make the relative changes to therouter.js
andNavBar.vue
files. - After any change, rebuild the app using
npm run build