webui: preserve temp config edits during refresh
This commit is contained in:
@@ -1158,40 +1158,60 @@ function renderConfigControls(data){
|
||||
</div>`).join("");
|
||||
}
|
||||
|
||||
const tempCount=$("tempEnabledCount");
|
||||
if(tempCount){
|
||||
tempCount.value=temps.filter(t=>t.enabled).length;
|
||||
}
|
||||
setConfigValue("tempEnabledCount", temps.filter(t=>t.enabled).length);
|
||||
|
||||
const tempBox=$("tempConfigList");
|
||||
if(tempBox){
|
||||
if(!tempBox) return;
|
||||
|
||||
const existingSignature=tempBox.dataset.signature||"";
|
||||
const nextSignature=temps.map(t=>t.id).join("|");
|
||||
|
||||
if(existingSignature!==nextSignature){
|
||||
tempBox.dataset.signature=nextSignature;
|
||||
tempBox.innerHTML=temps.map((t,i)=>`
|
||||
<div class="tempConfigCard">
|
||||
<div class="tempConfigCard" data-temp-id="${t.id}">
|
||||
<div class="tempConfigTop">
|
||||
<div class="tempConfigTitle">Temp Slot ${i+1}</div>
|
||||
<button class="danger tempClear" onclick="clearTempAssignment('${t.id}')">Clear Assignment</button>
|
||||
</div>
|
||||
|
||||
<label class="inputHelp" for="tempName${i}">Name</label>
|
||||
<input id="tempName${i}" value="${t.name||""}" placeholder="Temp name">
|
||||
<input id="tempName${i}" placeholder="Temp name" oninput="markConfigFieldTouched('tempName${i}')">
|
||||
|
||||
<div>
|
||||
<div class="inputHelp">Address</div>
|
||||
<div class="tempConfigAddress">${t.address||"unassigned"}</div>
|
||||
<div id="tempAddress${i}" class="tempConfigAddress"></div>
|
||||
</div>
|
||||
|
||||
<div class="tempConfigControls">
|
||||
<label class="tempCheck">
|
||||
<input id="tempEnabled${i}" type="checkbox" ${t.enabled?"checked":""} onchange="saveTempConfig()">
|
||||
<input id="tempEnabled${i}" type="checkbox" onchange="markConfigFieldTouched('tempEnabled${i}'); saveTempConfig()">
|
||||
Enabled
|
||||
</label>
|
||||
<label class="tempCheck">
|
||||
<input id="tempWeather${i}" type="checkbox" ${t.weather?"checked":""} onchange="saveTempConfig()">
|
||||
<input id="tempWeather${i}" type="checkbox" onchange="markConfigFieldTouched('tempWeather${i}'); saveTempConfig()">
|
||||
Weather Badge
|
||||
</label>
|
||||
</div>
|
||||
</div>`).join("");
|
||||
}
|
||||
|
||||
temps.forEach((t,i)=>{
|
||||
setConfigValue("tempName"+i,t.name||"");
|
||||
|
||||
const address=$("tempAddress"+i);
|
||||
if(address) address.textContent=t.address||"unassigned";
|
||||
|
||||
const enabled=$("tempEnabled"+i);
|
||||
if(enabled && !configTouched["tempEnabled"+i] && document.activeElement!==enabled){
|
||||
enabled.checked=!!t.enabled;
|
||||
}
|
||||
|
||||
const weather=$("tempWeather"+i);
|
||||
if(weather && !configTouched["tempWeather"+i] && document.activeElement!==weather){
|
||||
weather.checked=!!t.weather;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function saveRelayConfig(){
|
||||
@@ -1250,7 +1270,10 @@ async function saveTempConfig(){
|
||||
await fetch(api("/config/save"),{method:"POST"});
|
||||
await load();
|
||||
alert("Temperature config saved");
|
||||
clearConfigTouched(["tempEnabledCount"]);
|
||||
clearConfigTouched([
|
||||
"tempEnabledCount",
|
||||
...temps.flatMap((_,i)=>["tempName"+i,"tempEnabled"+i,"tempWeather"+i])
|
||||
]);
|
||||
}
|
||||
|
||||
async function loadWifiConfig(){
|
||||
|
||||
Reference in New Issue
Block a user