15. Adding Logic to a Button Node

In order to add logic into our button node, we will add an inject node, a function node, and two change nodes. This will allow us to change the color and the icon of the button when pressed.

Next, double-click on the function parameter, type the following code and parameters

var state = context.state || false;
state = !state;
context.state = state;
if (state) { return [msg,null]; }
else { return [null,msg]; }
‚Äč

Click Done once completed

Next, double-click on the top change (1) node and change the following parameters

<i class="fa fa-rotate-90 fa-folder-open-o"></i> OPENED FEEDER

Click Done once completed

Next, double-click on the top change (2) node and change the following parameters

<i class="fa fa-rotate-90 fa-folder-o"></i> CLOSED FEEDER

Click Done once completed

Next, double-click on the inject node and change the following parameters

Click Done once completed

Next, connect all the nodes as shown below

Click Deploy and go to your Dashboard page

Congratulations, you have successfully built your dashboard!