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_template.html 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <script type="text/html" data-help-name="ui_template">
  2. <p>The template widget can contain any valid html and Angular/Angular-Material directives.</p>
  3. <p>This node can be used to create a dynamic user interface element that changes its appearance
  4. based on the input message and can send back messages to Node-RED.</p>
  5. <p><b>For example:</b><br>
  6. <pre style="font-size:smaller;">&lt;div layout=&quot;row&quot; layout-align=&quot;space-between&quot;&gt;
  7. &lt;p&gt;The number is&lt;/p&gt;
  8. &lt;font color=&quot;{{((msg.payload || 0) % 2 === 0) ? 'green' : 'red'}}&quot;&gt;
  9. {{(msg.payload || 0) % 2 === 0 ? 'even' : 'odd'}}
  10. &lt;/font&gt;
  11. &lt;/div&gt;</pre>
  12. Will display if the number received as <code>msg.payload</code> is even or odd. It will also
  13. change the color of the text to green if the number is even or red if odd.<br/>
  14. The next example shows how to set a unique id for your template, pick up the default theme colour,
  15. and watch for any incoming message.</p>
  16. <pre style="font-size:smaller;">
  17. &lt;div id="{{'my_'+$id}}" style="{{'color:'+theme.base_color}}"&gt;Some text&lt;/div&gt;
  18. &lt;script&gt;
  19. (function(scope) {
  20. scope.$watch('msg', function(msg) {
  21. if (msg) {
  22. // Do something when msg arrives
  23. $("#my_"+scope.$id).html(msg.payload);
  24. }
  25. });
  26. })(scope);
  27. &lt;/script&gt;</pre>
  28. <p>Templates made in this way can be copied and remain independent of each other.</p>
  29. <p><b>Sending a message:</b><br>
  30. <pre style="font-size:smaller;">
  31. &lt;script&gt;
  32. var value = "hello world";
  33. // or overwrite value in your callback function ...
  34. this.scope.action = function() { return value; }
  35. &lt;/script&gt;
  36. &lt;md-button ng-click=&quot;send({payload:action()})&quot;&gt;
  37. Click me to send a hello world
  38. &lt;/md-button&gt;</pre>
  39. Will display a button that when clicked will send a message with the payload <code>'Hello world'</code>.</p>
  40. <p><b>Using <code>msg.template</code>:</b><br>
  41. You can also define the template content via <code>msg.template</code>, so you can use external files for example.<br>
  42. Template will be reloaded on input if it has changed.<br>
  43. Code written in the Template field will be ignored when <code>msg.template</code> is present.</p>
  44. <p>The following icon fonts are available: <a href="https://klarsys.github.io/angular-material-icons/" target="_blank">Material Design icon</a>
  45. <i>(e.g. 'check', 'close')</i> or a <a href="https://fontawesome.com/v4.7.0/icons/" target="_blank">Font Awesome icon</a>
  46. <i>(e.g. 'fa-fire')</i>, or a <a href="https://github.com/Paul-Reed/weather-icons-lite/blob/master/css_mappings.md">Weather icon</a>.
  47. You can use the full set of Google material icons if you add 'mi-' to the icon name. e.g. 'mi-videogame_asset'.</p>
  48. <p>If a <b>Class</b> is specified, it will be added to the parent card. This way you can style the card and the elements inside it with custom CSS. The Class can be set at runtime by setting a <code>msg.className</code> string property.</p>
  49. </script>