refactor: rework the network settings page (#307)

* fix: make W5500 interrupt and reset pins optional

* feat: rework the network settings page

* build: split elvinhome THRM ONE into BLE and Ethernet environments

* ci: target dev for Dependabot version updates

* chore: bump actions/cache from 5 to 6 (#302)

Bumps [actions/cache](https://github.com/actions/cache) from 5 to 6.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: bump actions/setup-python from 6 to 7 (#303)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 6 to 7.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: bump actions/download-artifact from 5 to 8 (#304)

Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 5 to 8.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v5...v8)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '8'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: bump actions/checkout from 6 to 7 (#305)

Bumps [actions/checkout](https://github.com/actions/checkout) from 6 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: bump actions/setup-node from 5 to 6 (#306)

Bumps [actions/setup-node](https://github.com/actions/setup-node) from 5 to 6.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* revert: restore the default branch for Dependabot version updates

This reverts commit a7b2120740.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
Yuriianddependabot[bot] authored and GitHub committed 2026-12-03 10:02:11 +03:00
1 parent 5fb4231201
commit 6a82768497
12 files changed
+493 -459

No files matched your search

+7 -7
View File
@@ -40,13 +40,13 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v7
with: with:
# A new tag needs branch history to determine whether its commit is on master. # A new tag needs branch history to determine whether its commit is on master.
fetch-depth: ${{ startsWith(github.ref, 'refs/tags/v') && github.event.created && '0' || '1' }} fetch-depth: ${{ startsWith(github.ref, 'refs/tags/v') && github.event.created && '0' || '1' }}
- name: Python - name: Python
uses: actions/setup-python@v6 uses: actions/setup-python@v7
with: with:
python-version: ${{ env.PYTHON_VERSION }} python-version: ${{ env.PYTHON_VERSION }}
@@ -98,15 +98,15 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v7
- name: Python - name: Python
uses: actions/setup-python@v6 uses: actions/setup-python@v7
with: with:
python-version: ${{ env.PYTHON_VERSION }} python-version: ${{ env.PYTHON_VERSION }}
- name: Install Node.js - name: Install Node.js
uses: actions/setup-node@v5 uses: actions/setup-node@v6
with: with:
node-version: "22" node-version: "22"
@@ -178,7 +178,7 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v7
with: with:
fetch-depth: 0 fetch-depth: 0
@@ -190,7 +190,7 @@ jobs:
git push origin refs/tags/unstable --force git push origin refs/tags/unstable --force
- name: Download artifacts - name: Download artifacts
uses: actions/download-artifact@v5 uses: actions/download-artifact@v8
with: with:
path: artifacts path: artifacts
merge-multiple: true merge-multiple: true
+4 -4
View File
@@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v6 uses: actions/checkout@v7
- name: Install jq - name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq run: sudo apt-get update && sudo apt-get install -y jq
@@ -67,16 +67,16 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v7
- name: Cache - name: Cache
uses: actions/cache@v5 uses: actions/cache@v6
with: with:
key: ${{ runner.os }}-cpplint key: ${{ runner.os }}-cpplint
path: ~/.cache/pip path: ~/.cache/pip
- name: Python - name: Python
uses: actions/setup-python@v6 uses: actions/setup-python@v7
with: with:
python-version: "3.x" python-version: "3.x"
+14 -2
View File
@@ -345,8 +345,20 @@ custom_sdkconfig = ${env:esp32_c6.custom_sdkconfig}
CONFIG_ETH_USE_SPI_ETHERNET=y CONFIG_ETH_USE_SPI_ETHERNET=y
CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF=y CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF=y
[env:elvinhome_thrm_one] [env:elvinhome_thrm_one_ble]
custom_title = Elvinhome THRM ONE (ESP32 C6, NO BLE) custom_title = elvinhome THRM ONE (ESP32 C6, BLE)
extends = env:esp32_c6
custom_board_flags = -D DEFAULT_OT_IN_GPIO=6
-D DEFAULT_OT_OUT_GPIO=7
-D DEFAULT_STATUS_LED_GPIO=1
-D DEFAULT_SENSOR_INDOOR_GPIO=4
-D DEFAULT_SENSOR_INDOOR_TYPE=Sensors::Type::NTC_10K_TEMP
-D DEFAULT_OT_RX_LED_GPIO=GPIO_IS_NOT_CONFIGURED
-D DEFAULT_SENSOR_OUTDOOR_GPIO=GPIO_IS_NOT_CONFIGURED
-D DEFAULT_NTC_VREF=3200.0f
[env:elvinhome_thrm_one_ethernet]
custom_title = elvinhome THRM ONE (ESP32 C6, ETHERNET)
extends = env:esp32_c6_ethernet extends = env:esp32_c6_ethernet
custom_board_flags = -D DEFAULT_ETH_CLK_GPIO=22 custom_board_flags = -D DEFAULT_ETH_CLK_GPIO=22
-D DEFAULT_ETH_MOSI_GPIO=20 -D DEFAULT_ETH_MOSI_GPIO=20
+16 -6
View File
@@ -192,8 +192,8 @@ bool isEthernetConfigured(const NetworkSettings& config) {
GPIO_IS_VALID_OUTPUT(gpios.mosi) && GPIO_IS_VALID_OUTPUT(gpios.mosi) &&
GPIO_IS_VALID_INPUT(gpios.miso) && GPIO_IS_VALID_INPUT(gpios.miso) &&
GPIO_IS_VALID_OUTPUT(gpios.cs) && GPIO_IS_VALID_OUTPUT(gpios.cs) &&
GPIO_IS_VALID_INPUT(gpios.irq) && (gpios.irq == GPIO_IS_NOT_CONFIGURED || GPIO_IS_VALID_INPUT(gpios.irq)) &&
GPIO_IS_VALID_OUTPUT(gpios.rst); (gpios.rst == GPIO_IS_NOT_CONFIGURED || GPIO_IS_VALID_OUTPUT(gpios.rst));
#else #else
(void)config; (void)config;
return false; return false;
@@ -589,10 +589,20 @@ static bool startEthernet() {
const auto& gpios = networkSettings.ethernet.w5500; const auto& gpios = networkSettings.ethernet.w5500;
ESP_LOGI(L_NETWORK, "Initialize W5500 Ethernet"); ESP_LOGI(L_NETWORK, "Initialize W5500 Ethernet");
if (!ETH.begin( const bool initialized = ETH.begin(
ETH_PHY_W5500, 1, gpios.cs, gpios.irq, gpios.rst, ETH_PHY_W5500,
SPI2_HOST, gpios.clk, gpios.miso, gpios.mosi, 12 1,
)) { gpios.cs,
gpios.irq == GPIO_IS_NOT_CONFIGURED ? -1 : gpios.irq, // optionally
gpios.rst == GPIO_IS_NOT_CONFIGURED ? -1 : gpios.rst, // optionally
SPI2_HOST,
gpios.clk,
gpios.miso,
gpios.mosi,
12
);
if (!initialized) {
ESP_LOGE(L_NETWORK, "W5500 initialization failed, check GPIOs and wiring"); ESP_LOGE(L_NETWORK, "W5500 initialization failed, check GPIOs and wiring");
stopEthernet(); stopEthernet();
return false; return false;
+11 -5
View File
@@ -29,6 +29,8 @@
"save": "保存", "save": "保存",
"saved": "已保存", "saved": "已保存",
"refresh": "刷新", "refresh": "刷新",
"search": "搜索",
"close": "关闭",
"restore": "恢复", "restore": "恢复",
"restored": "已恢复", "restored": "已恢复",
"backup": "备份", "backup": "备份",
@@ -154,23 +156,27 @@
"ethernet": "以太网", "ethernet": "以太网",
"wifi": "Wi-Fi", "wifi": "Wi-Fi",
"availableNetworks": "可用网络", "availableNetworks": "可用网络",
"staSettings": "WiFi 设置", "staSettings": "连接到 Wi-Fi",
"apSettings": "AP 设置" "apSettings": "备用接入点"
}, },
"scan": { "scan": {
"pos": "#", "pos": "#",
"info": "Info", "info": "Info",
"hiddenSsid": "请输入隐藏网络的名称",
"empty": "未找到网络",
"failed": "无法获取网络列表。",
"unavailable": "仅在 Wi-Fi 模式下可扫描网络。" "unavailable": "仅在 Wi-Fi 模式下可扫描网络。"
}, },
"ethernet": { "ethernet": {
"unavailable": "此固件版本不支持以太网。",
"notConfigured": "配置全部六个 GPIO 引脚以使用以太网。", "notConfigured": "配置全部六个 GPIO 引脚以使用以太网。",
"clk": "SPI 时钟 GPIO", "clk": "SPI clock GPIO",
"mosi": "SPI MOSI GPIO", "mosi": "SPI MOSI GPIO",
"miso": "SPI MISO GPIO", "miso": "SPI MISO GPIO",
"cs": "SPI CS GPIO", "cs": "SPI CS GPIO",
"irq": "中断 GPIO", "irq": "Interrupt GPIO",
"rst": "复位 GPIO", "rst": "Reset GPIO",
"note": "W5500 SPI 接线" "note": "W5500 SPI 接线"
}, },
"wifi": { "wifi": {
+11 -5
View File
@@ -29,6 +29,8 @@
"save": "Save", "save": "Save",
"saved": "Saved", "saved": "Saved",
"refresh": "Refresh", "refresh": "Refresh",
"search": "Search",
"close": "Close",
"restore": "Restore", "restore": "Restore",
"restored": "Restored", "restored": "Restored",
"backup": "Backup", "backup": "Backup",
@@ -154,23 +156,27 @@
"ethernet": "Ethernet", "ethernet": "Ethernet",
"wifi": "Wi-Fi", "wifi": "Wi-Fi",
"availableNetworks": "Available networks", "availableNetworks": "Available networks",
"staSettings": "WiFi settings", "staSettings": "Connect to Wi-Fi",
"apSettings": "AP settings" "apSettings": "Fallback access point"
}, },
"scan": { "scan": {
"pos": "#", "pos": "#",
"info": "Info", "info": "Info",
"hiddenSsid": "Enter the hidden network name",
"empty": "No networks found",
"failed": "Could not retrieve the list of networks.",
"unavailable": "Network scanning is available only in Wi-Fi mode." "unavailable": "Network scanning is available only in Wi-Fi mode."
}, },
"ethernet": { "ethernet": {
"unavailable": "This firmware build does not support Ethernet.",
"notConfigured": "Configure all six GPIOs to use Ethernet.", "notConfigured": "Configure all six GPIOs to use Ethernet.",
"clk": "SPI clock GPIO", "clk": "SPI CLK GPIO",
"mosi": "SPI MOSI GPIO", "mosi": "SPI MOSI GPIO",
"miso": "SPI MISO GPIO", "miso": "SPI MISO GPIO",
"cs": "SPI CS GPIO", "cs": "SPI CS GPIO",
"irq": "Interrupt GPIO", "irq": "IRQ GPIO",
"rst": "Reset GPIO", "rst": "RST GPIO",
"note": "W5500 SPI wiring" "note": "W5500 SPI wiring"
}, },
"wifi": { "wifi": {
+14 -8
View File
@@ -29,6 +29,8 @@
"save": "Salva", "save": "Salva",
"saved": "Salvato", "saved": "Salvato",
"refresh": "Ricarica", "refresh": "Ricarica",
"search": "Cerca",
"close": "Chiudi",
"restore": "Recupera", "restore": "Recupera",
"restored": "Recuperato", "restored": "Recuperato",
"backup": "Backup", "backup": "Backup",
@@ -154,23 +156,27 @@
"ethernet": "Ethernet", "ethernet": "Ethernet",
"wifi": "Wi-Fi", "wifi": "Wi-Fi",
"availableNetworks": "Reti disponibili", "availableNetworks": "Reti disponibili",
"staSettings": "Impostazioni WiFi", "staSettings": "Connessione al Wi-Fi",
"apSettings": "Impostazioni AP" "apSettings": "Punto di accesso di riserva"
}, },
"scan": { "scan": {
"pos": "#", "pos": "#",
"info": "Info", "info": "Info",
"hiddenSsid": "Inserisci il nome della rete nascosta",
"empty": "Nessuna rete trovata",
"failed": "Impossibile recuperare la lista delle reti.",
"unavailable": "La ricerca delle reti è disponibile solo in modalità Wi-Fi." "unavailable": "La ricerca delle reti è disponibile solo in modalità Wi-Fi."
}, },
"ethernet": { "ethernet": {
"unavailable": "Questa versione del firmware non supporta Ethernet.",
"notConfigured": "Configura tutti e sei i GPIO per utilizzare Ethernet.", "notConfigured": "Configura tutti e sei i GPIO per utilizzare Ethernet.",
"clk": "GPIO clock SPI", "clk": "SPI clock GPIO",
"mosi": "GPIO MOSI SPI", "mosi": "SPI MOSI GPIO",
"miso": "GPIO MISO SPI", "miso": "SPI MISO GPIO",
"cs": "GPIO CS SPI", "cs": "SPI CS GPIO",
"irq": "GPIO interrupt", "irq": "Interrupt GPIO",
"rst": "GPIO reset", "rst": "Reset GPIO",
"note": "Cablaggio SPI del W5500" "note": "Cablaggio SPI del W5500"
}, },
"wifi": { "wifi": {
+9 -3
View File
@@ -29,6 +29,8 @@
"save": "Opslaan", "save": "Opslaan",
"saved": "Opgeslagen", "saved": "Opgeslagen",
"refresh": "Vernieuwen", "refresh": "Vernieuwen",
"search": "Zoeken",
"close": "Sluiten",
"restore": "Herstellen", "restore": "Herstellen",
"restored": "Hersteld", "restored": "Hersteld",
"backup": "Back-up", "backup": "Back-up",
@@ -154,18 +156,22 @@
"ethernet": "Ethernet", "ethernet": "Ethernet",
"wifi": "Wi-Fi", "wifi": "Wi-Fi",
"availableNetworks": "Beschikbare netwerken", "availableNetworks": "Beschikbare netwerken",
"staSettings": "WiFi-instellingen", "staSettings": "Verbinden met wifi",
"apSettings": "AP-instellingen" "apSettings": "Reservetoegangspunt"
}, },
"scan": { "scan": {
"pos": "#", "pos": "#",
"info": "Info", "info": "Info",
"hiddenSsid": "Voer de naam van het verborgen netwerk in",
"empty": "Geen netwerken gevonden",
"failed": "De lijst met netwerken kon niet worden opgehaald.",
"unavailable": "Netwerken zoeken is alleen beschikbaar in de Wi-Fi-modus." "unavailable": "Netwerken zoeken is alleen beschikbaar in de Wi-Fi-modus."
}, },
"ethernet": { "ethernet": {
"unavailable": "Deze firmwarebuild ondersteunt geen Ethernet.",
"notConfigured": "Configureer alle zes GPIO's om Ethernet te gebruiken.", "notConfigured": "Configureer alle zes GPIO's om Ethernet te gebruiken.",
"clk": "SPI-klok GPIO", "clk": "SPI clock GPIO",
"mosi": "SPI MOSI GPIO", "mosi": "SPI MOSI GPIO",
"miso": "SPI MISO GPIO", "miso": "SPI MISO GPIO",
"cs": "SPI CS GPIO", "cs": "SPI CS GPIO",
+14 -8
View File
@@ -29,6 +29,8 @@
"save": "Сохранить", "save": "Сохранить",
"saved": "Сохранено", "saved": "Сохранено",
"refresh": "Обновить", "refresh": "Обновить",
"search": "Поиск",
"close": "Закрыть",
"restore": "Восстановить настройки", "restore": "Восстановить настройки",
"restored": "Восстановлено", "restored": "Восстановлено",
"backup": "Сохранить настройки", "backup": "Сохранить настройки",
@@ -154,23 +156,27 @@
"ethernet": "Ethernet", "ethernet": "Ethernet",
"wifi": "Wi-Fi", "wifi": "Wi-Fi",
"availableNetworks": "Доступные сети", "availableNetworks": "Доступные сети",
"staSettings": "Настройки подключения", "staSettings": "Подключение к Wi-Fi",
"apSettings": "Настройки точки доступа" "apSettings": "Резервная точка доступа"
}, },
"scan": { "scan": {
"pos": "#", "pos": "#",
"info": "Инфо", "info": "Инфо",
"hiddenSsid": "Введите имя скрытой сети",
"empty": "Сети не найдены",
"failed": "Не удалось получить список сетей.",
"unavailable": "Поиск сетей доступен только в режиме Wi-Fi." "unavailable": "Поиск сетей доступен только в режиме Wi-Fi."
}, },
"ethernet": { "ethernet": {
"unavailable": "Эта сборка прошивки не поддерживает Ethernet.",
"notConfigured": "Для подключения через Ethernet настройте все шесть GPIO.", "notConfigured": "Для подключения через Ethernet настройте все шесть GPIO.",
"clk": "GPIO тактирования SPI", "clk": "SPI clock GPIO",
"mosi": "GPIO MOSI SPI", "mosi": "SPI MOSI GPIO",
"miso": "GPIO MISO SPI", "miso": "SPI MISO GPIO",
"cs": "GPIO CS SPI", "cs": "SPI CS GPIO",
"irq": "GPIO прерывания", "irq": "Interrupt GPIO",
"rst": "GPIO сброса", "rst": "Reset GPIO",
"note": "Подключение W5500 по SPI" "note": "Подключение W5500 по SPI"
}, },
"wifi": { "wifi": {
+373 -237
View File
@@ -41,47 +41,128 @@
<div id="network-settings-busy" aria-busy="true"></div> <div id="network-settings-busy" aria-busy="true"></div>
<form action="/api/network/settings" id="network-settings" class="hidden"> <form action="/api/network/settings" id="network-settings" class="hidden">
<label> <div class="grid">
<span data-i18n>network.params.hostname</span> <label>
<input type="text" name="hostname" maxlength="24" pattern="[A-Za-z0-9]+[A-Za-z0-9\-]+[A-Za-z0-9]+" required> <span data-i18n>network.params.hostname</span>
</label> <input type="text" name="hostname" maxlength="24" pattern="[A-Za-z0-9]+[A-Za-z0-9\-]+[A-Za-z0-9]+" required>
</label>
<label> <label>
<span data-i18n>network.type.title</span> <span data-i18n>network.type.title</span>
<select name="type"> <select name="type">
<option value="2" data-i18n>network.type.wifi</option> <option value="2" data-i18n>network.type.wifi</option>
<option value="3" hidden disabled data-i18n>network.type.ethernet</option> <option value="3" data-i18n>network.type.ethernet</option>
</select> </select>
</label> </label>
</div>
<label>
<input type="checkbox" name="use_dhcp" value="true">
<span data-i18n>network.params.dhcp</span>
</label>
<br />
<hr /> <hr />
<h4 data-i18n>network.section.static</h4>
<label> <details>
<span data-i18n>network.params.ip</span> <summary><b data-i18n>network.section.static</b></summary>
<input type="text" name="static_config[ip]" maxlength="16" pattern="\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" required> <div>
</label> <fieldset>
<label>
<input type="checkbox" name="use_dhcp" value="true">
<span data-i18n>network.params.dhcp</span>
</label>
</fieldset>
<label> <div class="grid">
<span data-i18n>network.params.gateway</span> <label>
<input type="text" name="static_config[gateway]" maxlength="16" pattern="\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" required> <span data-i18n>network.params.ip</span>
</label> <input type="text" name="static_config[ip]" maxlength="16" pattern="\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" required>
</label>
<label> <label>
<span data-i18n>network.params.subnet</span> <span data-i18n>network.params.subnet</span>
<input type="text" name="static_config[subnet]" maxlength="16" pattern="\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" required> <input type="text" name="static_config[subnet]" maxlength="16" pattern="\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" required>
</label> </label>
</div>
<label> <div class="grid">
<span data-i18n>network.params.dns</span> <label>
<input type="text" name="static_config[dns]" maxlength="16" pattern="\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" required> <span data-i18n>network.params.gateway</span>
</label> <input type="text" name="static_config[gateway]" maxlength="16" pattern="\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" required>
</label>
<label>
<span data-i18n>network.params.dns</span>
<input type="text" name="static_config[dns]" maxlength="16" pattern="\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" required>
</label>
</div>
</div>
</details>
<hr />
<details class="ethernet">
<summary><b data-i18n>network.section.ethernet</b></summary>
<div>
<p class="unsupported hidden" data-i18n>network.ethernet.unavailable</p>
<fieldset class="supported">
<div class="grid">
<label>
<span data-i18n>network.ethernet.clk</span>
<input type="number" inputmode="numeric" name="ethernet[gpio][clk]" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>network.ethernet.mosi</span>
<input type="number" inputmode="numeric" name="ethernet[gpio][mosi]" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>network.ethernet.miso</span>
<input type="number" inputmode="numeric" name="ethernet[gpio][miso]" min="0" max="254" step="1">
</label>
</div>
<div class="grid">
<label>
<span data-i18n>network.ethernet.cs</span>
<input type="number" inputmode="numeric" name="ethernet[gpio][cs]" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>network.ethernet.irq</span>
<input type="number" inputmode="numeric" name="ethernet[gpio][irq]" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>network.ethernet.rst</span>
<input type="number" inputmode="numeric" name="ethernet[gpio][rst]" min="0" max="254" step="1">
</label>
</div>
</fieldset>
</div>
</details>
<hr />
<details>
<summary><b data-i18n>network.section.apSettings</b></summary>
<div>
<div class="grid">
<label>
<span data-i18n>network.wifi.ssid</span>
<input type="text" name="wifi[ap][ssid]" maxlength="32" required>
</label>
<label>
<span data-i18n>network.wifi.password</span>
<input type="text" name="wifi[ap][password]" maxlength="64" required>
</label>
</div>
<label>
<span data-i18n>network.wifi.channel</span>
<input type="number" inputmode="numeric" name="wifi[ap][channel]" min="1" max="12" step="1" required>
</label>
</div>
</details>
<br />
<button type="submit" data-i18n>button.save</button> <button type="submit" data-i18n>button.save</button>
</form> </form>
</div> </div>
@@ -91,147 +172,65 @@
<article id="wifi-section"> <article id="wifi-section">
<div> <div>
<hgroup> <hgroup>
<h2 data-i18n>network.section.wifi</h2> <h2 data-i18n>network.section.staSettings</h2>
<p></p> <p></p>
</hgroup> </hgroup>
<hgroup> <div>
<h3 data-i18n>network.section.availableNetworks</h3> <form action="/api/network/settings" id="sta-settings" class="hidden">
<p></p> <label for="sta-ssid" data-i18n>network.wifi.ssid</label>
</hgroup> <div role="group">
<input type="text" id="sta-ssid" name="wifi[sta][ssid]" maxlength="32" required>
<form action="/api/network/scan" id="network-scan"> <button type="button" class="scan" aria-haspopup="dialog" aria-controls="scan-dialog" data-i18n>button.search</button>
<fieldset id="wifi-scan-controls" disabled>
<div style="max-height: 25rem;" class="overflow-auto">
<table id="networks" role="grid">
<thead>
<tr>
<th scope="col" data-i18n>network.scan.pos</th>
<th scope="col" data-i18n>network.wifi.ssid</th>
<th scope="col" data-i18n>network.scan.info</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div> </div>
<p id="scan-unavailable" class="hidden" data-i18n>network.scan.unavailable</p> <div class="grid">
<button type="submit" data-i18n>button.refresh</button> <label>
</fieldset> <span data-i18n>network.wifi.password</span>
</form> <input type="password" name="wifi[sta][password]" maxlength="64">
</label>
<hr /> <label>
<div> <span data-i18n>network.wifi.channel</span>
<hgroup> <input type="number" inputmode="numeric" name="wifi[sta][channel]" min="0" max="12" step="1" required>
<h3 data-i18n>network.section.staSettings</h3> <small data-i18n>network.sta.channel.note</small>
<p></p> </label>
</hgroup> </div>
<div id="sta-settings-busy" aria-busy="true"></div>
<form action="/api/network/settings" id="sta-settings" class="hidden">
<label>
<span data-i18n>network.wifi.ssid</span>
<input type="text" name="wifi[sta][ssid]" maxlength="32" required>
</label>
<label>
<span data-i18n>network.wifi.password</span>
<input type="password" name="wifi[sta][password]" maxlength="64" required>
</label>
<label>
<span data-i18n>network.wifi.channel</span>
<input type="number" inputmode="numeric" name="wifi[sta][channel]" min="0" max="12" step="1" required>
<small data-i18n>network.sta.channel.note</small>
</label>
<br />
<button type="submit" data-i18n>button.save</button> <button type="submit" data-i18n>button.save</button>
</form> </form>
</div> </div>
<hr />
<div>
<hgroup>
<h3 data-i18n>network.section.apSettings</h3>
<p></p>
</hgroup>
<div id="ap-settings-busy" aria-busy="true"></div>
<form action="/api/network/settings" id="ap-settings" class="hidden">
<label>
<span data-i18n>network.wifi.ssid</span>
<input type="text" name="wifi[ap][ssid]" maxlength="32" required>
</label>
<label>
<span data-i18n>network.wifi.password</span>
<input type="text" name="wifi[ap][password]" maxlength="64" required>
</label>
<label>
<span data-i18n>network.wifi.channel</span>
<input type="number" inputmode="numeric" name="wifi[ap][channel]" min="1" max="12" step="1" required>
</label>
<button type="submit" data-i18n>button.save</button>
</form>
</div>
</div>
</article>
<article id="ethernet-section" class="hidden">
<div>
<hgroup>
<h3 data-i18n>network.section.ethernet</h3>
<p></p>
</hgroup>
<div id="ethernet-settings-busy" aria-busy="true"></div>
<form action="/api/network/settings" id="ethernet-settings" class="hidden">
<small id="ethernet-not-configured" class="hidden" data-i18n>network.ethernet.notConfigured</small>
<div class="grid">
<label>
<span data-i18n>network.ethernet.clk</span>
<input type="number" inputmode="numeric" name="ethernet[gpio][clk]" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>network.ethernet.mosi</span>
<input type="number" inputmode="numeric" name="ethernet[gpio][mosi]" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>network.ethernet.miso</span>
<input type="number" inputmode="numeric" name="ethernet[gpio][miso]" min="0" max="254" step="1">
</label>
</div>
<div class="grid">
<label>
<span data-i18n>network.ethernet.cs</span>
<input type="number" inputmode="numeric" name="ethernet[gpio][cs]" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>network.ethernet.irq</span>
<input type="number" inputmode="numeric" name="ethernet[gpio][irq]" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>network.ethernet.rst</span>
<input type="number" inputmode="numeric" name="ethernet[gpio][rst]" min="0" max="254" step="1">
</label>
</div>
<small data-i18n>network.ethernet.note</small>
<button type="submit" data-i18n>button.save</button>
</form>
</div> </div>
</article> </article>
</main> </main>
<dialog id="scan-dialog">
<article>
<header>
<button type="button" aria-label="Close" rel="prev"></button>
<p><b data-i18n>network.section.availableNetworks</b></p>
</header>
<form action="/api/network/scan" id="network-scan">
<table>
<thead>
<tr>
<th scope="col" data-i18n>network.scan.pos</th>
<th scope="col" data-i18n>network.wifi.ssid</th>
<th scope="col" data-i18n>network.scan.info</th>
</tr>
</thead>
<tbody></tbody>
</table>
<div role="status"></div>
</form>
<footer>
<button type="submit" class="refresh" form="network-scan" data-i18n>button.refresh</button>
</footer>
</article>
</dialog>
<footer class="container"> <footer class="container">
<small> <small>
<b>Made by Laxilef</b> <b>Made by Laxilef</b>
@@ -245,100 +244,237 @@
<script src="/static/app.js?{BUILD_TIME}"></script> <script src="/static/app.js?{BUILD_TIME}"></script>
<script> <script>
const setupNetworkScan = () => {
const staForm = document.getElementById('sta-settings');
const ssidInput = staForm.querySelector("[name='wifi[sta][ssid]']");
const dialog = document.getElementById('scan-dialog');
const form = dialog.querySelector('form');
const closeButton = dialog.querySelector('[rel="prev"]');
const refreshButton = dialog.querySelector('.refresh');
const status = form.querySelector('[role="status"]');
const tbody = form.querySelector('tbody');
const authNames = [
'Open', 'WEP', 'WPA', 'WPA2', 'WPA/WPA2', 'WPA/WPA2 Enterprise',
'WPA3', 'WPA2/WPA3', 'WAPI', 'OWE', 'WPA3 Enterprise'
];
let scanController;
let retryTimer;
const selectNetwork = (network) => {
if (network.hidden) {
ssidInput.value = '';
ssidInput.placeholder = i18n('network.scan.hiddenSsid');
ssidInput.removeAttribute('aria-invalid');
} else {
ssidInput.value = network.ssid;
ssidInput.removeAttribute('placeholder');
ssidInput.dispatchEvent(new Event('change', { bubbles: true }));
}
dialog.close();
ssidInput.focus();
};
const addIcon = (cell, iconClass, label) => {
const icon = document.createElement('i');
icon.className = iconClass;
const tooltip = document.createElement('span');
tooltip.dataset.tooltip = label;
tooltip.setAttribute('role', 'img');
tooltip.setAttribute('aria-label', label);
tooltip.appendChild(icon);
cell.appendChild(tooltip);
};
const addNetworkRow = (network, index) => {
const row = tbody.insertRow();
row.className = 'network';
row.insertCell().textContent = '#' + (index + 1);
const nameButton = document.createElement('button');
nameButton.type = 'button';
nameButton.textContent = network.hidden ? network.bssid : network.ssid;
nameButton.classList.toggle('bssid', network.hidden);
row.insertCell().appendChild(nameButton);
const infoCell = row.insertCell();
const strength = Math.max(0, Math.ceil(network.signal_quality / 20) - 1);
addIcon(infoCell, 'icons-wifi-strength-' + strength, network.signal_quality + '%');
const authIcon = network.auth === 0 ? 'icons-unlocked' : 'icons-locked';
addIcon(infoCell, authIcon, authNames[network.auth] || 'unknown');
row.addEventListener('click', () => selectNetwork(network));
};
const scan = async (signal, attempt = 1) => {
if (signal.aborted || !dialog.open) {
return;
}
const maxAttempts = 6;
let retryDelay = 0;
let unavailable = false;
let message = 'network.scan.failed';
try {
const response = await fetch(form.action, {
cache: "no-cache",
credentials: "include",
signal
});
const networks = response.status === 200
? await response.json()
: null;
// A previous scan can finish after the dialog is closed and opened again.
if (signal.aborted || !dialog.open) {
return;
}
if (networks !== null) {
networks.forEach(addNetworkRow);
message = networks.length ? '' : 'network.scan.empty';
} else if (response.status === 409) {
unavailable = true;
message = 'network.scan.unavailable';
} else if ((response.status === 404 || response.status === 202) && attempt < maxAttempts) {
// The ESP returns 404 when it starts a scan and 202 while it is running.
retryDelay = 5000;
}
} catch {
if (signal.aborted || !dialog.open) {
return;
}
tbody.replaceChildren();
if (attempt < maxAttempts) {
retryDelay = 10000;
}
} finally {
if (!signal.aborted && dialog.open) {
if (retryDelay) {
retryTimer = setTimeout(() => scan(signal, attempt + 1), retryDelay);
} else {
status.textContent = message ? i18n(message) : '';
refreshButton.disabled = unavailable;
refreshButton.removeAttribute('aria-busy');
}
}
}
};
const stopScan = () => {
clearTimeout(retryTimer);
scanController?.abort();
};
const startScan = () => {
stopScan();
scanController = new AbortController();
tbody.replaceChildren();
status.textContent = '';
refreshButton.disabled = true;
refreshButton.setAttribute('aria-busy', 'true');
scan(scanController.signal);
};
staForm.querySelector('.scan').addEventListener('click', () => {
closeButton.setAttribute('aria-label', i18n('button.close'));
dialog.showModal();
document.documentElement.classList.add('modal-is-open');
startScan();
});
form.addEventListener('submit', (event) => {
event.preventDefault();
if (dialog.open && !refreshButton.disabled) {
startScan();
}
});
closeButton.addEventListener('click', () => dialog.close());
dialog.addEventListener('click', (event) => {
if (event.target === dialog) {
dialog.close();
}
});
dialog.addEventListener('close', () => {
if (!dialog.open) {
stopScan();
document.documentElement.classList.remove('modal-is-open');
}
});
};
document.addEventListener('DOMContentLoaded', async () => { document.addEventListener('DOMContentLoaded', async () => {
const lang = new Lang(document.getElementById('lang')); const lang = new Lang(document.getElementById('lang'));
await lang.build(); await lang.build();
let networkType = 2; const fillNetworkSettings = (settings) => {
setSelectValue("[name='type']", settings.type);
setInputValue("[name='hostname']", settings.hostname);
setCheckboxValue("[name='use_dhcp']", settings.use_dhcp);
for (const field of ['ip', 'gateway', 'subnet', 'dns']) {
setInputValue(`[name='static_config[${field}]']`, settings.static_config[field]);
}
const fillData = (data) => { if (settings.ethernet?.gpio) {
networkType = data.type; for (const pin of ['clk', 'mosi', 'miso', 'cs', 'irq', 'rst']) {
setSelectValue("[name='type']", networkType); const value = settings.ethernet.gpio[pin];
setInputValue(`[name='ethernet[gpio][${pin}]']`, value < 255 ? value : '');
}
}
const canScan = networkType === 2; setInputValue("[name='wifi[ap][ssid]']", settings.wifi.ap.ssid);
document.getElementById('wifi-scan-controls').disabled = !canScan; setInputValue("[name='wifi[ap][password]']", settings.wifi.ap.password);
document.querySelector('#scan-unavailable').classList.toggle('hidden', canScan); setInputValue("[name='wifi[ap][channel]']", settings.wifi.ap.channel);
setInputValue("[name='hostname']", data.hostname);
setCheckboxValue("[name='use_dhcp']", data.use_dhcp);
setInputValue("[name='static_config[ip]']", data.static_config.ip);
setInputValue("[name='static_config[gateway]']", data.static_config.gateway);
setInputValue("[name='static_config[subnet]']", data.static_config.subnet);
setInputValue("[name='static_config[dns]']", data.static_config.dns);
setBusy('#network-settings-busy', '#network-settings', false);
const ethernet = data.ethernet || {};
const ethernetConfigured = !!ethernet.configured;
const ethernetGpio = ethernet.gpio || {};
const gpioValue = (value) => (value ?? 255) < 255 ? value : '';
setInputValue("[name='ethernet[gpio][clk]']", gpioValue(ethernetGpio.clk));
setInputValue("[name='ethernet[gpio][mosi]']", gpioValue(ethernetGpio.mosi));
setInputValue("[name='ethernet[gpio][miso]']", gpioValue(ethernetGpio.miso));
setInputValue("[name='ethernet[gpio][cs]']", gpioValue(ethernetGpio.cs));
setInputValue("[name='ethernet[gpio][irq]']", gpioValue(ethernetGpio.irq));
setInputValue("[name='ethernet[gpio][rst]']", gpioValue(ethernetGpio.rst));
document.getElementById('ethernet-not-configured')?.classList.toggle('hidden', ethernetConfigured);
setBusy('#ethernet-settings-busy', '#ethernet-settings', false);
setInputValue("[name='wifi[sta][ssid]']", data.wifi.sta.ssid);
setInputValue("[name='wifi[sta][password]']", data.wifi.sta.password);
setInputValue("[name='wifi[sta][channel]']", data.wifi.sta.channel);
setBusy('#sta-settings-busy', '#sta-settings', false);
setInputValue("[name='wifi[ap][ssid]']", data.wifi.ap.ssid);
setInputValue("[name='wifi[ap][password]']", data.wifi.ap.password);
setInputValue("[name='wifi[ap][channel]']", data.wifi.ap.channel);
setBusy('#ap-settings-busy', '#ap-settings', false);
}; };
const applyCapabilities = (info) => { const fillStaSettings = (settings) => {
// pages and firmware ship together: the section stays hidden unless the build says it can do ethernet setInputValue("[name='wifi[sta][ssid]']", settings.wifi.sta.ssid);
const supported = info?.features?.ethernet === true; setInputValue("[name='wifi[sta][password]']", settings.wifi.sta.password);
setInputValue("[name='wifi[sta][channel]']", settings.wifi.sta.channel);
document.getElementById('ethernet-section')?.classList.toggle('hidden', !supported);
const ethernetOption = document.querySelector("[name='type'] option[value='3']");
ethernetOption.hidden = !supported;
ethernetOption.disabled = !supported;
return supported;
}; };
try { try {
const [response, infoResponse] = await Promise.all([ const response = await fetch("/api/network/settings", {
fetch("/api/network/settings", { cache: "no-cache",
cache: "no-cache", credentials: "include"
credentials: "include" });
}),
fetch("/api/info", {
cache: "no-cache",
credentials: "include"
})
]);
if (!response.ok) { if (!response.ok) {
throw new Error('Response not valid'); throw new Error('Response not valid');
} }
const info = infoResponse.ok ? await infoResponse.json() : null; const settings = await response.json();
const ethernetSupported = applyCapabilities(info); if (!settings.ethernet) {
show('.ethernet .unsupported');
const result = await response.json(); const gpioFields = document.querySelector('.ethernet .supported');
fillData(result); gpioFields.classList.add('hidden');
gpioFields.disabled = true;
setupForm('#network-settings', fillData, ['hostname', 'static_config.ip', 'static_config.gateway', 'static_config.subnet', 'static_config.dns']);
// Keep scans disabled if an earlier request finishes after the connection method changes.
setupNetworkScanForm('#network-scan', '#networks', networkType === 2);
if (ethernetSupported) {
setupForm('#ethernet-settings', fillData);
} }
setupForm('#sta-settings', fillData, ['wifi.sta.ssid', 'wifi.sta.password']); fillNetworkSettings(settings);
setupForm('#ap-settings', fillData, ['wifi.ap.ssid', 'wifi.ap.password']); fillStaSettings(settings);
setupForm('#network-settings', fillNetworkSettings, [
'hostname',
'static_config.ip', 'static_config.gateway', 'static_config.subnet', 'static_config.dns',
'wifi.ap.ssid', 'wifi.ap.password'
]);
setupForm('#sta-settings', fillStaSettings, [
'wifi.sta.ssid', 'wifi.sta.password'
]);
setupNetworkScan();
setBusy('#network-settings-busy', '#network-settings, #sta-settings', false);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
-174
View File
@@ -92,180 +92,6 @@ const setupForm = (formSelector, onResultCallback = null, noCastItems = []) => {
}); });
} }
const setupNetworkScanForm = (formSelector, tableSelector, autorun = true) => {
const form = document.querySelector(formSelector);
if (!form) {
console.error("form not found");
return;
}
const url = form.action;
let button = form.querySelector('button[type="submit"]');
let defaultText;
const onSubmitFn = async (event) => {
if (event) {
event.preventDefault();
}
if (button) {
defaultText = button.innerHTML;
button.innerHTML = i18n('button.wait');
button.setAttribute('disabled', true);
button.setAttribute('aria-busy', true);
}
let table = document.querySelector(tableSelector);
if (!table) {
console.error("table not found");
return;
}
const onSuccess = async (response) => {
let result = await response.json();
console.log('networks: ', result);
let tbody = table.querySelector('tbody');
if (!tbody) {
tbody = table.createTBody();
}
while (tbody.rows.length > 0) {
tbody.rows[0].remove();
}
for (let i = 0; i < result.length; i++) {
let row = tbody.insertRow(-1);
row.classList.add("network");
row.dataset.ssid = result[i].hidden ? '' : result[i].ssid;
row.insertCell().textContent = `#${i + 1}`;
const nameCell = row.insertCell();
if (result[i].hidden) {
const hiddenName = document.createElement('i');
hiddenName.textContent = result[i].bssid;
nameCell.appendChild(hiddenName);
} else {
nameCell.textContent = result[i].ssid;
}
nameCell.onclick = (event) => {
const input = document.querySelector("[name='wifi[sta][ssid]']");
const ssid = row.dataset.ssid;
if (!input || !ssid) {
return;
}
input.value = ssid;
input.focus();
};
// info cell
let infoCell = row.insertCell();
// signal quality
let signalQualityIcon = document.createElement("i");
if (result[i].signal_quality > 80) {
signalQualityIcon.classList.add('icons-wifi-strength-4');
} else if (result[i].signal_quality > 60) {
signalQualityIcon.classList.add('icons-wifi-strength-3');
} else if (result[i].signal_quality > 40) {
signalQualityIcon.classList.add('icons-wifi-strength-2');
} else if (result[i].signal_quality > 20) {
signalQualityIcon.classList.add('icons-wifi-strength-1');
} else {
signalQualityIcon.classList.add('icons-wifi-strength-0');
}
let signalQualityContainer = document.createElement("span");
signalQualityContainer.dataset.tooltip = `${result[i].signal_quality}%`;
signalQualityContainer.appendChild(signalQualityIcon);
infoCell.appendChild(signalQualityContainer);
// auth
const authList = {
0: "Open",
1: "WEP",
2: "WPA",
3: "WPA2",
4: "WPA/WPA2",
5: "WPA/WPA2 Enterprise",
6: "WPA3",
7: "WPA2/WPA3",
8: "WAPI",
9: "OWE",
10: "WPA3 Enterprise"
};
let authIcon = document.createElement("i");
if (result[i].auth == 0) {
authIcon.classList.add('icons-unlocked');
} else {
authIcon.classList.add('icons-locked');
}
let authContainer = document.createElement("span");
authContainer.dataset.tooltip = (result[i].auth in authList) ? authList[result[i].auth] : "unknown";
authContainer.appendChild(authIcon);
infoCell.appendChild(authContainer);
}
if (button) {
button.innerHTML = defaultText;
button.removeAttribute('disabled');
button.removeAttribute('aria-busy');
}
};
const onFailed = async (response) => {
table.classList.remove('hidden');
if (button) {
button.innerHTML = defaultText;
button.removeAttribute('disabled');
button.removeAttribute('aria-busy');
}
};
let attempts = 6;
let attemptFn = async () => {
attempts--;
try {
let response = await fetch(url, {
cache: "no-cache",
credentials: "include"
});
if (response.status == 200) {
await onSuccess(response);
} else if (attempts <= 0) {
await onFailed(response);
} else {
setTimeout(attemptFn, 5000);
}
} catch (err) {
if (attempts <= 0) {
onFailed(err);
} else {
setTimeout(attemptFn, 10000);
}
}
};
attemptFn();
};
form.addEventListener('submit', onSubmitFn);
if (autorun) {
onSubmitFn();
}
}
const setBusy = (busySelector, contentSelector, value, parent = undefined) => { const setBusy = (busySelector, contentSelector, value, parent = undefined) => {
if (!value) { if (!value) {
hide(busySelector, parent); hide(busySelector, parent);
+20
View File
@@ -111,11 +111,31 @@ button.failed {
border-color: var(--pico-form-element-invalid-border-color); border-color: var(--pico-form-element-invalid-border-color);
} }
#scan-dialog header {
margin-bottom: 0.25rem;
}
#scan-dialog thead {
position: sticky;
top: calc(-1 * var(--pico-block-spacing-vertical));
z-index: 1;
}
tr.network:hover { tr.network:hover {
--pico-background-color: var(--pico-primary-focus); --pico-background-color: var(--pico-primary-focus);
cursor: pointer; cursor: pointer;
} }
tr.network button {
all: unset;
outline: revert;
overflow-wrap: anywhere;
}
tr.network .bssid {
font-style: italic;
}
.primary { .primary {
border: 0.25rem solid var(--pico-form-element-invalid-border-color); border: 0.25rem solid var(--pico-form-element-invalid-border-color);
padding: 1rem; padding: 1rem;