diff --git a/enervent-ctrl-python/html/coils/index.html b/enervent-ctrl-python/html/coils/index.html new file mode 100644 index 0000000..9962088 --- /dev/null +++ b/enervent-ctrl-python/html/coils/index.html @@ -0,0 +1,22 @@ + + + + + + +Enervent Pingvin Kotilämpö + + + + + + +
Coil values at
AddressValueSymbolDescription
+ + +

+

+
+
+ + \ No newline at end of file diff --git a/enervent-ctrl-python/html/index.html b/enervent-ctrl-python/html/index.html deleted file mode 100644 index 28a9118..0000000 --- a/enervent-ctrl-python/html/index.html +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - -Enervent Pingvin Kotilämpö - - - - - - -
Coil values at
AddressValueSymbolDescription
- - -

-

-
-
- - \ No newline at end of file diff --git a/enervent-ctrl-python/html/static/tabledata.css b/enervent-ctrl-python/html/static/tabledata.css new file mode 100644 index 0000000..2f03408 --- /dev/null +++ b/enervent-ctrl-python/html/static/tabledata.css @@ -0,0 +1,17 @@ +.addr { + text-align: center; +} +.val { + text-align: center; +} +#coils { + padding: 2pt; + border-collapse: collapse; +} +thead { + border-bottom: 1px solid; + text-align: left; +} +td { + padding: 2pt; +} \ No newline at end of file diff --git a/enervent-ctrl-python/html/static/tabledata.js b/enervent-ctrl-python/html/static/tabledata.js new file mode 100644 index 0000000..9cd8a95 --- /dev/null +++ b/enervent-ctrl-python/html/static/tabledata.js @@ -0,0 +1,42 @@ +// TODO: JS check +// checkboxes for live/reserved +function zeroPad(number) { + return ("0" + number).slice(-2) +} +function getData() { + now = new Date() + Y = now.getFullYear() + m = now.getMonth() + d = now.getDate() + H = zeroPad(now.getHours()) + M = zeroPad(now.getMinutes()) + S = zeroPad(now.getSeconds()) + document.getElementById('time').innerHTML = `${Y}-${m}-${d} ${H}:${M}:${S}` + + if (document.location.pathname == "/coils/") { + url = "/api/v1/coils" + } + else if (document.location.pathname == "/registers/") { + url = "/api/v1/registers" + } + error = false + fetch(url) + .then((response) => { + if (!response.ok) { + throw new Error(`Error fetching data: ${response.status}`) + } + return response.json() + }) + .then((coils) => { + document.getElementById('coildata').innerHTML = ""; + for (n=0; n${coils[n].address}\ + ${Number(coils[n].value)}\ + ${coils[n].symbol}\ + ${coils[n].description}` + document.getElementById('coildata').innerHTML += tablerow + } + }); + + if (!error) setTimeout(getData, 5*1000); +} \ No newline at end of file