Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ui_table.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. const datastore = require('../store/data.js')
  2. module.exports = function (RED) {
  3. function TableNode (config) {
  4. const node = this
  5. // create node in Node-RED
  6. RED.nodes.createNode(this, config)
  7. // which group are we rendering this widget
  8. const group = RED.nodes.getNode(config.group)
  9. config.maxrows = parseInt(config.maxrows) || 0
  10. if (config.columns) {
  11. config.columns.map((col) => {
  12. // map older data where 'label' was used.
  13. return {
  14. title: col.title || col.label,
  15. key: col.key,
  16. type: col.type,
  17. width: col.width,
  18. align: col.align
  19. }
  20. })
  21. }
  22. // inform the dashboard UI that we are adding this node
  23. group.register(node, config, {
  24. onAction: true,
  25. onInput: function (msg) {
  26. // store the latest msg passed to node
  27. datastore.save(group.getBase(), node, msg)
  28. // do nothing else - do not pass the message on
  29. }
  30. })
  31. }
  32. RED.nodes.registerType('ui-table', TableNode)
  33. }