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_group.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. module.exports = function (RED) {
  2. /**
  3. *
  4. * @param {*} config
  5. */
  6. function UIGroupNode (config) {
  7. RED.nodes.createNode(this, config)
  8. const node = this
  9. const page = RED.nodes.getNode(config.page)
  10. if (!('showTitle' in config)) {
  11. // migration backwards compatibility
  12. // we now use showTitle, not disp, but older flows still may have disp
  13. config.showTitle = config.disp || true
  14. }
  15. // register self
  16. page.getBase().register(null, config)
  17. node.on('close', function (removed, done) {
  18. node.deregister() // deregister self
  19. done()
  20. })
  21. /**
  22. * Function for widgets to register themselves with this page
  23. * Calls the parent UI Base "register" function and registers this page,
  24. * along with the widget
  25. * @param {*} widget
  26. */
  27. node.register = function (widgetNode, widgetConfig, widgetEvents) {
  28. const group = config
  29. page.register(group, widgetNode, widgetConfig, widgetEvents)
  30. }
  31. node.deregister = function (widgetNode) {
  32. const group = config
  33. page.deregister(group, widgetNode)
  34. }
  35. // Return the UI Base Node this group lives in
  36. node.getBase = function () {
  37. return RED.nodes.getNode(config.page).getBase()
  38. }
  39. }
  40. RED.nodes.registerType('ui-group', UIGroupNode)
  41. }