|
|
@@ -1,46 +1,110 @@
|
|
|
<% layout("/en/layout") %>
|
|
|
|
|
|
-<%~ include("/en/partials/navbar") %>
|
|
|
-
|
|
|
-<% if (it.data?.[0]) { %>
|
|
|
-<div class="stats">
|
|
|
- <div class="indoor">
|
|
|
- <h3>indoor</h3>
|
|
|
- <p>temp: <%= it.data?.[0].indoorTemp / 100 %> °C</p>
|
|
|
- <p>pressure: <%= it.data?.[0].indoorPressure / 100 %> hPa</p>
|
|
|
- <p>humidity: <%= it.data?.[0].indoorHumidity / 100 %>%</p>
|
|
|
- <p>altitude: <%= it.data?.[0].indoorAltitude / 100 %>m</p>
|
|
|
- </div>
|
|
|
- <div class="outdoor">
|
|
|
- <h3>outdoor</h3>
|
|
|
- <p>connected: <%= it.data?.[0].outdoorConnected %></p>
|
|
|
- <p>temp: <%= it.data?.[0].outdoorTemp / 100 %> °C</p>
|
|
|
- <p>pressure: <%= it.data?.[0].outdoorPressure / 100 %> hPa</p>
|
|
|
- <p>humidity: <%= it.data?.[0].outdoorHumidity / 100 %>%</p>
|
|
|
- <p>altitude: <%= it.data?.[0].outdoorAltitude / 100 %>m</p>
|
|
|
+<%~ include("/en/partials/topbar") %>
|
|
|
+
|
|
|
+<% const tickIcon = `
|
|
|
+ <svg class="icon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
|
|
+ <g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
|
|
|
+ <circle cx="12" cy="12" r="10" />
|
|
|
+ <path d="m9 12l2 2l4-4" />
|
|
|
+ </g>
|
|
|
+ </svg>
|
|
|
+` %>
|
|
|
+
|
|
|
+<% const xIcon = `
|
|
|
+ <svg class="icon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
|
|
+ <g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
|
|
|
+ <circle cx="12" cy="12" r="10" />
|
|
|
+ <path d="m15 9l-6 6m0-6l6 6" />
|
|
|
+ </g>
|
|
|
+ </svg>
|
|
|
+` %>
|
|
|
+
|
|
|
+<% const tempIcon = `
|
|
|
+ <svg class="icon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
|
|
+ <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0" />
|
|
|
+ </svg>
|
|
|
+` %>
|
|
|
+
|
|
|
+<% const pressureIcon = `
|
|
|
+ <svg class="icon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
|
|
+ <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m12 14l4-4M3.34 19a10 10 0 1 1 17.32 0" />
|
|
|
+ </svg>
|
|
|
+` %>
|
|
|
+
|
|
|
+<% const humidityIcon = `
|
|
|
+ <svg class="icon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
|
|
+ <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5S5 13 5 15a7 7 0 0 0 7 7" />
|
|
|
+ </svg>
|
|
|
+` %>
|
|
|
+
|
|
|
+<% const altitudeIcon = `
|
|
|
+ <svg class="icon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
|
|
+ <g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
|
|
|
+ <circle cx="12" cy="12" r="10" />
|
|
|
+ <path d="m16 12l-4-4l-4 4m4 4V8" />
|
|
|
+ </g>
|
|
|
+ </svg>
|
|
|
+` %>
|
|
|
+
|
|
|
+<div id="mainStats">
|
|
|
+ <% /* <div class="message">
|
|
|
+ <p>oops</p>
|
|
|
+ </div> */ %>
|
|
|
+
|
|
|
+ <div class="stats">
|
|
|
+ <div class="wrapper">
|
|
|
+ <h3>indoor</h3>
|
|
|
+ <div class="values indoor">
|
|
|
+ <p><%~ tempIcon %> <span id="indoorTemp"><%= it.data?.[0]?.indoorTemp / 100 %></span> °C</p>
|
|
|
+ <p><%~ pressureIcon %> <span id="indoorPressure"><%= it.data?.[0]?.indoorPressure / 100 %></span> hPa</p>
|
|
|
+ <p><%~ humidityIcon %> <span id="indoorHumidity"><%= it.data?.[0]?.indoorHumidity / 100 %></span> %</p>
|
|
|
+ <p><%~ altitudeIcon %> <span id="indoorAltitude"><%= it.data?.[0]?.indoorAltitude / 100 %></span> m</p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="wrapper">
|
|
|
+ <h3>outdoor</h3>
|
|
|
+ <div class="values outdoor">
|
|
|
+ <p id="outdoorConnected"><%~ it.data?.[0]?.outdoorConnected ? `${tickIcon} connected` : `${xIcon} disconnected` %></p>
|
|
|
+ <p><%~ tempIcon %> <span id="outdoorTemp"><%= it.data?.[0]?.outdoorTemp / 100 %></span> °C</p>
|
|
|
+ <p><%~ pressureIcon %> <span id="outdoorPressure"><%= it.data?.[0]?.outdoorPressure / 100 %></span> hPa</p>
|
|
|
+ <p><%~ humidityIcon %> <span id="outdoorHumidity"><%= it.data?.[0]?.outdoorHumidity / 100 %></span> %</p>
|
|
|
+ <p><%~ altitudeIcon %> <span id="outdoorAltitude"><%= it.data?.[0]?.outdoorAltitude / 100 %></span> m</p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
-<% } %>
|
|
|
-
|
|
|
-<h3>data</h3>
|
|
|
-
|
|
|
-<% if (it.data?.length) { %>
|
|
|
- <div>
|
|
|
- <table>
|
|
|
- <tr>
|
|
|
- <th>time</th>
|
|
|
- <th>indoor</th>
|
|
|
- <th>outdoor</th>
|
|
|
- </tr>
|
|
|
- <% for (const item of it.data) { %>
|
|
|
- <tr>
|
|
|
- <td><%= item.timestamp %></td>
|
|
|
- <td><strong>temp:</strong> <%= item.indoorTemp / 100 %> °C, <strong>pressure:</strong> <%= item.indoorPressure / 100 %> hPa, <strong>humidity:</strong> <%= item.indoorHumidity / 100 %>%, <strong>altitude:</strong> <%= item.indoorAltitude / 100 %>m</td>
|
|
|
- <td><strong>connected:</strong> <%= item.outdoorConnected %>, <strong>temp:</strong> <%= item.outdoorTemp / 100 %> °C, <strong>pressure:</strong> <%= item.outdoorPressure / 100%>hPa, <strong>humidity:</strong> <%= item.outdoorHumidity / 100 %>%, <strong>altitude:</strong> <%= item.outdoorAltitude / 100 %>m</td>
|
|
|
- </tr>
|
|
|
- <% } %>
|
|
|
- </table>
|
|
|
- </div>
|
|
|
-<% } else { %>
|
|
|
- <p>no data yet. :(</p>
|
|
|
-<% } %>
|
|
|
+
|
|
|
+<script defer>
|
|
|
+ setInterval(async () => {
|
|
|
+ const response = await fetch('/currentData')
|
|
|
+ const data = await response.json()
|
|
|
+
|
|
|
+ const indoorTemp = document.querySelector(`#indoorTemp`)
|
|
|
+ const indoorPressure = document.querySelector(`#indoorPressure`)
|
|
|
+ const indoorHumidity = document.querySelector(`#indoorHumidity`)
|
|
|
+ const indoorAltitude = document.querySelector(`#indoorAltitude`)
|
|
|
+
|
|
|
+ const outdoorConnected = document.querySelector(`#outdoorConnected`)
|
|
|
+ const outdoorTemp = document.querySelector(`#outdoorTemp`)
|
|
|
+ const outdoorPressure = document.querySelector(`#outdoorPressure`)
|
|
|
+ const outdoorHumidity = document.querySelector(`#outdoorHumidity`)
|
|
|
+ const outdoorAltitude = document.querySelector(`#outdoorAltitude`)
|
|
|
+
|
|
|
+ indoorTemp.textContent = data?.indoorTemp / 100
|
|
|
+ indoorPressure.textContent = data?.indoorPressure / 100
|
|
|
+ indoorHumidity.textContent = data?.indoorHumidity / 100
|
|
|
+ indoorAltitude.textContent = data?.indoorAltitude / 100
|
|
|
+
|
|
|
+ const tickIcon = `<%~ tickIcon %>`
|
|
|
+
|
|
|
+ const xIcon = `<%~ xIcon %>`
|
|
|
+
|
|
|
+ outdoorConnected.innerHTML = data?.outdoorConnected ? `${tickIcon} connected` : `${xIcon} disconnected`
|
|
|
+ outdoorTemp.textContent = data?.outdoorTemp / 100
|
|
|
+ outdoorPressure.textContent = data?.outdoorPressure / 100
|
|
|
+ outdoorHumidity.textContent = data?.outdoorHumidity / 100
|
|
|
+ outdoorAltitude.textContent = data?.outdoorAltitude / 100
|
|
|
+ }, 10000)
|
|
|
+</script>
|