Auto refresh

This commit is contained in:
2026-06-02 04:02:00 -04:00
parent 278303f541
commit 1fd7803f12
5 changed files with 114 additions and 2 deletions
+6 -1
View File
@@ -6,16 +6,21 @@
<title>{% block title %}SwitchBot Temps{% endblock %}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
</head>
<body>
<body
data-collect-interval-seconds="{{ collect_interval_seconds }}"
data-auto-refresh="{{ 'true' if request.path == '/' or request.path.startswith('/devices/') else 'false' }}"
>
<header class="topbar">
<a class="brand" href="/">SwitchBot Temps</a>
<nav class="nav">
<a href="/" {% if request.path == "/" %}aria-current="page"{% endif %}>Dashboard</a>
<a href="/reports" {% if request.path == "/reports" %}aria-current="page"{% endif %}>Reports</a>
</nav>
<p class="refresh-status" id="refreshStatus" aria-live="polite"></p>
</header>
<main class="page">
{% block content %}{% endblock %}
</main>
<script src="{{ url_for('static', filename='auto_refresh.js') }}"></script>
</body>
</html>
+2
View File
@@ -17,6 +17,7 @@
{% for device in devices %}
{% set reading = latest.get(device.id) %}
{% set stat = stats.get(device.id) %}
{% set collected_age = latest_relative.get(device.id) %}
<a class="metric-card metric-link" href="/devices/{{ device.id }}">
<div class="card-heading">
<h2>{{ device.name }}</h2>
@@ -27,6 +28,7 @@
<strong>{{ "%.1f"|format(reading.temperature) if reading.temperature is not none else "n/a" }}&deg;C</strong>
<span>{{ reading.humidity if reading.humidity is not none else "n/a" }}% RH</span>
</div>
<p class="muted">{{ collected_age or "n/a" }}</p>
<dl class="mini-stats">
<div>
<dt>Day low</dt>