Sending data from dashboard template (for the closed topic from Vrrrum)

I know this has already been answered, but I found a solution from another post that seems very easy to understand.

For beginners like myself (and perhaps Vrrrum) it might help you get started.

I've just copied this directly from a flow of mine. The point of the flow is just check whether the connection is on the local network or not.

There is a small .png image that the page tries to load. If it loads successfully it calls the test_remote function with the variable 'local' and if there'ss an error i.e it can't find the image it calls the test_remote function with the variable 'remote'.

This is just done normally in the html i.e outside the 'scope'.

The 'script' is also fairly normal. The only thing you have to do is declare a variable for the scope in this case "var theScope = scope;"

Then you can use "theScope.send" to send the variable i.e "theScope.send({payload:connection});"

I hope this helps someone.

<html>
<body>

<img id="test_image" src="http://192.168.1.156:1880/test_network_image.png"  onload="test_remote('local')" onerror="test_remote('remote')">

<style>
    #test_image{
    display:none;
    }
     
    #nr-dashboard .masonry-container ui-card-panel {
    border:none;
    }
        
    [node-id="b4733bd745eaa38b"] {
        background-color: #111111 !important;
    }
       
</style>




<script>
var theScope = scope;

function test_remote(connection) {
  theScope.send({payload:connection});
};


</script>

</body>
</html>

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