Update Wi-Fi setup UI: hide status, add password toggle, add AP disappearance note
This commit is contained in:
parent
49a033780a
commit
77d428db1a
|
|
@ -338,6 +338,7 @@ def load_env(path="/etc/iomatex/ap.env"):
|
|||
|
||||
ENV = load_env()
|
||||
UI_PORT = int(ENV.get("UI_PORT", "18080"))
|
||||
HOSTNAME = (ENV.get("SSID", "") or "").strip()
|
||||
|
||||
|
||||
def run(cmd):
|
||||
|
|
@ -355,29 +356,33 @@ label{display:block;margin:8px 0 4px}
|
|||
input{width:100%;padding:10px;border:1px solid #ccc;border-radius:10px}
|
||||
button{padding:10px 14px;border-radius:10px;border:1px solid #111;background:#111;color:#fff;cursor:pointer}
|
||||
.small{color:#666;font-size:13px}
|
||||
.inlineRow{display:flex;gap:10px;align-items:center}
|
||||
.inlineRow input{flex:1 1 auto}
|
||||
.toggleBtn{white-space:nowrap}
|
||||
pre{white-space:pre-wrap;background:#f6f6f6;border-radius:10px;padding:12px}
|
||||
</style></head><body>
|
||||
<h2>IOMATEX Wi-Fi Setup</h2>
|
||||
|
||||
<div class="card">
|
||||
<b>Status</b>
|
||||
<pre id="raw">Loading...</pre>
|
||||
<button onclick="refresh()">Refresh</button>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<b>Connect to external Wi-Fi</b>
|
||||
<div class="small">In AP mode scanning may be unavailable; enter SSID manually.</div>
|
||||
<label>SSID</label><input id="ssid" placeholder="e.g. HotelWiFi">
|
||||
<label>Password</label><input id="pass" type="password" placeholder="(empty = open network)">
|
||||
<label>Password</label>
|
||||
<div class="inlineRow">
|
||||
<input id="pass" type="password" placeholder="(empty = open network)">
|
||||
<button type="button" class="toggleBtn" onclick="togglePassword(this)">Show</button>
|
||||
</div>
|
||||
<div class="small">After successful connection, the access point %(hostname_note)s will disappear.</div>
|
||||
<div style="margin-top:12px"><button onclick="connect()">Connect</button></div>
|
||||
<div class="small" id="msg" style="margin-top:10px"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
async function refresh(){
|
||||
const r = await fetch("/api/status"); const j = await r.json();
|
||||
document.getElementById("raw").textContent = j.output || "";
|
||||
function togglePassword(btn){
|
||||
const pass=document.getElementById("pass");
|
||||
const showing = pass.type === "text";
|
||||
pass.type = showing ? "password" : "text";
|
||||
if(btn){ btn.textContent = showing ? "Show" : "Hide"; }
|
||||
}
|
||||
async function connect(){
|
||||
const ssid=document.getElementById("ssid").value.trim();
|
||||
|
|
@ -389,12 +394,12 @@ async function connect(){
|
|||
body:new URLSearchParams({ssid,pass}).toString()});
|
||||
const j = await r.json();
|
||||
msg.textContent = (j.ok ? "OK: " : "ERROR: ") + (j.output || "");
|
||||
await refresh();
|
||||
}
|
||||
refresh();
|
||||
</script>
|
||||
</body></html>
|
||||
"""
|
||||
""" % {
|
||||
"hostname_note": HOSTNAME if HOSTNAME else "device access point"
|
||||
}
|
||||
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
|
|
|
|||
Loading…
Reference in New Issue