From 32d44eb15807ee18c489b200b354bee9d57beca9 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Thu, 9 Apr 2026 13:33:20 +0200 Subject: [PATCH] Review changes --- lib/I18n/translations/english.yaml | 2 +- .../settings/SystemInformationActivity.cpp | 2 +- src/network/html/HomePage.html | 19 ++++++++++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/I18n/translations/english.yaml b/lib/I18n/translations/english.yaml index 8fe5cb59..3a6f780d 100644 --- a/lib/I18n/translations/english.yaml +++ b/lib/I18n/translations/english.yaml @@ -456,7 +456,7 @@ STR_UPTIME: "Uptime" STR_CHARGING: "Charging" STR_GATHERING_DATA: "Gathering data..." STR_READING: "Reading..." -STR_SD_UPDATE_PROMPT: "Press update to show" +STR_SD_UPDATE_PROMPT: "Press Update to load SD info" STR_UNSUPPORTED_IMAGE_FORMAT: "Unsupported image format" STR_COULD_NOT_RENDER_IMAGE: "Could not render image" STR_FAILED_TO_SET_SLEEP_SCREEN: "Failed to set sleep screen" diff --git a/src/activities/settings/SystemInformationActivity.cpp b/src/activities/settings/SystemInformationActivity.cpp index 643e7414..1483247a 100644 --- a/src/activities/settings/SystemInformationActivity.cpp +++ b/src/activities/settings/SystemInformationActivity.cpp @@ -126,7 +126,7 @@ void SystemInformationActivity::render(RenderLock&&) { drawRow(9, tr(STR_SD_CARD), tr(STR_NOT_SET)); } - const auto labels = mappedInput.mapLabels(tr(STR_BACK), tr(STR_UPDATE), "", ""); + const auto labels = mappedInput.mapLabels(tr(STR_BACK), sdStatusReady_ ? "" : tr(STR_UPDATE), "", ""); GUI.drawButtonHints(renderer, labels.btn1, labels.btn2, labels.btn3, labels.btn4); renderer.displayBuffer(); diff --git a/src/network/html/HomePage.html b/src/network/html/HomePage.html index a12c12a2..8a3e3507 100644 --- a/src/network/html/HomePage.html +++ b/src/network/html/HomePage.html @@ -215,6 +215,13 @@ return parseFloat(val.toFixed(2)).toLocaleString() + ' ' + units[i]; } + const SD_LABELS = { + NOT_LOADED: 'Not loaded', + LOAD_BUTTON: 'Load SD info', + LOADING: 'Loading...', + ERROR: 'Error loading' + }; + function formatUptime(seconds) { if (seconds == null) return 'N/A'; const h = Math.floor(seconds / 3600); @@ -255,7 +262,7 @@ ? formatBytes(data.sdUsed) + ' / ' + formatBytes(data.sdTotal) : 'N/A'; } else { - document.getElementById('sd-space').textContent = 'Not loaded'; + document.getElementById('sd-space').textContent = SD_LABELS.NOT_LOADED; } } @@ -270,14 +277,15 @@ setSdButtonState(true); } catch (error) { console.error('Error fetching status:', error); + document.getElementById('sd-space').textContent = SD_LABELS.ERROR; } } async function fetchSdStatus() { const button = document.getElementById('load-sd-button'); button.disabled = true; - button.textContent = 'Loading...'; - document.getElementById('sd-space').textContent = 'Loading...'; + button.textContent = SD_LABELS.LOADING; + document.getElementById('sd-space').textContent = SD_LABELS.LOADING; try { const response = await fetch('/api/status'); @@ -290,14 +298,15 @@ } catch (error) { console.error('Error fetching SD status:', error); button.disabled = false; - button.textContent = 'Load SD info'; + button.textContent = SD_LABELS.LOAD_BUTTON; + document.getElementById('sd-space').textContent = SD_LABELS.ERROR; } } function setSdButtonState(enabled) { const button = document.getElementById('load-sd-button'); button.disabled = !enabled; - button.textContent = enabled ? 'Load SD info' : 'Loading...'; + button.textContent = enabled ? SD_LABELS.LOAD_BUTTON : SD_LABELS.LOADING; } document.addEventListener('DOMContentLoaded', () => {