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