ESP

ESP Monitor
ESP Health Monitor

Data Entry


Dashboard

0

Healthy

0

Faulty

0

Shutdown
ESP Health Monitor

Data Entry


Dashboard

0

Healthy

0

Faulty

0

Shutdown
"; // build fields const statuses = ["Healthy","Attention","Faulty","Shutdown"]; let html=""; for(let i=1;i<=6;i++){ html += ``; } document.getElementById("fields").innerHTML = html; // SAVE DATA function save(){ let data={ entry_date:document.getElementById("date").value, unit_no:document.getElementById("unit").value, remarks:document.getElementById("remarks").value, updated_by:"admin", updated_at:new Date().toISOString() }; for(let i=1;i<=6;i++){ data[`pass_a_field_${i}`]=document.getElementById(`A${i}`).value; } fetch(URL,{ method:"POST", body:JSON.stringify(data) }).then(()=>alert("Saved")); } // LOAD DASHBOARD async function load(){ const res = await fetch(URL); const data = await res.json(); let h=0,f=0,s=0; data.forEach(d=>{ Object.values(d).forEach(v=>{ if(v==="Healthy")h++; if(v==="Faulty")f++; if(v==="Shutdown")s++; }); }); document.getElementById("healthy").innerText=h; document.getElementById("faulty").innerText=f; document.getElementById("shutdown").innerText=s; new Chart(document.getElementById("chart"),{ type:"doughnut", data:{ labels:["Healthy","Faulty","Shutdown"], datasets:[{data:[h,f,s]}] } }); } load();