Hi DieselD,
Here's some pure javascript to toggle a point, if that's helpful:
<script>function togglePoint( dataPointXid ) {
var getPoint = new XMLHttpRequest();
getPoint.addEventListener('load', function() {
//Consider returning if empty response text
var point = JSON.parse( this.responseText );
point.enabled = !point.enabled;
var putPoint = new XMLHttpRequest();
putPoint.open('PUT', '/rest/v1/data-points/'+point.xid, true);
putPoint.setRequestHeader( 'X-XSRF-TOKEN', /XSRF-TOKEN=(.*?);/.exec(document.cookie)[1] );
putPoint.setRequestHeader( 'Accept', 'application/json' );
putPoint.setRequestHeader( 'Content-Type', 'application/json' );
putPoint.send(JSON.stringify(point));
});
getPoint.open('GET', '/rest/v1/data-points/'+dataPointXid, true);
getPoint.setRequestHeader( 'X-XSRF-TOKEN', /XSRF-TOKEN=(.*?);/.exec(document.cookie)[1] );
getPoint.setRequestHeader( 'Accept', 'application/json' );
getPoint.send();
};
togglePoint("DP_819223");</script>
This can be used on one of the custom dashboards. If you're going to use it elsewhere, be sure to supply the Cookie header with the value of the cookie you get when you log in, and also to run the regex against that cookie instead of document.cookie