diff --git a/platypush/backend/http/static/css/gpio.sensor.mcp3008.css b/platypush/backend/http/static/css/gpio.sensor.mcp3008.css new file mode 100644 index 000000000..e69de29bb diff --git a/platypush/backend/http/static/js/gpio.sensor.mcp3008.js b/platypush/backend/http/static/js/gpio.sensor.mcp3008.js new file mode 100644 index 000000000..86b897aef --- /dev/null +++ b/platypush/backend/http/static/js/gpio.sensor.mcp3008.js @@ -0,0 +1,47 @@ +$(document).ready(function() { + var $container = $('#sensors-container'); + + var onEvent = function(event) { + switch (event.args.type) { + case 'platypush.message.event.sensor.SensorDataChangeEvent': + var data = event.args.sensors; + + for (var sensor of Object.keys(data)) { + var $sensor = $container.find('[data-sensor-type=' + sensor + ']'); + var $sensorValue; + + if ($sensor.length === 0) { + $sensor = $('
') + .addClass('row sensor-data') + .attr('data-sensor-type', sensor); + + var $name = $('
') + .addClass('sensor-name six columns') + .text(sensor); + + $sensorValue = $('
') + .addClass('sensor-value six columns'); + + $sensor.appendTo($container); + } else { + $sensorValue = $sensor.find('.sensor-value'); + } + + $sensorValue.text(data[sensor]); + } + + break; + } + }; + + var initEvents = function() { + window.registerEventListener(onEvent); + }; + + var init = function() { + initEvents(); + }; + + init(); +}); + diff --git a/platypush/backend/http/templates/plugins/gpio.sensor.mcp3008.html b/platypush/backend/http/templates/plugins/gpio.sensor.mcp3008.html new file mode 100644 index 000000000..be1a5151c --- /dev/null +++ b/platypush/backend/http/templates/plugins/gpio.sensor.mcp3008.html @@ -0,0 +1,5 @@ + + + +
+