summaryrefslogtreecommitdiff
path: root/appdata/index.html.tmpl
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2023-03-27 17:57:19 +0200
committerxengineering <me@xengineering.eu>2023-03-27 17:57:19 +0200
commitd7ce7860bf47ad1f51a44a9705eb0dbf1825eb66 (patch)
tree49f36a991a4777aa3e6cee4b43e8d83668e4e7dd /appdata/index.html.tmpl
parent5d1d9e09e3fd26228230bb325ca3d5ddf2576070 (diff)
downloadwebiot-d7ce7860bf47ad1f51a44a9705eb0dbf1825eb66.tar
webiot-d7ce7860bf47ad1f51a44a9705eb0dbf1825eb66.tar.zst
webiot-d7ce7860bf47ad1f51a44a9705eb0dbf1825eb66.zip
Pass appdata directory by argument
Passing this as part of the configuration file is not flexible. With args it can be easily tweaked for the debug use case while the default path for production is included in the argument parsing.
Diffstat (limited to 'appdata/index.html.tmpl')
-rw-r--r--appdata/index.html.tmpl49
1 files changed, 49 insertions, 0 deletions
diff --git a/appdata/index.html.tmpl b/appdata/index.html.tmpl
new file mode 100644
index 0000000..17c67c1
--- /dev/null
+++ b/appdata/index.html.tmpl
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+
+<!--
+ vim: shiftwidth=4 tabstop=4 noexpandtab
+-->
+
+<html>
+
+ <head>
+
+ <title>IoT</title>
+
+ <meta charset="utf-8"/>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <link rel="stylesheet" href="./webiot.css" type="text/css">
+
+ </head>
+
+ <body>
+
+ <main>
+
+ <h1>IoT</h1>
+
+ {{range .Hs100}}
+ <div class="card">
+ <h3 class="card-first-item">{{.Name}}</h3>
+ <button onclick="api('{{.Ip}}', 'on')">on</button>
+ <button class="card-last-item" onclick="api('{{.Ip}}', 'off')">off</button>
+ </div>
+ {{end}}
+
+ <script>
+ function api(host, state) {
+ const xhttp = new XMLHttpRequest();
+ xhttp.open(
+ "POST",
+ "/api?host=" + host + "&state=" + state,
+ true
+ );
+ xhttp.send();
+ }
+ </script>
+
+ </main>
+
+ </body>
+
+</html>