Add in-app settings menu and fix settings API
Move WiFi and device name configuration into a modal menu, reuse existing settings endpoints, and harden settings serialization and startup for MicroPython.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
<button class="btn btn-secondary" id="presets-btn">Presets</button>
|
||||
<button class="btn btn-secondary" id="patterns-btn">Patterns</button>
|
||||
<button class="btn btn-secondary" id="profiles-btn">Profiles</button>
|
||||
<button class="btn btn-secondary" id="settings-btn">Settings</button>
|
||||
<button class="btn btn-secondary" id="help-btn">Help</button>
|
||||
</div>
|
||||
</header>
|
||||
@@ -230,6 +231,111 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Settings Modal -->
|
||||
<div id="settings-modal" class="modal">
|
||||
<div class="modal-content" style="max-width: 900px; max-height: 90vh; overflow-y: auto;">
|
||||
<h2>Device Settings</h2>
|
||||
<p class="muted-text" style="margin-bottom: 1rem;">Configure WiFi and device settings.</p>
|
||||
|
||||
<div id="settings-message" class="message" style="display:none;"></div>
|
||||
|
||||
<!-- Device Name -->
|
||||
<div class="settings-section">
|
||||
<h3>Device</h3>
|
||||
<form id="device-form">
|
||||
<div class="form-group">
|
||||
<label for="device-name-input">Device Name</label>
|
||||
<input type="text" id="device-name-input" name="device_name" placeholder="e.g. led-controller" required>
|
||||
<small>This name may be used for mDNS (e.g. <code>name.local</code>) and UI display.</small>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button type="submit" class="btn btn-primary btn-full">Save Name</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- WiFi Station Settings -->
|
||||
<div class="settings-section">
|
||||
<h3>WiFi Station (Client)</h3>
|
||||
|
||||
<div id="station-status" class="status-info">
|
||||
<h4>Connection Status</h4>
|
||||
<p>Loading...</p>
|
||||
</div>
|
||||
|
||||
<form id="station-form">
|
||||
<div class="form-group">
|
||||
<label for="station-ssid">SSID (Network Name)</label>
|
||||
<input type="text" id="station-ssid" name="ssid" placeholder="Enter WiFi network name" required>
|
||||
<small>The name of the WiFi network to connect to</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="station-password">Password</label>
|
||||
<input type="password" id="station-password" name="password" placeholder="Enter WiFi password">
|
||||
<small>Leave empty for open networks</small>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="station-ip">IP Address (Optional)</label>
|
||||
<input type="text" id="station-ip" name="ip" placeholder="192.168.1.100">
|
||||
<small>Static IP address (leave empty for DHCP)</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="station-gateway">Gateway (Optional)</label>
|
||||
<input type="text" id="station-gateway" name="gateway" placeholder="192.168.1.1">
|
||||
<small>Gateway/router IP address</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="btn-group">
|
||||
<button type="submit" class="btn btn-primary btn-full">Connect</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- WiFi Access Point Settings -->
|
||||
<div class="settings-section" style="margin-top: 1.5rem;">
|
||||
<h3>WiFi Access Point</h3>
|
||||
|
||||
<div id="ap-status" class="status-info">
|
||||
<h4>AP Status</h4>
|
||||
<p>Loading...</p>
|
||||
</div>
|
||||
|
||||
<form id="ap-form">
|
||||
<div class="form-group">
|
||||
<label for="ap-ssid">AP SSID (Network Name)</label>
|
||||
<input type="text" id="ap-ssid" name="ssid" placeholder="Enter AP name" required>
|
||||
<small>The name of the WiFi access point this device creates</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="ap-password">AP Password</label>
|
||||
<input type="password" id="ap-password" name="password" placeholder="Enter AP password (min 8 chars)">
|
||||
<small>Leave empty for open network (min 8 characters if set)</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="ap-channel">Channel (1-11)</label>
|
||||
<input type="number" id="ap-channel" name="channel" min="1" max="11" placeholder="Auto">
|
||||
<small>WiFi channel (1-11 for 2.4GHz). Leave empty for auto.</small>
|
||||
</div>
|
||||
|
||||
<div class="btn-group">
|
||||
<button type="submit" class="btn btn-primary btn-full">Configure AP</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="modal-actions">
|
||||
<button class="btn btn-secondary" id="settings-close-btn">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.modal {
|
||||
display: none;
|
||||
|
||||
Reference in New Issue
Block a user