Serve data from txt file to dashboard template

72 views
Skip to first unread message

Chapo

unread,
Apr 20, 2018, 5:17:13 AM4/20/18
to Node-RED
Hello!

I have managed to serve motion data to a data.txt file and inject a timestamp which now sits happily on my pi.  Seperately, I have managed to serve up the last event via a template on the dashboard.  However, my true objective is to serve up the last 50 or so events from the data.txt file into the template.  Can anybody point me in the right direction please?

Adrian Brown

unread,
Apr 20, 2018, 5:27:30 AM4/20/18
to node...@googlegroups.com

Tail is one option quite easy if your new to node.js or JavaScript coding



On Fri, 20 Apr 2018 at 7:17 pm, Chapo <glenn.aj...@gmail.com> wrote:
Hello!

I have managed to serve motion data to a data.txt file and inject a timestamp which now sits happily on my pi.  Seperately, I have managed to serve up the last event via a template on the dashboard.  However, my true objective is to serve up the last 50 or so events from the data.txt file into the template.  Can anybody point me in the right direction please?

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/cbee089e-ba25-47c6-870c-7fddd9b7df8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Regards
Adrian Brown

Chapo

unread,
Apr 20, 2018, 11:26:04 AM4/20/18
to Node-RED
Thanks for coming back to me Adrian most appreciated.

Below is the javascript for my motion output.  How would I incorporate tail here please, with the historic data coming from the text file?

<h3>Last Recorded Motion</h3>
{{msg.payload}}
<script>
    (function(scope) {
        console.log('Position 1');
        console.dir(scope);
        console.log(scope.msg);
        scope.$watch('msg.payload', function(data) {
            console.log('Position 2');
            console.dir(data);
        });
    })(scope);
</script>

Thanks in advance

Glenn
Reply all
Reply to author
Forward
0 new messages