feat: add Sync Time button to Device page in web UI

Adds a 'Sync Time' button in the Device Actions section that calls
POST /api/action/sync-time to trigger NTP sync and RTC write.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-05 20:57:53 -04:00
parent 3051122742
commit 39e240dd35

View File

@@ -237,6 +237,7 @@ async function renderDevice(el) {
<div class="card"> <div class="card">
<h2>Device Actions</h2> <h2>Device Actions</h2>
<div class="btn-group"> <div class="btn-group">
<button class="btn" id="syncTime">Sync Time</button>
<button class="btn btn-danger" onclick="if(confirm('Enter deep sleep?'))api('/api/action/sleep',{method:'POST'})">Deep Sleep</button> <button class="btn btn-danger" onclick="if(confirm('Enter deep sleep?'))api('/api/action/sleep',{method:'POST'})">Deep Sleep</button>
<button class="btn btn-danger" onclick="if(confirm('Reboot device?'))fetch('/api/action/reboot',{method:'POST'})">Reboot</button> <button class="btn btn-danger" onclick="if(confirm('Reboot device?'))fetch('/api/action/reboot',{method:'POST'})">Reboot</button>
</div> </div>
@@ -263,6 +264,12 @@ async function renderDevice(el) {
status.style.color = '#c62828'; status.style.color = '#c62828';
} }
}; };
document.getElementById('syncTime').onclick = async () => {
toast('Syncing...');
const result = await api('/api/action/sync-time', { method: 'POST' });
toast(result.msg || 'Time synced');
};
} }
async function renderFirmware(el) { async function renderFirmware(el) {