Show SD-card info only if requested
This commit is contained in:
@@ -456,6 +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_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"
|
||||||
|
|||||||
@@ -375,6 +375,7 @@ STR_FLASH_USED: "Flash utilisé"
|
|||||||
STR_UPTIME: "Temps d'activité"
|
STR_UPTIME: "Temps d'activité"
|
||||||
STR_CHARGING: "En charge"
|
STR_CHARGING: "En charge"
|
||||||
STR_GATHERING_DATA: "Collecte des données…"
|
STR_GATHERING_DATA: "Collecte des données…"
|
||||||
|
STR_SD_UPDATE_PROMPT: "Appuyez sur mise à jour"
|
||||||
STR_WEATHER: "Météo"
|
STR_WEATHER: "Météo"
|
||||||
STR_WEATHER_LOCATION: "Lieu"
|
STR_WEATHER_LOCATION: "Lieu"
|
||||||
STR_WEATHER_NO_LOCATION: "Aucun lieu défini pour la météo"
|
STR_WEATHER_NO_LOCATION: "Aucun lieu défini pour la météo"
|
||||||
|
|||||||
@@ -334,6 +334,7 @@ STR_UPTIME: "Laufzeit"
|
|||||||
STR_CHARGING: "Lädt"
|
STR_CHARGING: "Lädt"
|
||||||
STR_GATHERING_DATA: "Daten werden gesammelt..."
|
STR_GATHERING_DATA: "Daten werden gesammelt..."
|
||||||
STR_READING: "Lese..."
|
STR_READING: "Lese..."
|
||||||
|
STR_SD_UPDATE_PROMPT: "Zum Anzeigen aktualisieren"
|
||||||
STR_UNSUPPORTED_IMAGE_FORMAT: "Nicht unterstütztes Bildformat"
|
STR_UNSUPPORTED_IMAGE_FORMAT: "Nicht unterstütztes Bildformat"
|
||||||
STR_COULD_NOT_RENDER_IMAGE: "Bild konnte nicht dargestellt werden"
|
STR_COULD_NOT_RENDER_IMAGE: "Bild konnte nicht dargestellt werden"
|
||||||
STR_FAILED_TO_SET_SLEEP_SCREEN: "Standby-Bild konnte nicht gesetzt werden"
|
STR_FAILED_TO_SET_SLEEP_SCREEN: "Standby-Bild konnte nicht gesetzt werden"
|
||||||
|
|||||||
@@ -372,6 +372,7 @@ STR_FLASH_USED: "Flash usado"
|
|||||||
STR_UPTIME: "Tempo ativo"
|
STR_UPTIME: "Tempo ativo"
|
||||||
STR_CHARGING: "Carregando"
|
STR_CHARGING: "Carregando"
|
||||||
STR_GATHERING_DATA: "Coletando dados..."
|
STR_GATHERING_DATA: "Coletando dados..."
|
||||||
|
STR_SD_UPDATE_PROMPT: "Pressione atualizar"
|
||||||
STR_WEATHER: "Clima"
|
STR_WEATHER: "Clima"
|
||||||
STR_WEATHER_LOCATION: "Localização"
|
STR_WEATHER_LOCATION: "Localização"
|
||||||
STR_WEATHER_NO_LOCATION: "Nenhuma localização definida"
|
STR_WEATHER_NO_LOCATION: "Nenhuma localização definida"
|
||||||
|
|||||||
@@ -372,6 +372,7 @@ STR_FLASH_USED: "Flash занято"
|
|||||||
STR_UPTIME: "Время работы"
|
STR_UPTIME: "Время работы"
|
||||||
STR_CHARGING: "Зарядка"
|
STR_CHARGING: "Зарядка"
|
||||||
STR_GATHERING_DATA: "Сбор данных..."
|
STR_GATHERING_DATA: "Сбор данных..."
|
||||||
|
STR_SD_UPDATE_PROMPT: "Нажмите обновить"
|
||||||
STR_WEATHER: "Погода"
|
STR_WEATHER: "Погода"
|
||||||
STR_WEATHER_LOCATION: "Местоположение"
|
STR_WEATHER_LOCATION: "Местоположение"
|
||||||
STR_WEATHER_NO_LOCATION: "Местоположение не задано"
|
STR_WEATHER_NO_LOCATION: "Местоположение не задано"
|
||||||
|
|||||||
@@ -375,6 +375,7 @@ STR_FLASH_USED: "Flash usado"
|
|||||||
STR_UPTIME: "Tiempo activo"
|
STR_UPTIME: "Tiempo activo"
|
||||||
STR_CHARGING: "Cargando"
|
STR_CHARGING: "Cargando"
|
||||||
STR_GATHERING_DATA: "Recopilando datos..."
|
STR_GATHERING_DATA: "Recopilando datos..."
|
||||||
|
STR_SD_UPDATE_PROMPT: "Presiona actualizar"
|
||||||
STR_WEATHER: "Clima"
|
STR_WEATHER: "Clima"
|
||||||
STR_WEATHER_LOCATION: "Ubicación"
|
STR_WEATHER_LOCATION: "Ubicación"
|
||||||
STR_WEATHER_NO_LOCATION: "No se ha configurado ubicación"
|
STR_WEATHER_NO_LOCATION: "No se ha configurado ubicación"
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ void SystemInformationActivity::onEnter() {
|
|||||||
Activity::onEnter();
|
Activity::onEnter();
|
||||||
status_.reset();
|
status_.reset();
|
||||||
sdStatusReady_ = false;
|
sdStatusReady_ = false;
|
||||||
|
sdLoadRequested_ = false;
|
||||||
requestUpdate();
|
requestUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,6 +37,7 @@ void SystemInformationActivity::loop() {
|
|||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect fast fields first so this page appears immediately.
|
// Collect fast fields first so this page appears immediately.
|
||||||
if (!status_.has_value()) {
|
if (!status_.has_value()) {
|
||||||
status_ = SystemStatus::collectFast();
|
status_ = SystemStatus::collectFast();
|
||||||
@@ -43,11 +45,18 @@ void SystemInformationActivity::loop() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SD stats can be slower to compute on large cards.
|
// SD stats can be slower to compute on large cards. Load them only when the
|
||||||
|
// user explicitly confirms.
|
||||||
if (!sdStatusReady_) {
|
if (!sdStatusReady_) {
|
||||||
SystemStatus::fillSdStatus(*status_);
|
if (sdLoadRequested_) {
|
||||||
sdStatusReady_ = true;
|
SystemStatus::fillSdStatus(*status_);
|
||||||
requestUpdate();
|
sdStatusReady_ = true;
|
||||||
|
sdLoadRequested_ = false;
|
||||||
|
requestUpdate();
|
||||||
|
} else if (mappedInput.wasPressed(MappedInputManager::Button::Confirm)) {
|
||||||
|
sdLoadRequested_ = true;
|
||||||
|
requestUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,14 +118,15 @@ void SystemInformationActivity::render(RenderLock&&) {
|
|||||||
drawRow(8, tr(STR_UPTIME), uptimeBuf);
|
drawRow(8, tr(STR_UPTIME), uptimeBuf);
|
||||||
|
|
||||||
if (!sdStatusReady_) {
|
if (!sdStatusReady_) {
|
||||||
drawRow(9, tr(STR_SD_CARD), tr(STR_READING));
|
const char* sdMessage = sdLoadRequested_ ? tr(STR_READING) : tr(STR_SD_UPDATE_PROMPT);
|
||||||
|
drawRow(9, tr(STR_SD_CARD), sdMessage);
|
||||||
} else if (status.sdTotalBytes > 0) {
|
} else if (status.sdTotalBytes > 0) {
|
||||||
drawRow(9, tr(STR_SD_CARD), formatBytes(status.sdUsedBytes) + " / " + formatBytes(status.sdTotalBytes));
|
drawRow(9, tr(STR_SD_CARD), formatBytes(status.sdUsedBytes) + " / " + formatBytes(status.sdTotalBytes));
|
||||||
} else {
|
} else {
|
||||||
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), "", "", "");
|
const auto labels = mappedInput.mapLabels(tr(STR_BACK), 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();
|
||||||
|
|||||||
@@ -18,4 +18,5 @@ class SystemInformationActivity final : public Activity {
|
|||||||
private:
|
private:
|
||||||
std::optional<SystemStatus> status_;
|
std::optional<SystemStatus> status_;
|
||||||
bool sdStatusReady_ = false;
|
bool sdStatusReady_ = false;
|
||||||
|
bool sdLoadRequested_ = false;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -110,6 +110,26 @@
|
|||||||
background-color: var(--accent-hover-color);
|
background-color: var(--accent-hover-color);
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.action-row {
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-row button {
|
||||||
|
padding: 10px 18px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
background-color: var(--accent-color);
|
||||||
|
color: white;
|
||||||
|
font-size: 1rem;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-row button:disabled {
|
||||||
|
opacity: 0.6;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@@ -174,7 +194,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="info-row">
|
<div class="info-row">
|
||||||
<span class="label">SD Card</span>
|
<span class="label">SD Card</span>
|
||||||
<span class="value" id="sd-space">Loading...</span>
|
<span class="value" id="sd-space">Not loaded</span>
|
||||||
|
</div>
|
||||||
|
<div class="action-row">
|
||||||
|
<button id="load-sd-button">Load SD info</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -231,6 +254,8 @@
|
|||||||
document.getElementById('sd-space').textContent = data.sdTotal
|
document.getElementById('sd-space').textContent = data.sdTotal
|
||||||
? formatBytes(data.sdUsed) + ' / ' + formatBytes(data.sdTotal)
|
? formatBytes(data.sdUsed) + ' / ' + formatBytes(data.sdTotal)
|
||||||
: 'N/A';
|
: 'N/A';
|
||||||
|
} else {
|
||||||
|
document.getElementById('sd-space').textContent = 'Not loaded';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,21 +267,43 @@
|
|||||||
}
|
}
|
||||||
const fastData = await fastResponse.json();
|
const fastData = await fastResponse.json();
|
||||||
applyStatus(fastData, false);
|
applyStatus(fastData, false);
|
||||||
document.getElementById('sd-space').textContent = 'Reading...';
|
setSdButtonState(true);
|
||||||
|
|
||||||
const response = await fetch('/api/status');
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error('Failed to fetch full status: ' + response.status + ' ' + response.statusText);
|
|
||||||
}
|
|
||||||
const data = await response.json();
|
|
||||||
applyStatus(data, true);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching status:', error);
|
console.error('Error fetching status:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch status on page load
|
async function fetchSdStatus() {
|
||||||
window.onload = fetchStatus;
|
const button = document.getElementById('load-sd-button');
|
||||||
|
button.disabled = true;
|
||||||
|
button.textContent = 'Loading...';
|
||||||
|
document.getElementById('sd-space').textContent = 'Loading...';
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/status');
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Failed to fetch SD status: ' + response.status + ' ' + response.statusText);
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
applyStatus(data, true);
|
||||||
|
button.style.display = 'none';
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching SD status:', error);
|
||||||
|
button.disabled = false;
|
||||||
|
button.textContent = 'Load SD info';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setSdButtonState(enabled) {
|
||||||
|
const button = document.getElementById('load-sd-button');
|
||||||
|
button.disabled = !enabled;
|
||||||
|
button.textContent = enabled ? 'Load SD info' : 'Loading...';
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
document.getElementById('load-sd-button').addEventListener('click', fetchSdStatus);
|
||||||
|
fetchStatus();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user