Hello,
I am reading data from a database and in dependency to that I create buttons on the dashboard. By clicking the buttons I write data in the database again. In dependency to the new data the number of buttons change. But how do I start the flow again to read the changed data from database? I start the procedure by a timestamp injection node; to loop this doesn't helped. What's the best practice in this case? I fear that I misunderstood the functionality of Node Red in this point.
Here is my flow:
[{"id":"4908e9f4.3b0eb8","type":"tab","label":"Haushalt","disabled":false,"info":""},{"id":"ef4a66.cf651598","type":"sqlite","z":"4908e9f4.3b0eb8","mydb":"928d1f20.39874","sqlquery":"fixed","sql":"SELECT hId, hTodo, hIcon FROM haushalt where hLast < current_Date;","name":"SmartyPi getTodo","x":350,"y":100,"wires":[["e22adac3.7feb38"]]},{"id":"a6c876c9.41757","type":"ui_template","z":"4908e9f4.3b0eb8","group":"3674240e.411144","name":"Buttons Daily","order":0,"width":0,"height":0,"format":"<!-- Add icon library -->\n<link href=\"https://fonts.googleapis.com/icon?family=Material+Icons\" rel=\"stylesheet\">\n \n<!-- Style buttons -->\n <style>\n.btn {\n background-color: #0094ce; \n border: none; \n color: white; \n padding: 5px 5px; \n font-size: 16px;\n cursor: pointer; \n}\n\n.btn:hover {\n background-color: #00aaed;\n}\n\n.nextButton {\n float: left;\n padding-left: 5px;\n}\n\n#setUid {\n display: none;\n}\n</style>\n\n\n<div class=\"choose\" id=\"setTodo\">\n<div ng-repeat=\"row in msg.payload[[0]]\" class=\"nextButton\">\n<button class=\"btn\" title={{row.hTodo}} style=\"height: 35px; width: 35px;\"><i class=\"material-icons\" ng-click=\"setTodo({todo: row.hId})\">{{row.hIcon}}</i></button>\n</div>\n</div>\n\n<div class=\"dialog\" id=\"setUid\"> \n<div ng-repeat=\"row in msg.payload[[1]]\" class=\"nextButton\">\n<button class=\"btn\" id=\"test2\" title={{row.uName}} style=\"height: 35px; width: 35px;\"><i class=\"material-icons\" ng-click=\"setUser({user: row.uId})\">{{row.uIcon}}</i></button>\n</div>\n</div>\n\n\n<script>\n(function(scope) {\n scope.payload = [];\n scope.setTodo = function(getTodo) {\n scope.payload.push(getTodo);\n document.getElementById(\"setUid\").style.display = \"block\";\n document.getElementById(\"setTodo\").style.display = \"none\";\n }\n scope.setUser = function(getUser) {\n scope.payload.push(getUser);\n scope.send({status: true, payload : scope.payload});\n }\n})(scope);\n \n</script>\n","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":790,"y":100,"wires":[["af110667.329f78"]]},{"id":"cd41a4c6.5c9bf","type":"sqlite","z":"4908e9f4.3b0eb8","mydb":"928d1f20.39874","sqlquery":"fixed","sql":"SELECT uId, uName, uIcon FROM user;","name":"SmartyPi getUser","x":490,"y":40,"wires":[["e22adac3.7feb38"]]},{"id":"72855e8d.015038","type":"delay","z":"4908e9f4.3b0eb8","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":260,"y":40,"wires":[["cd41a4c6.5c9bf"]]},{"id":"e22adac3.7feb38","type":"join","z":"4908e9f4.3b0eb8","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":650,"y":100,"wires":[["a6c876c9.41757"]]},{"id":"33cc495c.4dcda6","type":"function","z":"4908e9f4.3b0eb8","name":"Update Haushalt","func":"backup = msg;\nmsg.topic = \"Update haushalt set hLast = current_date where hId= \" + backup.payload[0][\"todo\"] + \";Insert into done (uID, dDate, dTime) values(\" + backup.payload[1][\"user\"] + \", current_date, (SELECT hTime from haushalt where hId = \" + backup.payload[0][\"todo\"] + \"));\";\nreturn msg;","outputs":1,"noerr":0,"x":1090,"y":100,"wires":[["5e85ec73.1202fc"]]},{"id":"5e85ec73.1202fc","type":"sqlite","z":"4908e9f4.3b0eb8","mydb":"928d1f20.39874","sqlquery":"msg.topic","sql":"","name":"Update Haushalt","x":1290,"y":100,"wires":[[]]},{"id":"af110667.329f78","type":"switch","z":"4908e9f4.3b0eb8","name":"","property":"status","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":930,"y":100,"wires":[["33cc495c.4dcda6"]]},{"id":"22d26df1.0d9f8a","type":"inject","z":"4908e9f4.3b0eb8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":130,"y":100,"wires":[["72855e8d.015038","ef4a66.cf651598"]]},{"id":"928d1f20.39874","type":"sqlitedb","z":"","db":"/home/pi/smartyPi/database/smartyPi.sqlite","mode":"RWC"},{"id":"3674240e.411144","type":"ui_group","z":"","name":"Daily Todo","tab":"f851193c.456508","order":1,"disp":true,"width":"6","collapse":false},{"id":"f851193c.456508","type":"ui_tab","z":"","name":"Haushalt","icon":"home","order":1,"disabled":false,"hidden":false}]
I hope you understand my problem and have an idea.
Thanks for help!
Sanne