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_page.html 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <script type="text/javascript">
  2. RED.nodes.registerType('ui-page', {
  3. category: 'config',
  4. defaults: {
  5. name: {
  6. value: RED._('@flowfuse/node-red-dashboard/ui-page:ui-page.label.pageName'),
  7. required: true
  8. },
  9. ui: {
  10. type: 'ui-base',
  11. value: '',
  12. required: true
  13. },
  14. path: {
  15. value: -1,
  16. required: false
  17. },
  18. icon: {
  19. value: 'home',
  20. required: false
  21. },
  22. layout: {
  23. value: '',
  24. required: true
  25. },
  26. theme: {
  27. type: 'ui-theme',
  28. value: 'default',
  29. required: true
  30. },
  31. order: {
  32. value: -1
  33. },
  34. className: { value: '' },
  35. visible: { value: 'true' },
  36. disabled: { value: 'false' }
  37. },
  38. oneditprepare: function () {
  39. if (this.path === -1) {
  40. // we have no path set yet
  41. let pageCount = 0
  42. RED.nodes.eachConfig((cNode) => {
  43. pageCount += cNode.type === 'ui-page' ? 1 : 0
  44. })
  45. this.path = '/page' + (pageCount + 1)
  46. $('#node-config-input-path').val(this.path)
  47. }
  48. $('#node-config-input-layout').typedInput({
  49. type: 'layout',
  50. types: [{
  51. value: 'layout',
  52. options: [
  53. { value: 'grid', label: RED._('@flowfuse/node-red-dashboard/ui-page:ui-page.label.grid') },
  54. { value: 'flex', label: RED._('@flowfuse/node-red-dashboard/ui-page:ui-page.label.fixed') },
  55. { value: 'tabs', label: RED._('@flowfuse/node-red-dashboard/ui-page:ui-page.label.tabs') },
  56. { value: 'notebook', label: RED._('@flowfuse/node-red-dashboard/ui-page:ui-page.label.notebook') }
  57. ]
  58. }],
  59. typeField: '#node-input-layoutType'
  60. })
  61. // backwards compatibility - because NR can't do boolean values on dropdowns
  62. if (this.visible === false || this.visible === 'false') {
  63. this.visible = false
  64. $('#node-config-input-visible').val('false')
  65. } else {
  66. this.visible = true
  67. $('#node-config-input-visible').val('true')
  68. }
  69. // backwards compatibility
  70. if (this.disabled === 'true' || this.disabled === true) {
  71. this.disabled = true
  72. $('#node-config-input-disabled').val('true')
  73. } else {
  74. this.disabled = false
  75. $('#node-config-input-disabled').val('false')
  76. }
  77. },
  78. oneditsave: function () {
  79. // convert string to boolean
  80. const visible = $('#node-config-input-visible').val()
  81. if (visible === 'true') {
  82. this.visible = true
  83. } else {
  84. this.visible = false
  85. }
  86. // convert string to boolean
  87. const disabled = $('#node-config-input-disabled').val()
  88. if (disabled === 'true') {
  89. this.disabled = true
  90. } else {
  91. this.disabled = false
  92. }
  93. },
  94. label: function () {
  95. const baseNode = RED.nodes.node(this.ui)
  96. const base = baseNode ? baseNode.path : '/'
  97. const path = this.path || ''
  98. return `${this.name} [${base}${path}]` || 'UI Page'
  99. }
  100. })
  101. </script>
  102. <script type="text/html" data-template-name="ui-page">
  103. <div class="form-row">
  104. <label for="node-config-input-name"><i class="w-16 fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></label>
  105. <input type="text" id="node-config-input-name" data-i18n="[placeholder]node-red:common.label.name">
  106. </div>
  107. <div class="form-row">
  108. <label for="node-config-input-ui"><i class="w-16 fa fa-sitemap"></i> <span data-i18n="ui-page.label.ui"></label>
  109. <input type="text" id="node-config-input-ui">
  110. </div>
  111. <div class="form-row">
  112. <label for="node-config-input-path"><i class="w-16 fa fa-link"></i> <span data-i18n="ui-page.label.path"></label>
  113. <input type="text" id="node-config-input-path">
  114. </div>
  115. <div class="form-row">
  116. <label for="node-config-input-icon"><i class="w-16 fa fa-home"></i> <span data-i18n="ui-page.label.icon"></label>
  117. <input type="text" id="node-config-input-icon">
  118. </div>
  119. <div class="form-row">
  120. <label for="node-config-input-theme"><i class="w-16 fa fa-paint-brush"></i> <span data-i18n="ui-page.label.theme"></label>
  121. <input type="text" id="node-config-input-theme">
  122. </div>
  123. <div class="form-row">
  124. <label for="node-config-input-layout"><i class="w-16 fa fa-th"></i> <span data-i18n="ui-page.label.layout"></label>
  125. <input type="text" id="node-config-input-layout">
  126. <input type="hidden" id="node-config-input-layoutType">
  127. </div>
  128. <div class="form-row" id="text-row-class">
  129. <label for="node-config-input-className"><i class="w-16 fa fa-code"></i> <span data-i18n="ui-page.label.class"></label>
  130. <input type="text" id="node-config-input-className" data-i18n="[placeholder]ui-page.label.classNamePlaceholder"/>
  131. </div>
  132. <div class="form-row" style="font-weight: 600;">
  133. <i class="w-16 fa fa-eye"></i> <span data-i18n="ui-page.label.defaultState">
  134. </div>
  135. <div class="form-row">
  136. <div style="display: flex; align-items: center; gap: 2px;">
  137. <label for="node-config-input-visible" style="margin-bottom: 0" data-i18n="ui-page.label.visibility"></label>
  138. <select id="node-config-input-visible" style="width: 150px;">
  139. <option value="true" data-i18n="ui-page.label.visible"></option>
  140. <option value="false" data-i18n="ui-page.label.hidden"></option>
  141. </select>
  142. </div>
  143. </div>
  144. <div class="form-row">
  145. <div style="display: flex; align-items: center; gap: 2px;">
  146. <label for="node-config-input-disabled" style="margin-bottom: 0" data-i18n="ui-page.label.interactivity"></label>
  147. <select id="node-config-input-disabled" style="width: 150px;">
  148. <option value="false" data-i18n="ui-page.label.active"></option>
  149. <option value="true" data-i18n="ui-page.label.disabled"></option>
  150. </select>
  151. </div>
  152. </div>
  153. <div class="form-row">
  154. <button onclick="RED.sidebar.show('dashboard-2.0')" class="editor-button editor-button-small" data-i18n="ui-page.label.openDashboardSidebar"></button>
  155. </div>
  156. </script>