Notify on Click

Dashboard Buttons work fine. I just have some slow things reacting on the click.

Would it be Possibly to add some flash/color change reaction to the Dashboard Button for the onClick Event ?

Also disabling buttons for a while would be a solution if possible ?

oh found it, thought an old example which still works ok

[{"id":"b9a70965.13e138","type":"ui_button","z":"d511095d.512808","name":"","group":"c070ecdb.6d5ce","order":0,"width":"0","height":"0","passthru":false,"label":"{{payload}}","color":"","bgcolor":"{{colour}}","icon":"","payload":"press","payloadType":"str","topic":"","x":610,"y":560,"wires":[["48aaee20.8d9e1"]]},{"id":"5cc84101.ac6d9","type":"change","z":"d511095d.512808","name":"","rules":[{"t":"set","p":"colour","pt":"msg","to":"green","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"<i class=\"fa fa-rotate-90 fa-folder-open-o\"></i> OPEN","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":520,"wires":[["b9a70965.13e138"]]},{"id":"329e773b.0fdcb8","type":"inject","z":"d511095d.512808","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"","x":190,"y":560,"wires":[["bc5a70e.6f6a29"]]},{"id":"48aaee20.8d9e1","type":"function","z":"d511095d.512808","name":"state","func":"var state = context.state || false;\nstate = !state;\ncontext.state = state;\nif (state) { return [msg,null]; }\nelse { return [null,msg]; }\n","outputs":2,"noerr":0,"x":190,"y":700,"wires":[["5cc84101.ac6d9"],["bc5a70e.6f6a29"]]},{"id":"bc5a70e.6f6a29","type":"change","z":"d511095d.512808","name":"","rules":[{"t":"set","p":"colour","pt":"msg","to":"red","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"<i class=\"fa fa-rotate-90 fa-folder-o\"></i> Closed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":560,"wires":[["b9a70965.13e138"]]},{"id":"c070ecdb.6d5ce","type":"ui_group","z":"d511095d.512808","name":"Click","tab":"7d974e73.cf8f9","order":1,"disp":true,"width":"5"},{"id":"7d974e73.cf8f9","type":"ui_tab","z":"d511095d.512808","name":"Home","icon":"link","order":1}]

example was made by dceejay in slack 2018

You might use the newer (although the older one still works) syntax for the context. In such case your function code would looks like:

var state = context.get("state") || false;
state = !state;
context.set ("state" , state);

if (state) { return [msg,null]; }
else { return [null,msg]; }

ok thanks Andrei, I'll try that

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.