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.html 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <script type="text/javascript">
  2. RED.nodes.registerType('ui-group', {
  3. category: 'config',
  4. defaults: {
  5. name: {
  6. value: RED._('@flowfuse/node-red-dashboard/ui-group:ui-group.label.groupName'),
  7. required: true
  8. },
  9. page: { type: 'ui-page', required: true },
  10. width: { value: 6 },
  11. height: { value: 1 },
  12. order: { value: -1 },
  13. showTitle: { value: true }, // show title on group card
  14. className: { value: '' },
  15. visible: { value: true },
  16. disabled: { value: false }
  17. },
  18. label: function () {
  19. const page = RED.nodes.node(this.page)?.name || ''
  20. return `[${page}] ${this.name}` || 'UI Group'
  21. },
  22. oneditprepare: function () {
  23. if (this.disp) {
  24. this.showTitle = this.disp
  25. }
  26. $('#node-config-input-size').elementSizer({
  27. width: '#node-config-input-width',
  28. height: '#node-config-input-height',
  29. auto: false
  30. })
  31. // backwards compatibility
  32. if (this.visible === undefined || this.visible === true) {
  33. this.visible = true
  34. $('#node-config-input-visible').val('true')
  35. } else if (this.visible === false) {
  36. this.visible = false
  37. $('#node-config-input-visible').val('false')
  38. }
  39. // backwards compatibility
  40. if (this.disabled === undefined || this.disabled === false) {
  41. this.disabled = false
  42. $('#node-config-input-disabled').val('false')
  43. } else if (this.disabled === true) {
  44. this.disabled = true
  45. $('#node-config-input-disabled').val('true')
  46. }
  47. },
  48. oneditsave: function () {
  49. // convert string to boolean
  50. const visible = $('#node-config-input-visible').val()
  51. if (visible === 'true') {
  52. this.visible = true
  53. } else {
  54. this.visible = false
  55. }
  56. // convert string to boolean
  57. const disabled = $('#node-config-input-disabled').val()
  58. if (disabled === 'true') {
  59. this.disabled = true
  60. } else {
  61. this.disabled = false
  62. }
  63. }
  64. })
  65. </script>
  66. <script type="text/html" data-template-name="ui-group">
  67. <div class="form-row">
  68. <label for="node-config-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></label>
  69. <input type="text" id="node-config-input-name" data-i18n="[placeholder]node-red:common.label.name">
  70. </div>
  71. <div class="form-row">
  72. <label for="node-config-input-page"><i class="fa fa-bookmark"></i> <span data-i18n="ui-group.label.page"></label>
  73. <input type="text" id="node-config-input-page">
  74. </div>
  75. <div class="form-row">
  76. <label for="node-config-input-size"><i class="fa fa-arrows-h"></i> <span data-i18n="ui-group.label.size"></label>
  77. <input type="hidden" id="node-config-input-width">
  78. <input type="hidden" id="node-config-input-height">
  79. <button class="editor-button" id="node-config-input-size"></button>
  80. </div>
  81. <div class="form-row">
  82. <input style="margin:8px 0 10px 102px; width:20px;" type="checkbox" checked id="node-config-input-showTitle">
  83. <label style="width:auto" for="node-config-input-showTitle"><span data-i18n="ui-group.label.display-name"></span></label>
  84. </div>
  85. <div class="form-row" id="text-row-class">
  86. <label for="node-config-input-className"><i class="fa fa-code"></i> <span data-i18n="ui-group.label.className"></span></label>
  87. <input type="text" id="node-config-input-className" data-i18n="[placeholder]ui-group.label.classNamePlaceholder"/>
  88. </div>
  89. <div class="form-row" style="font-weight: 600;">
  90. <i class="w-16 fa fa-eye"></i> <span data-i18n="ui-group.label.defaultState"></span>
  91. </div>
  92. <div class="form-row">
  93. <div style="display: flex; align-items: center; gap: 2px;">
  94. <label for="node-config-input-visible" style="margin-bottom: 0" data-i18n="ui-group.label.visibility"></label>
  95. <select id="node-config-input-visible" style="width: 150px;">
  96. <option value="true" data-i18n="ui-group.label.visible"></option>
  97. <option value="false" data-i18n="ui-group.label.hidden"></option>
  98. </select>
  99. </div>
  100. </div>
  101. <div class="form-row">
  102. <div style="display: flex; align-items: center; gap: 2px;">
  103. <label for="node-config-input-disabled" style="margin-bottom: 0" data-i18n="ui-group.label.interactivity"></label>
  104. <select id="node-config-input-disabled" style="width: 150px;">
  105. <option value="false" data-i18n="ui-group.label.active"></option>
  106. <option value="true" data-i18n="ui-group.label.disabled"></option>
  107. </select>
  108. </div>
  109. </div>
  110. <div class="form-row">
  111. <button onclick="RED.sidebar.show('dashboard-2.0')" class="editor-button editor-button-small" data-i18n="ui-group.label.openDashboardSidebar"></button>
  112. </div>
  113. </script>