Enhance eMMC provisioning dashboard: add backups directory information to API response, update UI to include a refresh button for saved backups, and improve user instructions for setting golden images.

This commit is contained in:
nearxos
2026-02-19 00:15:47 +02:00
parent d76e19169c
commit a3661df8c2
2 changed files with 12 additions and 5 deletions

View File

@@ -332,7 +332,7 @@ def api_backup_upload():
@app.route("/api/backups") @app.route("/api/backups")
def api_backups(): def api_backups():
return jsonify({"backups": list_backups()}) return jsonify({"backups": list_backups(), "backups_dir": str(BACKUPS_DIR)})
@app.route("/api/backups/<path:name>/set-as-golden", methods=["POST"]) @app.route("/api/backups/<path:name>/set-as-golden", methods=["POST"])

View File

@@ -399,8 +399,9 @@
<!-- 3. Saved backups --> <!-- 3. Saved backups -->
<section class="section"> <section class="section">
<h2 class="section-title">Saved backups</h2> <h2 class="section-title">Saved backups <button type="button" class="btn btn-outline btn-sm" id="refreshBackupsBtn" title="Reload list">Refresh</button></h2>
<p id="goldenHint" class="backups-mono" style="margin-bottom:0.75rem;font-size:0.8rem;"></p> <p id="goldenHint" class="backups-mono" style="margin-bottom:0.25rem;font-size:0.8rem;"></p>
<p id="backupsDirHint" class="backups-mono" style="margin-bottom:0.75rem;font-size:0.75rem;color:var(--muted);"></p>
<table class="backups-table" id="backupsTable"> <table class="backups-table" id="backupsTable">
<thead> <thead>
<tr> <tr>
@@ -757,7 +758,11 @@
fetch('/api/log').then(function(r) { return r.json(); }).then(function(d) { document.getElementById('log').textContent = d.log || ''; }).catch(function() {}); fetch('/api/log').then(function(r) { return r.json(); }).then(function(d) { document.getElementById('log').textContent = d.log || ''; }).catch(function() {});
} }
function fetchBackups() { function fetchBackups() {
fetch('/api/backups').then(function(r) { return r.json(); }).then(function(d) { renderBackups(d.backups || []); }).catch(function() {}); fetch('/api/backups').then(function(r) { return r.json(); }).then(function(d) {
renderBackups(d.backups || []);
var dirEl = document.getElementById('backupsDirHint');
if (dirEl && d.backups_dir) dirEl.textContent = 'Stored in: ' + d.backups_dir;
}).catch(function() {});
} }
function getBuildVariant() { function getBuildVariant() {
@@ -839,7 +844,7 @@
if (d.phase === 'idle' && !d.message) { if (d.phase === 'idle' && !d.message) {
el.textContent = ''; el.textContent = '';
} else if (d.phase === 'done') { } else if (d.phase === 'done') {
el.textContent = 'Done: ' + (d.output_name || '') + ' — see Saved backups below. Set as golden to use for Deploy.'; el.textContent = 'Done: ' + (d.output_name || '') + ' — see Saved backups above. Click "Set as golden" next to it to use for Deploy. If missing, click Refresh.';
fetchBackups(); fetchBackups();
fetchGoldenInfo(); fetchGoldenInfo();
} else if (d.phase === 'error') { } else if (d.phase === 'error') {
@@ -894,6 +899,8 @@
document.getElementById('statusClearBtn').addEventListener('click', function() { document.getElementById('statusClearBtn').addEventListener('click', function() {
fetch('/api/status-clear', { method: 'POST' }).then(function(r) { return r.json(); }).then(function(d) { if (d.ok) fetchStatus(); }); fetch('/api/status-clear', { method: 'POST' }).then(function(r) { return r.json(); }).then(function(d) { if (d.ok) fetchStatus(); });
}); });
var refreshBackupsBtn = document.getElementById('refreshBackupsBtn');
if (refreshBackupsBtn) refreshBackupsBtn.onclick = function() { fetchBackups(); fetchGoldenInfo(); };
fetchStatus(); fetchStatus();
fetchLog(); fetchLog();