diff --git a/platypush/backend/http/static/css/switch.switchbot.css b/platypush/backend/http/static/css/switch.switchbot.css new file mode 100644 index 000000000..d03674040 --- /dev/null +++ b/platypush/backend/http/static/css/switch.switchbot.css @@ -0,0 +1,29 @@ +#switchbot-container { + background-color: #f8f8f8; + padding: 12px; + border: 1px solid #ddd; + border-radius: 10px; + font-family: "Raleway", "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif; + font-weight: 400; + line-height: 38px; + letter-spacing: .1rem; +} + +.switchbot-device { + padding: 1.5em 1em .2em .5em; + border-radius: 10px; +} + + .switchbot-device:nth-of-type(odd) { + background-color: #ececec; + } + + .switchbot-device:hover { + background-color: #daf8e2 !important; + } + +.toggle-container { + text-align: right; + padding-right: 1em; +} + diff --git a/platypush/backend/http/static/js/switch.switchbot.js b/platypush/backend/http/static/js/switch.switchbot.js new file mode 100644 index 000000000..a3e7b1e64 --- /dev/null +++ b/platypush/backend/http/static/js/switch.switchbot.js @@ -0,0 +1,33 @@ +$(document).ready(function() { + var switches, + $switchbotContainer = $('#switchbot-container'); + + var initBindings = function() { + $switchbotContainer.on('click touch', '.switch-ctrl-container', function() { + var $input = $(this).find('.switch-ctrl'); + var addr = $input.attr('name'); + $input.prop('checked', true); + + execute( + { + type: 'request', + action: 'switch.switchbot.press', + args: { + device: addr + } + }, + + onSuccess = function(response) { + $input.prop('checked', false); + } + ); + }); + }; + + var init = function() { + initBindings(); + }; + + init(); +}); + diff --git a/platypush/backend/http/templates/plugins/switch.switchbot.html b/platypush/backend/http/templates/plugins/switch.switchbot.html new file mode 100644 index 000000000..a0113fce1 --- /dev/null +++ b/platypush/backend/http/templates/plugins/switch.switchbot.html @@ -0,0 +1,17 @@ + + + +