Show "Not enough data yet" instead of hiding the battery-estimate row
Build and push server image / build-and-push (push) Successful in 40s
Build and push server image / build-and-push (push) Successful in 40s
Previously the row just disappeared whenever battery_estimate_s couldn't be computed yet, which looked like the feature was gone. Now it always shows once there's any battery reading at all, with a placeholder until enough discharge history accumulates (matches the "Not enough data yet." wording battery_chart.js already uses for the same situation on the chart).
This commit is contained in:
@@ -26,9 +26,16 @@ function renderDeviceStatusBar(device) {
|
||||
}
|
||||
if (device.battery) {
|
||||
rows.push(['Battery', `${device.battery.percent}%`, false]);
|
||||
}
|
||||
if (device.battery_estimate_s !== null && device.battery_estimate_s !== undefined) {
|
||||
rows.push(['Est. battery life left', `~${formatDuration(device.battery_estimate_s)}`, false]);
|
||||
// Shown as soon as there's any battery reading at all, even before
|
||||
// battery_estimate_s can compute a rate (needs 2h+ span and a 2%+
|
||||
// drop within the current discharge cycle -- see common.py) -- so
|
||||
// it's clear the number is coming, not that the feature is broken.
|
||||
const hasEstimate = device.battery_estimate_s !== null && device.battery_estimate_s !== undefined;
|
||||
rows.push([
|
||||
'Est. battery life left',
|
||||
hasEstimate ? `~${formatDuration(device.battery_estimate_s)}` : 'Not enough data yet',
|
||||
false,
|
||||
]);
|
||||
}
|
||||
for (const [label, value, alert] of rows) {
|
||||
const stat = document.createElement('span');
|
||||
|
||||
Reference in New Issue
Block a user