From 86c1ee145c26277d2e9ee3b6e0fc6d6575956b28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B8=D0=BA=D1=82=D0=BE=D1=80?= <78488229+viktor138irk@users.noreply.github.com> Date: Thu, 7 May 2026 09:38:42 +0900 Subject: [PATCH] =?UTF-8?q?Update=20Center=20=D0=B1=D1=8B=D0=BB=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=B2=D0=B5=D0=B4=D1=91=D0=BD=20=D0=BD=D0=B0?= =?UTF-8?q?=20=D1=80=D1=83=D1=87=D0=BD=D1=83=D1=8E=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D0=BA=D1=83=20=D0=B8=20=D0=BA=D0=BD=D0=BE?= =?UTF-8?q?=D0=BF=D0=BA=D1=83=20=D1=83=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/templates/update.html | 58 ++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/web/templates/update.html b/web/templates/update.html index eb20088..e517690 100644 --- a/web/templates/update.html +++ b/web/templates/update.html @@ -11,7 +11,7 @@
Обновления
-
GitHub update center: автоматический мониторинг, changelog и установка
+
GitHub update center: changelog, проверка и установка
user: {{ user }} @@ -58,16 +58,14 @@ {% if not info.fetch_ok %}
GitHub fetch вернул ошибку: {{ info.fetch_error }}
{% endif %} -
- Проверка обновлений выполняется автоматически при открытии страницы и дальше каждые 5 минут. Ручная кнопка убрана — меньше лишних действий, больше порядка. -
-
+
+
+ +
{% if info.has_update %} -
- + +
- {% else %} - {% endif %}
@@ -105,7 +103,7 @@
{% else %} -
Нет пропущенных версий. Система на свежем коде, красота.
+
Нет пропущенных версий. Система на свежем коде.
{% endfor %} @@ -145,7 +143,10 @@ const logBox = document.getElementById('update-log'); const logState = document.getElementById('update-log-state'); const lastCheckBox = document.getElementById('last-check-value'); - let autoCheckRunning = false; + const checkForm = document.getElementById('update-check-form'); + const applyForm = document.getElementById('update-apply-form'); + const mainButton = document.getElementById('update-main-button'); + const applyButton = document.getElementById('update-apply-button'); function statusClass(status) { if (status === 'success') return 'status ok'; @@ -153,6 +154,15 @@ return 'status warn'; } + function stageText(state) { + const status = state.status || 'idle'; + const message = state.message || ''; + if (status === 'running') return message || 'Установка выполняется'; + if (status === 'success') return 'Обновление установлено'; + if (status === 'error') return 'Ошибка обновления'; + return message || 'Готово'; + } + async function refreshUpdateStatus() { try { const response = await fetch('/update/status', {cache: 'no-store'}); @@ -167,29 +177,27 @@ finishedBox.textContent = state.finished_at || '—'; logBox.textContent = payload.log_tail || 'Лог пока пуст.'; logState.textContent = 'live · ' + (payload.checked_at || 'now'); + if (applyButton && state.status === 'running') applyButton.textContent = stageText(state); } catch (error) { logState.textContent = 'live error'; } } - async function autoCheckUpdates() { - if (autoCheckRunning) return; - autoCheckRunning = true; - try { - await fetch('/update/check', {method: 'POST', cache: 'no-store', redirect: 'follow'}); - const now = new Date().toLocaleString(); - if (lastCheckBox) lastCheckBox.textContent = now; - } catch (error) { - if (logState) logState.textContent = 'check error'; - } finally { - autoCheckRunning = false; - } + if (checkForm) { + checkForm.addEventListener('submit', () => { + if (mainButton) mainButton.textContent = 'Проверяем GitHub...'; + }); + } + if (applyForm) { + applyForm.addEventListener('submit', () => { + if (applyButton) applyButton.textContent = 'Запускаем обновление...'; + setTimeout(refreshUpdateStatus, 1200); + setTimeout(refreshUpdateStatus, 2600); + }); } refreshUpdateStatus(); - autoCheckUpdates(); setInterval(refreshUpdateStatus, 2000); - setInterval(autoCheckUpdates, 300000);