view service/mqtt_graph_bridge/index.html @ 1497:44de96fd0e6e

add publish to ON/OFF messages. split up the main statement handler Ignore-this: b1ec515e6873a6841b1c31c3fb7a2a36 darcs-hash:5ce3d7a66e7e45b2be2345a52e737cd0426dd985
author drewp <drewp@bigasterisk.com>
date Fri, 31 Jan 2020 23:55:27 -0800
parents e2d5290bef22
children
line wrap: on
line source

<!doctype html>
<html>
  <head>
    <title>mqtt_graph_bridge</title>
    <meta charset="utf-8">
    <script src="/lib/polymer/1.0.9/webcomponentsjs/webcomponents.min.js"></script>
    <script src="/lib/require/require-2.3.3.js"></script>
    <script src="/rdf/common_paths_and_ns.js"></script>

    <link rel="stylesheet" href="/rdf/browse/style.css">

  </head>
  <body class="rdfBrowsePage">
    mqtt_graph_bridge


    <p>Send demo statements to bridge:</p>
    <div><button data-post="output?s=:kitchenLight&p=:brightness" data-body="0.0">Send (:kitchenLight :brightness 0.0)</button></div>
    <div><button data-post="output?s=:kitchenLight&p=:brightness" data-body="1.0">Send (:kitchenLight :brightness 1.0)</button></div>
    <div><button data-post="output?s=:livingLampShelf&p=:brightness" data-body="0.0">Send (:livingLampShelf :brightness 0.0)</button></div>
    <div><button data-post="output?s=:livingLampShelf&p=:brightness" data-body="1.0">Send (:livingLampShelf :brightness 1.0)</button></div>

    <script>
     Array.from(document.querySelectorAll("button")).forEach((el) => {
       el.addEventListener("click", (ev) => {
         fetch(el.dataset.post, {
           method: "PUT",
           body: el.dataset.body
         });
       });
     });
    </script>

  </body>
</html>