- docs
- FlowFuse User Manuals
- Using FlowFuse
- Getting Started
- Static asset service
- Bill of Materials
- FlowFuse Concepts
- Changing the Stack
- Custom Hostnames
- Device Groups
- DevOps Pipelines
- Environment Variables
- FlowFuse Assistant
- FlowFuse File Nodes
- FlowFuse Persistent Context
- FlowFuse Project Nodes
- High Availability mode
- HTTP Access Tokens
- Instance Settings
- Logging
- Shared Team Library
- Snapshots
- Team Broker
- Teams
- User Settings
- FlowFuse API
- Migrating a Node-RED project to FlowFuse
- Device Agent
- Device Agent
- FlowFuse Device Agent Introduction
- Quick Start
- Installation
- Quick Start with Web UI
- Register your Device
- Running the Agent
- Deploying your Flows
- Hardware Guides
- FlowFuse Cloud
- FlowFuse Cloud
- FlowFuse Self-Hosted
- Quick Start
- Installing FlowFuse
- Overview
- Configuring FlowFuse
- DNS Setup
- Docker install
- Docker from AWS Market Place
- Docker on Digital Ocean
- Add Project Stacks on Docker
- Docker Engine on Windows
- Email configuration
- First Run Setup
- FlowFuse File Storage
- Install FlowFuse on Kubernetes
- Upgrading FlowFuse
- Administering FlowFuse
- Administering FlowFuse
- Configuring Single Sign-On (SSO)
- Licensing
- Monitoring
- Telemetry
- User Management
- Support
- Community Support
- Premium Support
- Debugging Node-RED issues
- Contributing
- Contributing to FlowFuse
- Introduction
- Adding Template Settings
- API Design
- Creating debug stack containers
- Database migrations
- FlowFuse Architecture
- Local Install
- State Flows
- Device Editor
- Invite External Users
- User Login Flows
- Reset Password Flow
- Project Creation
- Instance states
- User Sign up Flow
- Team creation Flow
- Team Broker
- Working with Feature Flags
# Adding Template Settings
Within FlowFuse, each Node-RED instance is created from a Template. The Template defines a set of preconfigured options for the instance. This includes runtime settings - values that you would normally expect to set in your Node-RED settings.js file.
The Template also defines which of those options can be customised by individual instances.
This guide explains how to add a new Node-RED runtime option to the Template object so that it can be customised and passed through to the underlying Node-RED settings.js file.
This is reasonably straightforward for simple boolean/string/numeric types. For other types (objects/arrays) it gets more complicated and we don't currently have good examples to follow.
For the 'simple' cases, the steps are:
- Update the Frontend
- Pick a name for the setting, add it to the list of known settings and any validation logic that is needed
- Add it to the appropriate Template section
- Update the runtime
- Add it to the known list of settings and any additional validation logic
- Update the Launcher
- Update the template used to generate settings.js with the new property
# 1. Updating the Frontend
There are a set of views in the frontend used to present and edit templates. They get used in two different ways:
- When creating/editing a template. All options are available and there is a dropdown that lets the user set the policy on the setting (which controls whether an instance is allowed to override the setting)
- When editing instance settings. All options are shown, but only lets the user modify those that the template policy allows to be changed.
This reuse of the views saves a lot of code duplication, at the cost of some complication in implementing it.
# 1.1 - Pick a name for the setting
The name should try to match its corresponding property in the Node-RED settings.js file. Some thought should be made as to organisation of the properties.
- Edit
frontend/src/pages/admin/Template/utils.js
- Add the new property name to the
templateFields
anddefaultTemplateValues
objects. Notice the names are flat strings with_
used as a hierarchy separator... that will make more sense if you're looking at the file. - If the value needs any sort of validation, add it to
templateValidators
in the same file.
# 1.2 - Add it to the appropriate Template section
Currently there are:
- Editor
- Palette
- Environment - a special case that is unlikely to get other options added
These each lives in their own file under frontend/src/pages/admin/Template/sections/
.
Pick an existing setting that most closely matches the setting you want to add (ie checkbox or text input), and copy its entry to the appropriate place.
Make sure you update all of the references of the copied property name to your new property name.
# 2. Updating the Runtime
# 2.1 - Adding it to the known list
-
Edit
forge/db/controllers/ProjectTemplate.js
to add the new property to the list of known settings. -
In that same file, update the
validateSettings
function with any additional validation or data cleansing needed.
# 3. Update nr-launcher
In the flowforge-nr-launcher
repo...
- Edit
lib/runtimeSettings.js
to include the new setting in the generate settings.js file. Note that you must handle the case where the new setting is not present - either by applying a sensible default, or omitting the value.