Review changes

This commit is contained in:
jpirnay
2026-04-09 13:33:20 +02:00
parent 91d5280a05
commit 32d44eb158
3 changed files with 16 additions and 7 deletions
+1 -1
View File
@@ -456,7 +456,7 @@ STR_UPTIME: "Uptime"
STR_CHARGING: "Charging" STR_CHARGING: "Charging"
STR_GATHERING_DATA: "Gathering data..." STR_GATHERING_DATA: "Gathering data..."
STR_READING: "Reading..." 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_UNSUPPORTED_IMAGE_FORMAT: "Unsupported image format"
STR_COULD_NOT_RENDER_IMAGE: "Could not render image" STR_COULD_NOT_RENDER_IMAGE: "Could not render image"
STR_FAILED_TO_SET_SLEEP_SCREEN: "Failed to set sleep screen" STR_FAILED_TO_SET_SLEEP_SCREEN: "Failed to set sleep screen"
@@ -126,7 +126,7 @@ void SystemInformationActivity::render(RenderLock&&) {
drawRow(9, tr(STR_SD_CARD), tr(STR_NOT_SET)); 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); GUI.drawButtonHints(renderer, labels.btn1, labels.btn2, labels.btn3, labels.btn4);
renderer.displayBuffer(); renderer.displayBuffer();
+14 -5
View File
@@ -215,6 +215,13 @@
return parseFloat(val.toFixed(2)).toLocaleString() + ' ' + units[i]; 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) { function formatUptime(seconds) {
if (seconds == null) return 'N/A'; if (seconds == null) return 'N/A';
const h = Math.floor(seconds / 3600); const h = Math.floor(seconds / 3600);
@@ -255,7 +262,7 @@
? formatBytes(data.sdUsed) + ' / ' + formatBytes(data.sdTotal) ? formatBytes(data.sdUsed) + ' / ' + formatBytes(data.sdTotal)
: 'N/A'; : 'N/A';
} else { } else {
document.getElementById('sd-space').textContent = 'Not loaded'; document.getElementById('sd-space').textContent = SD_LABELS.NOT_LOADED;
} }
} }
@@ -270,14 +277,15 @@
setSdButtonState(true); setSdButtonState(true);
} catch (error) { } catch (error) {
console.error('Error fetching status:', error); console.error('Error fetching status:', error);
document.getElementById('sd-space').textContent = SD_LABELS.ERROR;
} }
} }
async function fetchSdStatus() { async function fetchSdStatus() {
const button = document.getElementById('load-sd-button'); const button = document.getElementById('load-sd-button');
button.disabled = true; button.disabled = true;
button.textContent = 'Loading...'; button.textContent = SD_LABELS.LOADING;
document.getElementById('sd-space').textContent = 'Loading...'; document.getElementById('sd-space').textContent = SD_LABELS.LOADING;
try { try {
const response = await fetch('/api/status'); const response = await fetch('/api/status');
@@ -290,14 +298,15 @@
} catch (error) { } catch (error) {
console.error('Error fetching SD status:', error); console.error('Error fetching SD status:', error);
button.disabled = false; 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) { function setSdButtonState(enabled) {
const button = document.getElementById('load-sd-button'); const button = document.getElementById('load-sd-button');
button.disabled = !enabled; button.disabled = !enabled;
button.textContent = enabled ? 'Load SD info' : 'Loading...'; button.textContent = enabled ? SD_LABELS.LOAD_BUTTON : SD_LABELS.LOADING;
} }
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {