48 lines
2.0 KiB
HTML
48 lines
2.0 KiB
HTML
|
|
<!doctype html>
|
||
|
|
<html>
|
||
|
|
<head>
|
||
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||
|
|
<title>ESP32-C3 first-run setup</title>
|
||
|
|
<style>
|
||
|
|
:root{font-family:system-ui,-apple-system,Segoe UI,sans-serif;color:#202124;background:#f5f7f8}
|
||
|
|
body{margin:0}.top{background:#263238;color:white;padding:14px 18px;font-weight:650}
|
||
|
|
main{max-width:1040px;margin:0 auto;padding:18px}
|
||
|
|
section,.box{background:white;border:1px solid #d8dee2;border-radius:8px;padding:14px}
|
||
|
|
label{display:block;font-size:13px;margin:10px 0 4px}input,select,textarea,button{font:inherit}
|
||
|
|
input,select,textarea{width:100%;box-sizing:border-box;padding:9px;border:1px solid #b9c2c8;border-radius:6px}
|
||
|
|
button{border:0;border-radius:6px;background:#1261a6;color:white;padding:9px 12px;cursor:pointer;margin-top:10px}
|
||
|
|
pre{white-space:pre-wrap;background:#111;color:#d7ffd7;padding:10px;border-radius:6px;max-height:300px;overflow:auto}
|
||
|
|
</style>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<div class="top">ESP32-C3 first-run setup</div>
|
||
|
|
<main>
|
||
|
|
<section>
|
||
|
|
<h2>Network and admin setup</h2>
|
||
|
|
<label>WiFi network</label>
|
||
|
|
<select id="ssid"></select>
|
||
|
|
<label>WiFi password</label>
|
||
|
|
<input id="wifiPass" type="password" autocomplete="off">
|
||
|
|
<label>Admin username</label>
|
||
|
|
<input id="admin" value="admin">
|
||
|
|
<label>Admin password</label>
|
||
|
|
<input id="adminPass" type="password" autocomplete="new-password">
|
||
|
|
<button onclick="save()">Save and restart</button>
|
||
|
|
<pre id="out"></pre>
|
||
|
|
</section>
|
||
|
|
</main>
|
||
|
|
<script>
|
||
|
|
async function scan(){
|
||
|
|
let r=await fetch('/api/wifi/scan'),j=await r.json();
|
||
|
|
ssid.innerHTML=j.networks.map(n=>`<option>${n.ssid}</option>`).join('');
|
||
|
|
}
|
||
|
|
async function save(){
|
||
|
|
let body={ssid:ssid.value,wifiPass:wifiPass.value,admin:admin.value,adminPass:adminPass.value};
|
||
|
|
let r=await fetch('/api/setup',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(body)});
|
||
|
|
out.textContent=await r.text();
|
||
|
|
}
|
||
|
|
scan();
|
||
|
|
</script>
|
||
|
|
</body>
|
||
|
|
</html>
|