diff --git a/src/baby_monitor/static/diapers.html b/src/baby_monitor/static/diapers.html index d21c7dc..6bf330d 100644 --- a/src/baby_monitor/static/diapers.html +++ b/src/baby_monitor/static/diapers.html @@ -280,7 +280,7 @@ let allChildren = []; let currentDaysRange = parseInt(localStorage.getItem("lastDiaperTimeRange")) || 7; - let selectedChildId = null; // null means "All Children" + let selectedChildId = null; // null means show first/only child // Restore last selected child from localStorage const lastChildId = localStorage.getItem("lastDiaperChildFilter"); @@ -321,6 +321,11 @@ if (response.ok) { allChildren = await response.json(); + + // Auto-select first child if no selection exists + if (selectedChildId === null && allChildren.length > 0) { + selectedChildId = allChildren[0].id; + } } } catch (error) { console.error("Error loading children:", error); @@ -334,8 +339,7 @@ } function onChildChange(event) { - selectedChildId = - event.target.value === "all" ? null : parseInt(event.target.value); + selectedChildId = parseInt(event.target.value); localStorage.setItem("lastDiaperChildFilter", event.target.value); displayDiaperChanges(allDiaperChanges); } @@ -367,11 +371,21 @@ content.innerHTML = `