Commit 1dd25986 authored by Vitaly Lipatov's avatar Vitaly Lipatov

router: show last update timestamp alongside countdown timer

parent 574357b4
...@@ -271,7 +271,7 @@ HTML_PAGE = """\ ...@@ -271,7 +271,7 @@ HTML_PAGE = """\
<div id="list-direct"></div> <div id="list-direct"></div>
</div> </div>
</div> </div>
<p class="note"><span id="countdown">Изменения применятся в течение 5 минут</span> · <a href="/swagger">API docs</a></p> <p class="note"><span id="last-update"></span><span id="countdown">Изменения применятся в течение 5 минут</span> · <a href="/swagger">API docs</a></p>
<script> <script>
const $ = id => document.getElementById(id); const $ = id => document.getElementById(id);
...@@ -412,7 +412,11 @@ refresh(); ...@@ -412,7 +412,11 @@ refresh();
function poll() { function poll() {
fetch('/api/active').then(r => r.json()).then(d => { fetch('/api/active').then(r => r.json()).then(d => {
if (d.updated) nextUpdate = (d.updated + INTERVAL) * 1000; if (d.updated) {
nextUpdate = (d.updated + INTERVAL) * 1000;
const ts = new Date(d.updated * 1000);
$('last-update').textContent = 'Обновлено ' + ts.toLocaleString('ru') + ' · ';
}
tick(); tick();
}).catch(() => { }).catch(() => {
el.textContent = 'Изменения применятся в течение 5 минут'; el.textContent = 'Изменения применятся в течение 5 минут';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment