196 строки
8.2 KiB
HTML
196 строки
8.2 KiB
HTML
<!doctype html>
|
|
<html lang="ru">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Обновления — {{ app_name }}</title>
|
|
<link rel="stylesheet" href="/static/app.css">
|
|
</head>
|
|
<body>
|
|
<div class="shell">
|
|
<header class="topbar">
|
|
<div>
|
|
<div class="brand">Обновления</div>
|
|
<div class="muted">GitHub update center: автоматический мониторинг, changelog и установка</div>
|
|
</div>
|
|
<div class="top-meta">
|
|
<span>user: {{ user }}</span>
|
|
<a class="link-pill" href="/">← Дашборд</a>
|
|
<form method="post" action="/logout" class="logout-form"><button class="ghost">Выйти</button></form>
|
|
</div>
|
|
</header>
|
|
|
|
{% if error %}
|
|
<div class="alert danger">{{ error }}</div>
|
|
{% endif %}
|
|
|
|
<section class="grid stats">
|
|
<article class="card stat">
|
|
<div class="label">Текущая версия</div>
|
|
<div class="value small">{{ info.current_version }}</div>
|
|
</article>
|
|
<article class="card stat">
|
|
<div class="label">Новая версия</div>
|
|
<div class="value small">{{ info.latest_version }}</div>
|
|
</article>
|
|
<article class="card stat">
|
|
<div class="label">Статус</div>
|
|
<div class="value small">{{ 'Есть обновление' if info.has_update else 'Актуально' }}</div>
|
|
<span class="status {{ 'warn' if info.has_update else 'ok' }}">{{ 'update' if info.has_update else 'ok' }}</span>
|
|
</article>
|
|
<article class="card stat">
|
|
<div class="label">Последняя проверка</div>
|
|
<div class="value small" id="last-check-value">{{ info.checked_at }}</div>
|
|
</article>
|
|
</section>
|
|
|
|
<section class="grid two">
|
|
<article class="card">
|
|
<div class="card-head">
|
|
<h2>Проверка GitHub</h2>
|
|
<span class="pill">{{ info.remote }}/{{ info.branch }}</span>
|
|
</div>
|
|
<div class="meta-grid">
|
|
<div><span>Source</span><strong>{{ info.source_dir }}</strong></div>
|
|
<div><span>Local commit</span><strong>{{ info.current_commit[:12] if info.current_commit else 'unknown' }}</strong></div>
|
|
<div><span>Remote commit</span><strong>{{ info.latest_commit[:12] if info.latest_commit else 'unknown' }}</strong></div>
|
|
</div>
|
|
{% if not info.fetch_ok %}
|
|
<div class="alert danger top-space">GitHub fetch вернул ошибку: {{ info.fetch_error }}</div>
|
|
{% endif %}
|
|
<div class="notice top-space">
|
|
Проверка обновлений выполняется автоматически при открытии страницы и дальше каждые 5 минут. Ручная кнопка убрана — меньше лишних действий, больше порядка.
|
|
</div>
|
|
<div class="actions top-space">
|
|
{% if info.has_update %}
|
|
<form method="post" action="/update/apply" onsubmit="return confirm('Запустить обновление Virtuality из GitHub? Панель перезапустится.');">
|
|
<button class="primary">Установить обновление</button>
|
|
</form>
|
|
{% else %}
|
|
<button disabled>Установить обновление</button>
|
|
{% endif %}
|
|
</div>
|
|
</article>
|
|
|
|
<article class="card">
|
|
<div class="card-head">
|
|
<h2>Состояние установки</h2>
|
|
<span id="update-status-badge" class="status {{ 'ok' if info.state.status == 'success' else 'err' if info.state.status == 'error' else 'warn' }}">{{ info.state.status }}</span>
|
|
</div>
|
|
<div id="update-message" class="notice">{{ info.state.message }}</div>
|
|
<div class="meta-grid top-space">
|
|
<div><span>Started</span><strong id="update-started">{{ info.state.started_at or '—' }}</strong></div>
|
|
<div><span>Updated</span><strong id="update-updated">{{ info.state.updated_at or '—' }}</strong></div>
|
|
<div><span>Finished</span><strong id="update-finished">{{ info.state.finished_at or '—' }}</strong></div>
|
|
</div>
|
|
</article>
|
|
</section>
|
|
|
|
<section class="card">
|
|
<div class="card-head">
|
|
<h2>Пропущенные версии и функции</h2>
|
|
<span class="pill">{{ info.missing_versions|length }} версий</span>
|
|
</div>
|
|
{% for release in info.missing_versions %}
|
|
<div class="release-note">
|
|
<div class="card-head compact">
|
|
<h2>{{ release.version }} · {{ release.title }}</h2>
|
|
<span class="pill">{{ release.date }}</span>
|
|
</div>
|
|
<p class="muted">{{ release.summary }}</p>
|
|
<ul>
|
|
{% for feature in release.features %}
|
|
<li>{{ feature }}</li>
|
|
{% endfor %}
|
|
</ul>
|
|
</div>
|
|
{% else %}
|
|
<div class="muted">Нет пропущенных версий. Система на свежем коде, красота.</div>
|
|
{% endfor %}
|
|
</section>
|
|
|
|
<section class="grid two">
|
|
<article class="card">
|
|
<div class="card-head">
|
|
<h2>Новые коммиты</h2>
|
|
<span class="pill">{{ info.commits|length }}</span>
|
|
</div>
|
|
<div class="services">
|
|
{% for commit in info.commits %}
|
|
<div class="service-row">
|
|
<span><strong>{{ commit.short }}</strong><small>{{ commit.subject }} · {{ commit.date }}</small></span>
|
|
</div>
|
|
{% else %}
|
|
<div class="muted">Новых коммитов нет.</div>
|
|
{% endfor %}
|
|
</div>
|
|
</article>
|
|
|
|
<article class="card">
|
|
<div class="card-head">
|
|
<h2>Лог обновления</h2>
|
|
<span id="update-log-state" class="pill">live</span>
|
|
</div>
|
|
<pre id="update-log">{{ info.log_tail or 'Лог пока пуст.' }}</pre>
|
|
</article>
|
|
</section>
|
|
</div>
|
|
|
|
<script>
|
|
const statusBadge = document.getElementById('update-status-badge');
|
|
const messageBox = document.getElementById('update-message');
|
|
const startedBox = document.getElementById('update-started');
|
|
const updatedBox = document.getElementById('update-updated');
|
|
const finishedBox = document.getElementById('update-finished');
|
|
const logBox = document.getElementById('update-log');
|
|
const logState = document.getElementById('update-log-state');
|
|
const lastCheckBox = document.getElementById('last-check-value');
|
|
let autoCheckRunning = false;
|
|
|
|
function statusClass(status) {
|
|
if (status === 'success') return 'status ok';
|
|
if (status === 'error') return 'status err';
|
|
return 'status warn';
|
|
}
|
|
|
|
async function refreshUpdateStatus() {
|
|
try {
|
|
const response = await fetch('/update/status', {cache: 'no-store'});
|
|
const payload = await response.json();
|
|
if (!payload.ok) return;
|
|
const state = payload.state || {};
|
|
statusBadge.textContent = state.status || 'idle';
|
|
statusBadge.className = statusClass(state.status || 'idle');
|
|
messageBox.textContent = state.message || 'Готово к проверке обновлений';
|
|
startedBox.textContent = state.started_at || '—';
|
|
updatedBox.textContent = state.updated_at || '—';
|
|
finishedBox.textContent = state.finished_at || '—';
|
|
logBox.textContent = payload.log_tail || 'Лог пока пуст.';
|
|
logState.textContent = 'live · ' + (payload.checked_at || 'now');
|
|
} 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;
|
|
}
|
|
}
|
|
|
|
refreshUpdateStatus();
|
|
autoCheckUpdates();
|
|
setInterval(refreshUpdateStatus, 2000);
|
|
setInterval(autoCheckUpdates, 300000);
|
|
</script>
|
|
</body>
|
|
</html>
|