diff --git a/frontend/src/pages/EnvironmentReportPage.tsx b/frontend/src/pages/EnvironmentReportPage.tsx index 5e3fa19..6b83212 100644 --- a/frontend/src/pages/EnvironmentReportPage.tsx +++ b/frontend/src/pages/EnvironmentReportPage.tsx @@ -85,6 +85,17 @@ export default function EnvironmentReportPage() { const [dateRange, setDateRange] = useState<'24h' | '7d' | '30d'>('24h'); const reportRef = useRef(null); + // Define light theme chart colors for the report + const reportTheme = { + background: '#ffffff', + text: '#000000', + grid: '#e2e8f0', + temp: '#dc2626', // Red-600 + humidity: '#2563eb', // Blue-600 + vpd: '#9333ea', // Purple-600 + success: '#16a34a', // Green-600 + }; + useEffect(() => { fetchReportData(); }, [dateRange]); @@ -299,7 +310,7 @@ export default function EnvironmentReportPage() {
- {/* Header Controls - Hidden in print */} + {/* --- WEB DASHBOARD VIEW --- */}

@@ -351,9 +362,9 @@ export default function EnvironmentReportPage() {

- {/* Report Content */} -
- {/* Report Header */} + {/* Dashboard Content (Web View) */} +
+ {/* Dashboard Header */}
@@ -741,6 +752,186 @@ export default function EnvironmentReportPage() {

Generated automatically • Data subject to sensor accuracy

+ + + {/* --- CLEAN DOCUMENT LAYOUT (For PDF Generation) --- */} + {/* This div is referenced by reportRef for html2canvas */} +
+ {/* Document Header */} +
+
+

Environment Report

+

Veridian Grow Operations

+
+
+

Report Period

+

{reportData?.period.start} — {reportData?.period.end}

+

Generated: {new Date().toLocaleDateString()}

+
+
+ + {/* Executive Summary Table */} +
+

+ Executive Summary +

+
+
+ Avg Temperature + {reportData?.devices[0]?.stats.temperature.avg.toFixed(1)}°F + Min: {reportData?.devices[0]?.stats.temperature.min.toFixed(1)}° / Max: {reportData?.devices[0]?.stats.temperature.max.toFixed(1)}° +
+
+ Avg Humidity + {reportData?.devices[0]?.stats.humidity.avg.toFixed(0)}% + Min: {reportData?.devices[0]?.stats.humidity.min.toFixed(0)}% / Max: {reportData?.devices[0]?.stats.humidity.max.toFixed(0)}% +
+
+ Avg VPD + {reportData?.devices[0]?.stats.vpd.avg.toFixed(2)} + Min: {reportData?.devices[0]?.stats.vpd.min.toFixed(2)} / Max: {reportData?.devices[0]?.stats.vpd.max.toFixed(2)} +
+
+ Total Alerts + {reportData?.alertAnalytics?.summary.total || 0} + Resolution Rate: {reportData?.alertAnalytics?.summary.resolutionRate}% +
+
+
+ + {/* Historical Charts (Clean Style) */} +
+

+ Environmental Trends +

+ +
+
+

Temperature History (°F)

+ + + + val.split(',')[1]} /> + + + + +
+ +
+
+

Humidity History (%)

+ + + + + + + + +
+
+

VPD History (kPa)

+ + + + + + + + +
+
+
+
+ + {/* Data Tables Section */} +
+

+ Alert & Intervention Analysis +

+ + {/* KPI Table */} + + + + + + + + + + + + + + + + + + + + + + + + + +
MetricValueNotes
Avg Resolution Time{reportData?.alertAnalytics?.resolutionTimes.avgMinutes || '--'} minAverage time to return to normal range
Resolution Rate{reportData?.alertAnalytics?.summary.resolutionRate}%{reportData?.alertAnalytics?.summary.resolved} resolved out of {reportData?.alertAnalytics?.summary.total} total
Slowest Response{reportData?.alertAnalytics?.resolutionTimes.maxMinutes || '--'} minMax deviation duration
+ + {/* Recent Alerts List */} + {reportData?.alertAnalytics?.recentAlerts && reportData.alertAnalytics.recentAlerts.length > 0 ? ( + + + + + + + + + + + + {reportData.alertAnalytics.recentAlerts.slice(0, 15).map((alert, idx) => ( + + + + + + + + ))} + +
TimeSeverityAlert TypeMessageDuration
+ {new Date(alert.createdAt).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', month: 'short', day: 'numeric' })} + + + {alert.severity} + + {alert.type.replace('_', ' ')}{alert.message} + {alert.resolutionTimeMin ? `${alert.resolutionTimeMin.toFixed(1)}m` : '-'} +
+ ) : ( +

No recent alerts found for this period.

+ )} +
+ + {/* Footer */} +
+

© {new Date().getFullYear()} Veridian Systems • Generated via Environment Operations Manager

+
+