0.4.154 • Published 1 year ago

@flexdash/node-red-flexdash v0.4.154

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

node-red-flexdash

Node-RED nodes to interface with FlexDash

FlexDash is a self-contained web dashboard for Node-RED and IoT devices. This package provides Node-RED nodes that interface with FlexDash making it easy to send data to be displayed in the dashboard, and to receive user input messages from the dashboard.

Under the hood the nodes here use Socket.IO and the dashboard(s) can use Node-RED's web server (i.e. the same port) or a different port.

Please refer to the FlexDash Documentation for a quick-start guide, tutorials, and more...

Installation

To install node-red-flexdash use:

npm i @flexdash/node-red-flexdash

On its own node-red-flexdash doesn't provide any widgets to fill a dashboard with, it is thus recommended to install the core widgets:

npm -i @flexdash/node-red-fd-corewidgets

Quick-start (more in detail in the FlexDash Documentation, see below):

  • import one of the simple examples from the node-red-corewidgets module
  • edit one of the FlexDash nodes that show up, edit its grid configuration node, add a tab configuration node (default config OK) and add a dashboard configuration node (again, deafults are OK)
  • deploy
  • point your browser at http://localhost:1880/flexdash (same hostname/port you use for the Node-RED editor)

To do

Near term enhancements

  • set-up demos for all widgets
  • replace typedInput by something better, support unsetting, support color picker, fix booleans
  • color picker for node-red using the material design palette
  • support fd-custom node, i.e., compile vue SFC on-the-fly server-side

Near term fixes

  • fix reordering of array widgets
  • new-dashboard should automatically use a different path

Other

  • enhance Widget API to support more complex data structures, specifically, ring buffers (arrays) and messages
  • during NR deploy block changes from dashboards
  • keep static/dynamic setting across deploy
  • support editing multiline text prop values in node-red
  • implement checks for unsupported combinations: non-global tabs/dashboards, panels in panels, grids in subflows, nested subflows, array-widgets in array-panels, array/subflow combinations
  • fix order of props in NR edit pane
  • support array-panels
  • fix edit button for panels overlapping edit button of widget
  • fix editing of array-widgets in the dashboard: need to propagate changes to all other widgets in the array
  • implement array_max in array-widgets
  • Windows 10 support
  • Basic login mechanism
  • Wrap onInput callback into try/catch
  • Pass flexdash client id to onInput handler
  • Edit mode disable/off/on setting, per-user if there's auth
  • Create an "any widget" node
  • Add logging verbosity switch to dashboard config node
  • Don't log every message sent to FD, or at least shorten
  • Fix display of tab name as title if title is empty
  • Remove "Widget X has not prop Y" warning

Internals

The main interface with FlexDash is flexdash-dashboard.*, which handles serving up FlexDash and handling messages to/from the dashboard. It also exposes a config node to represent the dashboard connection. There can be multiple dashboard as long as they use different paths or ports.

The Node-RED plugin in flexdash-plugin.* is a relatively simple piece that is a plugin only so node-red widget nodes can call "into FlexDash" without having to figure out how to get a handle onto the appropriate flexdash-dashboard config node first.

The config nodes in flexdash-tab.* and flexdash-container.* represent containers for widgets in the dashboard. lfexdash-container can represent a grid or a panel. A Widget either belongs to a grid or to a panel which itself belongs to a grid. A grid belongs to a tab and there can be multiple tabs per dashboard.

The development server in flexdash-dev-server.* is a node that can be placed anywhere to launch a development server for FlexDash widgets. It runs Vite, which is a web server that automatically pushes source code to the web browser as soon as you save a file (hot module reload). To access the dev server, once launched, point your browser at the dashboard URL plus a -src suffix, e.g. /flexdash-src instead of /flexdash for the default set-up. (Note: the dev server feature should be moved into a side-bar eventually.)

The flexdash-in.* and flexdash-out.* nodes are not currently supported. They send/receive raw messages to/from FlexDash which supports advanced usage. However, the current saving of dashboard configuration changes does not really support such advanced usage, so these nodes are not currently exported.

Disabled flows

When flows are disabled the nodes simply don't show up in the runtime. This means that the list of widgets in a container has IDs that are missing and look like they were deleted.

The config coming out of the flow editor needs to ensure that all nodes referenced in the "children" list exist (in the flow editor). Then in the run-time, missing nodes found in the children list are assumed to be disabled and are marked as such, but not removed.

When altering the position of widgets in the dashboard, the missing widgets need to be kept. When the config is pushed back into the flow editor, the missing widgets should be "reconnected" with the disabled nodes.

  • the pruning of deleted nodes in children lists must only happen in the flow editor

Subflows

In the flow editor, widgets in subflows must be associated with an ArrayGrid (or a (Subflow?)Panel in an ArrayGrid) and listed in the grid's children. Not clear how a static order is represented...

In the runtime, the subflow instance widgets show up, they need to be mapped to their template node using the _alias property. The ordering in the ArrayGrid is then determined via the subflow node's ID.

Changing the order in the dashboard should result in a change in the order list in the ArrayGrid. Changing the dimension and other properties needs to map back to the template nodes.

  • the main trick seems to be to map N nodes in the runtime to 1 template node (which may not exist in the runtime?), plus an ordering/data key
  • message routing then needs to use the ordering/data key also

Panels need to be similarly mapped back, but need to be transparent to the widget ordering/data key stuff. Not clear how this happens...

It's not clear how to handle nesting of subflows, maybe it's just a concatenation of the subflow instance IDs for the purpose of the ordering representation?

SubflowPanels:

  • End up with widget IDs `w-
  • ID of containing grid is in subflow instance env variable
  • Containing grid has fd_children with w<subflow>-<panel> because the order of these needs to be persisted.
  • The panel node ID is pretty useless 'cause it changes at each deploy

Widgets in SubflowPanels:

  • End up with widget IDs `w- mostly because otherwise it requires an extra data structure to locate the widget instance node ID (prob would have to do the latter to support array widgets in subflows).
  • When expanding the SubflowPanel's fd_children the widget config ID is converted to wSSS-NNN.

Array widgets:

  • End up with widget IDs `w- in order to support the one-to-many.

Node-RED internals

  • The flow editor operates on node configs that it passes to the runtime.
  • The runtime has the node configs, but then operates on node objects, i.e. instantiations of the configs.
  • The flow config can be traversed in the runtime using RED.nodes.eachNode, eachConfig, eachSubflow, etc. Confusingly RED.nodes.node is to query active instantiated nodes!
  • There are nodes in the config that are not instantiated: nodes in disabled flows and nodes in subflows are two examples.
  • The set of active/instantiated flows cannot be traversed (no eachXxx function).
  • There are nodes in the active set that are not in the config: nodes in instances of subflows are one example.
  • Everything is a node: a flow, a subflow, a subflow instance, a node, a config node, etc.
  • Special fields:
    • .z refers to the flow in which a node is located, it doesn't exist in global config nodes
    • ._alias in runtime is found in nodes in subflows and refers to the node (config) that the node was instantiated from
    • .d is true(?) for nodes in disabled flows
  • Subflows:

    • The subflow "template" is represented by a type=subflow node.
    • A node type subflow:<subflow node id> is created for each subflow.
    • Subflow instance nodes are of that type
    • For each node in a subflow "template" a new node in instantiated on deploy, its ._alias has the ID of the node "template".
    • The "template" nodes are not instantiated in the runtime, they remain solely as configs, i.e., no constructor gets called.

License

MIT

0.4.149

1 year ago

0.4.148

1 year ago

0.4.147

1 year ago

0.4.153

1 year ago

0.4.152

1 year ago

0.4.151

1 year ago

0.4.150

1 year ago

0.4.154

1 year ago

0.4.142

1 year ago

0.4.141

1 year ago

0.4.140

1 year ago

0.4.145

1 year ago

0.4.144

1 year ago

0.4.143

1 year ago

0.4.135

1 year ago

0.4.139

1 year ago

0.4.138

1 year ago

0.4.137

1 year ago

0.4.136

1 year ago

0.4.129

1 year ago

0.4.131

1 year ago

0.4.134

1 year ago

0.4.133

1 year ago

0.4.132

1 year ago

0.4.119

1 year ago

0.4.118

1 year ago

0.4.120

1 year ago

0.4.124

1 year ago

0.4.122

1 year ago

0.4.121

1 year ago

0.4.128

1 year ago

0.4.127

1 year ago

0.4.126

1 year ago

0.4.125

1 year ago

0.4.109

2 years ago

0.4.108

2 years ago

0.4.113

1 year ago

0.4.112

1 year ago

0.4.117

1 year ago

0.4.116

1 year ago

0.4.115

1 year ago

0.4.114

1 year ago

0.4.107

2 years ago

0.4.102

2 years ago

0.4.101

2 years ago

0.4.106

2 years ago

0.4.105

2 years ago

0.4.104

2 years ago

0.4.103

2 years ago

0.4.42

2 years ago

0.4.43

2 years ago

0.4.40

2 years ago

0.4.46

2 years ago

0.4.47

2 years ago

0.4.44

2 years ago

0.4.45

2 years ago

0.4.31

2 years ago

0.4.32

2 years ago

0.4.37

2 years ago

0.4.38

2 years ago

0.4.35

2 years ago

0.4.36

2 years ago

0.4.33

2 years ago

0.4.34

2 years ago

0.4.21

2 years ago

0.4.26

2 years ago

0.4.27

2 years ago

0.4.24

2 years ago

0.4.25

2 years ago

0.4.22

2 years ago

0.4.97

2 years ago

0.4.98

2 years ago

0.4.95

2 years ago

0.4.96

2 years ago

0.4.93

2 years ago

0.4.94

2 years ago

0.4.91

2 years ago

0.4.92

2 years ago

0.4.99

2 years ago

0.4.90

2 years ago

0.4.86

2 years ago

0.4.87

2 years ago

0.4.84

2 years ago

0.4.85

2 years ago

0.4.82

2 years ago

0.4.83

2 years ago

0.4.80

2 years ago

0.4.81

2 years ago

0.4.88

2 years ago

0.4.89

2 years ago

0.4.100

2 years ago

0.4.75

2 years ago

0.4.76

2 years ago

0.4.73

2 years ago

0.4.74

2 years ago

0.4.71

2 years ago

0.4.72

2 years ago

0.4.79

2 years ago

0.4.77

2 years ago

0.4.78

2 years ago

0.4.64

2 years ago

0.4.65

2 years ago

0.4.62

2 years ago

0.4.63

2 years ago

0.4.60

2 years ago

0.4.61

2 years ago

0.4.68

2 years ago

0.4.69

2 years ago

0.4.66

2 years ago

0.4.67

2 years ago

0.4.53

2 years ago

0.4.51

2 years ago

0.4.52

2 years ago

0.4.50

2 years ago

0.4.59

2 years ago

0.4.57

2 years ago

0.4.58

2 years ago

0.4.56

2 years ago

0.4.20

2 years ago

0.4.19

2 years ago

0.4.17

2 years ago

0.4.18

2 years ago

0.4.9

2 years ago

0.4.8

2 years ago

0.4.10

2 years ago

0.4.15

2 years ago

0.4.16

2 years ago

0.4.13

2 years ago

0.4.14

2 years ago

0.4.11

2 years ago

0.4.12

2 years ago

0.4.5

2 years ago

0.4.4

2 years ago

0.4.7

2 years ago

0.4.6

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.4.2

2 years ago

0.3.9

2 years ago

0.3.10

2 years ago

0.3.6

2 years ago

0.3.8

2 years ago

0.3.7

2 years ago

0.3.5

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago