-
+
@@ -312,18 +312,57 @@ document.getElementById('stxt').textContent='Err';
async function save(){
pts.sort((a,b)=>a.t-b.t);
-let cfg={'GPU-Fan':{enabled:true,mode:cMode,'fixed-speed':fSpd,'curve-points':pts.length}};
-for(let i=0;i<5;i++){
-cfg['GPU-Fan']['curve-t'+(i+1)]=i
0?pts[0].t:30,
+'curve-s1':pts.length>0?pts[0].s:30,
+'curve-t2':pts.length>1?pts[1].t:50,
+'curve-s2':pts.length>1?pts[1].s:50,
+'curve-t3':pts.length>2?pts[2].t:70,
+'curve-s3':pts.length>2?pts[2].s:75,
+'curve-t4':pts.length>3?pts[3].t:85,
+'curve-s4':pts.length>3?pts[3].s:100,
+'curve-t5':pts.length>4?pts[4].t:95,
+'curve-s5':pts.length>4?pts[4].s:100
+}};
+
try{
-let r=await fetch('/cfg.json',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({um:cfg})});
-if(r.ok){
+// First update the config
+let r1=await fetch('/cfg.json',{
+method:'POST',
+headers:{'Content-Type':'application/json'},
+body:JSON.stringify({um:cfg})
+});
+
+if(!r1.ok){
+toast('Config update failed',1);
+return;
+}
+
+// Then trigger a config save by posting to /json with save flag
+let r2=await fetch('/json/state',{
+method:'POST',
+headers:{'Content-Type':'application/json'},
+body:JSON.stringify({
+psave:true,
+'GPU-Fan':{mode:cMode}
+})
+});
+
+if(r2.ok){
toast('Saved!');
-fetch('/json/state',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({'GPU-Fan':{mode:cMode}})});
-}else toast('Fail',1);
-}catch(e){toast('Err',1)}
+}else{
+toast('Save failed',1);
+}
+}catch(e){
+console.error(e);
+toast('Error: '+e.message,1);
+}
}
function toast(m,e){
@@ -336,4 +375,4 @@ setTimeout(()=>t.classList.remove('show'),2000);