feat: Add initial Svelte frontend for ESP32 system monitoring and reboot control.

This commit is contained in:
2026-03-02 20:21:32 -05:00
parent 9b4f94207c
commit 6d457e4744
4 changed files with 243 additions and 11 deletions

View File

@@ -0,0 +1,35 @@
/**
* API layer for Calendink Provider ESP32-S3 dashboard.
*
* VITE_API_BASE controls the backend URL:
* - Development (PC): "http://<ESP32_IP>" (set in .env.development)
* - Production (ESP32): "" (empty = relative URLs, same origin)
*/
const API_BASE = import.meta.env.VITE_API_BASE || '';
/**
* Fetch system information from the ESP32.
* @returns {Promise<{chip: string, freeHeap: number, uptime: number, firmware: string, connection: string}>}
*/
export async function getSystemInfo() {
const res = await fetch(`${API_BASE}/api/system/info`);
if (!res.ok) {
throw new Error(`HTTP ${res.status}: ${res.statusText}`);
}
return res.json();
}
/**
* Send a reboot command to the ESP32.
* @returns {Promise<{message: string}>}
*/
export async function reboot() {
const res = await fetch(`${API_BASE}/api/system/reboot`, {
method: 'POST',
});
if (!res.ok) {
throw new Error(`HTTP ${res.status}: ${res.statusText}`);
}
return res.json();
}