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_link.html 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <script type="text/javascript">
  2. RED.nodes.registerType('ui-link', {
  3. category: 'config',
  4. defaults: {
  5. name: {
  6. value: RED._('@flowfuse/node-red-dashboard/ui-link:ui-link.label.linkName'),
  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. order: {
  23. value: -1
  24. },
  25. visible: { value: true },
  26. disabled: { value: false }
  27. },
  28. oneditprepare: function () {
  29. // handle Node-RED's dislike for booleans on dropdowns
  30. if (this.visible === undefined || this.visible === true) {
  31. this.visible = true
  32. $('#node-config-input-visible').val('true')
  33. } else if (this.visible === false) {
  34. this.visible = false
  35. $('#node-config-input-visible').val('false')
  36. }
  37. // handle Node-RED's dislike for booleans on dropdowns
  38. if (this.disabled === undefined || this.disabled === false) {
  39. this.disabled = false
  40. $('#node-config-input-disabled').val('false')
  41. } else if (this.disabled === true) {
  42. this.disabled = true
  43. $('#node-config-input-disabled').val('true')
  44. }
  45. },
  46. oneditsave: function () {
  47. // convert string to boolean
  48. const visible = $('#node-config-input-visible').val()
  49. if (visible === 'true') {
  50. this.visible = true
  51. } else {
  52. this.visible = false
  53. }
  54. // convert string to boolean
  55. const disabled = $('#node-config-input-disabled').val()
  56. if (disabled === 'true') {
  57. this.disabled = true
  58. } else {
  59. this.disabled = false
  60. }
  61. },
  62. label: function () {
  63. const path = this.path || ''
  64. return `${this.name} [${path}]` || 'UI Link'
  65. }
  66. })
  67. </script>
  68. <script type="text/html" data-template-name="ui-link">
  69. <div class="form-row">
  70. <label for="node-config-input-name"><i class="w-16 fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></label>
  71. <input type="text" id="node-config-input-name" data-i18n="[placeholder]node-red:common.label.name">
  72. </div>
  73. <div class="form-row">
  74. <label for="node-config-input-ui"><i class="w-16 fa fa-sitemap"></i> <span data-i18n="ui-link.label.ui"></label>
  75. <input type="text" id="node-config-input-ui">
  76. </div>
  77. <div class="form-row">
  78. <label for="node-config-input-path"><i class="w-16 fa fa-link"></i> <span data-i18n="ui-link.label.path"></label>
  79. <input type="text" id="node-config-input-path">
  80. </div>
  81. <div class="form-row">
  82. <label for="node-config-input-icon"><i class="w-16 fa fa-home"></i> <span data-i18n="ui-link.label.icon"></label>
  83. <input type="text" id="node-config-input-icon">
  84. </div>
  85. <div class="form-row" style="font-weight: 600;">
  86. <i class="w-16 fa fa-eye"></i> <span data-i18n="ui-link.label.defaultState">
  87. </div>
  88. <div class="form-row">
  89. <div style="display: flex; align-items: center; gap: 2px;">
  90. <label for="node-config-input-visible" style="margin-bottom: 0" data-i18n="ui-link.label.visibility"></label>
  91. <select id="node-config-input-visible" style="width: 150px;">
  92. <option value="true" data-i18n="ui-link.label.visible"></option>
  93. <option value="false" data-i18n="ui-link.label.hidden"></option>
  94. </select>
  95. </div>
  96. </div>
  97. <div class="form-row">
  98. <div style="display: flex; align-items: center; gap: 2px;">
  99. <label for="node-config-input-disabled" style="margin-bottom: 0" data-i18n="ui-link.label.interactivity"></label>
  100. <select id="node-config-input-disabled" style="width: 150px;">
  101. <option value="false" data-i18n="ui-link.label.active"></option>
  102. <option value="true" data-i18n="ui-link.label.disabled"></option>
  103. </select>
  104. </div>
  105. </div>
  106. </script>