Smart Soil Monitoring Dashboard

Plot Status

Active Alerts

    Soil Moisture Trend (Last 48 Hours)

    Manage Farm Plots & Alert Thresholds

    Log New Sensor Reading

    Full Sensor Log

    TimePlotMoistureNPKActions

    No data

    '); card.classList.add(statusClass); plotsGrid.appendChild(card); }); if(alerts.length > 0) { alertsList.innerHTML = alerts.map(a => `
  • ${a.type === 'danger' ? '🔴' : '🟡'}
    ${a.plotName}: ${a.message}
  • `).join(''); } else { alertsList.innerHTML = '
  • ✅ No urgent alerts. All systems normal.
  • '; } // Chart const fortyEightHoursAgo = dateFns.subHours(currentTime, 48); const trendData = state.sensorLog.filter(l => l.timestamp >= fortyEightHoursAgo); const datasets = state.plots.map((plot, i) => { const colors = ['#2980b9', '#27ae60', '#f39c12']; return { label: plot.name, data: trendData.filter(l => l.plotId === plot.id).map(l => ({ x: l.timestamp, y: l.soilMoisture })), borderColor: colors[i % colors.length], tension: 0.1 } }); charts.moisture = new Chart(document.getElementById('moistureChart').getContext('2d'), { type: 'line', data: { datasets }, options: { responsive: true, maintainAspectRatio: false, scales: { x: { type: 'time', time: { unit: 'hour' } }, y: { title: { display: true, text: 'Soil Moisture (%)' } } } } }); }; const renderManagementTab = () => { /* Logic to render management forms and tables */ }; // --- EVENT LISTENERS --- // Placeholder for CRUD event listeners window.soilSwitchTab = (evt, tabName) => { document.querySelectorAll('#soil-dashboard-container .soil-tab-content').forEach(tc => tc.style.display = 'none'); document.querySelectorAll('#soil-dashboard-container .soil-tab-button').forEach(tl => tl.classList.remove('active')); document.getElementById(tabName).style.display = 'block'; if (tabName === 'data') renderManagementTab(); }; // --- INITIALIZATION --- loadState(); renderAll(); });
    Scroll to Top