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_button.html 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <script type="text/javascript">
  2. RED.nodes.registerType('ui_button',{
  3. category: RED._("node-red-dashboard/ui_base:ui_base.label.category"),
  4. color: 'rgb(176, 223, 227)',
  5. defaults: {
  6. name: {value: ''},
  7. group: {type: 'ui_group', required: true},
  8. order: {value: 0},
  9. width: {value: 0, validate: function(v) {
  10. var width = v||0;
  11. var currentGroup = $('#node-input-group').val()||this.group;
  12. var groupNode = RED.nodes.node(currentGroup);
  13. var valid = !groupNode || +width <= +groupNode.width;
  14. $("#node-input-size").toggleClass("input-error",!valid);
  15. return valid;
  16. }
  17. },
  18. height: {value: 0},
  19. passthru: {value: false},
  20. label: {value: 'button'},
  21. tooltip: {value: ''},
  22. color: {value: ''},
  23. bgcolor: {value: ''},
  24. className: {value: ''},
  25. icon: {value: ''},
  26. payload: {value: '',validate: (RED.validators.hasOwnProperty('typedInput')?RED.validators.typedInput('payloadType'):function(v) { return true})},
  27. payloadType: { value: 'str'},
  28. topic: {value: 'topic', validate: (RED.validators.hasOwnProperty('typedInput')?RED.validators.typedInput('topicType'):function(v) { return true})},
  29. topicType: {value: 'msg'}
  30. },
  31. inputs:1,
  32. outputs:1,
  33. outputLabels: function() { if (this.payloadType === "str") {
  34. return this.payload;
  35. } else {return this.payloadType; } },
  36. icon: "ui_button.png",
  37. paletteLabel: 'button',
  38. label: function() { return this.name || (~this.label.indexOf("{{") ? null : this.label) || 'button'; },
  39. labelStyle: function() { return this.name?"node_label_italic":""; },
  40. oneditprepare: function() {
  41. $("#node-input-size").elementSizer({
  42. width: "#node-input-width",
  43. height: "#node-input-height",
  44. group: "#node-input-group"
  45. });
  46. $('#node-input-payload').typedInput({
  47. default: 'str',
  48. typeField: $("#node-input-payloadType"),
  49. types: ['str','num','bool','json','bin','date','flow','global']
  50. });
  51. $('#node-input-topic').typedInput({
  52. default: 'str',
  53. typeField: $("#node-input-topicType"),
  54. types: ['str','msg','flow','global']
  55. });
  56. }
  57. });
  58. </script>
  59. <script type="text/html" data-template-name="ui_button">
  60. <div class="form-row">
  61. <label for="node-input-group"><i class="fa fa-table"></i> <span data-i18n="ui_button.label.group"></label>
  62. <input type="text" id="node-input-group">
  63. </div>
  64. <div class="form-row">
  65. <label><i class="fa fa-object-group"></i> <span data-i18n="ui_button.label.size"></label>
  66. <input type="hidden" id="node-input-width">
  67. <input type="hidden" id="node-input-height">
  68. <button class="editor-button" id="node-input-size"></button>
  69. </div>
  70. <div class="form-row">
  71. <label for="node-input-icon"><i class="fa fa-picture-o"></i> <span data-i18n="ui_button.label.icon"></label>
  72. <input type="text" id="node-input-icon" data-i18n="[placeholder]ui_button.label.optionalIcon">
  73. </div>
  74. <div class="form-row">
  75. <label for="node-input-label"><i class="fa fa-i-cursor"></i> <span data-i18n="ui_button.label.label"></label>
  76. <input type="text" id="node-input-label" data-i18n="[placeholder]ui_button.label.optionalLabel">
  77. </div>
  78. <div class="form-row">
  79. <label for="node-input-tooltip"><i class="fa fa-info-circle"></i> <span data-i18n="ui_button.label.tooltip"></label>
  80. <input type="text" id="node-input-tooltip" data-i18n="[placeholder]ui_button.label.optionalTooltip">
  81. </div>
  82. <div class="form-row">
  83. <label for="node-input-color"><i class="fa fa-tint"></i> <span data-i18n="ui_button.label.color"></label>
  84. <input type="text" id="node-input-color" data-i18n="[placeholder]ui_button.label.optionalColor">
  85. </div>
  86. <div class="form-row">
  87. <label for="node-input-bgcolor"><i class="fa fa-tint"></i> <span data-i18n="ui_button.label.background"></label>
  88. <input type="text" id="node-input-bgcolor" data-i18n="[placeholder]ui_button.label.optionalBackgroundColor">
  89. </div>
  90. <div class="form-row">
  91. <label style="width:auto" for="node-input-payload"><i class="fa fa-envelope-o"></i> <span data-i18n="ui_button.label.whenClicked"></label>
  92. </div>
  93. <div class="form-row">
  94. <label for="node-input-payload" style="padding-left: 25px; margin-right: -25px"><span data-i18n="ui_button.label.payload"></label>
  95. <input type="text" id="node-input-payload" style="width:70%">
  96. <input type="hidden" id="node-input-payloadType">
  97. </div>
  98. <div class="form-row">
  99. <label for="node-input-topic" style="padding-left: 25px; margin-right: -25px"><span data-i18n="ui_button.label.topic"></label>
  100. <input type="text" id="node-input-topic">
  101. <input type="hidden" id="node-input-topicType">
  102. </div>
  103. <div class="form-row">
  104. <label style="width:auto" for="node-input-passthru"><i class="fa fa-arrow-right"></i> <span data-i18n="ui_button.label.emulateClick"></label>
  105. <input type="checkbox" id="node-input-passthru" style="display:inline-block; width:auto; vertical-align:top;">
  106. </div>
  107. <div class="form-row">
  108. <label for="node-input-className"><i class="fa fa-code"></i> <span data-i18n="ui_button.label.className"></label>
  109. <input type="text" id="node-input-className" data-i18n="[placeholder]ui_button.label.classNamePlaceholder"/>
  110. </div>
  111. <div class="form-row">
  112. <label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></label>
  113. <input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
  114. </div>
  115. </script>