Add API endpoint to clear status and update UI with hints for golden image handling in eMMC provisioning dashboard

This commit is contained in:
nearxos
2026-02-18 14:29:38 +02:00
parent c42e7951d0
commit ccdace36bc
2 changed files with 30 additions and 0 deletions

View File

@@ -151,6 +151,22 @@ def api_status():
return jsonify(read_status()) return jsonify(read_status())
@app.route("/api/status-clear", methods=["POST"])
def api_status_clear():
"""Reset status to idle (e.g. to dismiss a 'Golden image not found' error so you can try again)."""
try:
with open(STATUS_FILE, "w") as f:
json.dump({
"phase": "idle",
"message": DEFAULT_STATUS["message"],
"progress": None,
"updated": None,
}, f)
return jsonify({"ok": True})
except (PermissionError, OSError):
return jsonify({"ok": False, "error": "Could not write status"}), 500
@app.route("/api/log") @app.route("/api/log")
def api_log(): def api_log():
return jsonify({"log": read_log_tail()}) return jsonify({"log": read_log_tail()})

View File

@@ -368,6 +368,10 @@
<span id="statusMsg" class="status-msg">Waiting for device</span> <span id="statusMsg" class="status-msg">Waiting for device</span>
</div> </div>
<div id="statusErr" class="status-err" style="display:none;"></div> <div id="statusErr" class="status-err" style="display:none;"></div>
<div id="statusGoldenHint" class="backup-deploy-hint" style="display:none; margin-top:0.75rem;">
No golden image is required to <strong>capture</strong>. Connect a device in USB boot mode (or register over network); when it appears under “Capture image or deploy”, click <strong>Backup</strong> to save its image. Then set that backup as golden in the list below.
<button type="button" id="statusClearBtn" class="btn btn-outline btn-sm" style="margin-left:0.5rem;">Clear message</button>
</div>
<div id="statusMeta" class="status-meta" style="display:none;"></div> <div id="statusMeta" class="status-meta" style="display:none;"></div>
<div id="progressWrap" class="progress-track" style="display:none;"> <div id="progressWrap" class="progress-track" style="display:none;">
<div id="progressFill" class="progress-fill"></div> <div id="progressFill" class="progress-fill"></div>
@@ -467,6 +471,12 @@
statusErr.style.display = 'none'; statusErr.style.display = 'none';
} }
var goldenHint = document.getElementById('statusGoldenHint');
if (goldenHint) {
var isGoldenError = phase === 'error' && /golden|Golden image/i.test((data.error || '') + (data.message || ''));
goldenHint.style.display = isGoldenError ? 'block' : 'none';
}
if (data.updated) { if (data.updated) {
statusMeta.textContent = 'Updated ' + data.updated; statusMeta.textContent = 'Updated ' + data.updated;
statusMeta.style.display = 'block'; statusMeta.style.display = 'block';
@@ -670,6 +680,10 @@
return d.innerHTML; return d.innerHTML;
} }
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(); });
});
fetchStatus(); fetchStatus();
fetchLog(); fetchLog();
fetchPending(); fetchPending();