Smart Work Fatigue Monitor

Smart Work Fatigue Monitor

New Check-in

Work Context

Self-Assessment

Symptoms Checklist

Physical Symptoms:
Mental Symptoms:

Recent Check-in Log

DateWork(h)BrkStressEnergySleepSymptomsNotesAct

Note: Log data is stored in your browser's LocalStorage.

Dashboard Filters

Current Fatigue Indicator (based on latest entry in range)

N/A

Log check-ins and select a date range to view the dashboard.

Key Insights & Recommendations

  • No data to analyze.

Analysis Period: ${analysisStartDate} to ${analysisEndDate}

`; pdfHTML += `

Current Fatigue Indicator

${fatigueIndicatorLabel}
`; const chartsToInclude = [ {instance: swfmChartInstances['swfm-stress-chart'], title: "Stress Level Over Time"}, {instance: swfmChartInstances['swfm-energy-chart'], title: "Energy Level Over Time"}, {instance: swfmChartInstances['swfm-sleep-chart'], title: "Sleep Quality Over Time"}, {instance: swfmChartInstances['swfm-symptoms-chart'], title: "Top Reported Symptoms"} ]; chartsToInclude.forEach(chartInfo => { if(chartInfo.instance){ pdfHTML += `

${chartInfo.title}

`; } }); const insightsContent = document.getElementById('swfm-insights-list').outerHTML; if(insightsContent) pdfHTML += `

Key Insights & Recommendations

${insightsContent}
`; const filteredLogsForPDF = swfmFatigueLogs.filter(log => { const logDateOnly = log.datetime.toISOString().split('T')[0]; return logDateOnly >= analysisStartDate && logDateOnly <= analysisEndDate; }); if (filteredLogsForPDF.length > 0) { pdfHTML += `

Detailed Log (${analysisStartDate} to ${analysisEndDate})

`; pdfHTML += ``; filteredLogsForPDF.forEach(log => { const symptomsSummary = [...log.physicalSymptoms, ...log.mentalSymptoms]; pdfHTML += ``; }); pdfHTML += `
DateWork(h)BrkStressEnergySleepSymptomsNotes
${log.datetime.toLocaleString([],{dateStyle:'short',timeStyle:'short'})}${log.workDuration.toFixed(1)}${log.breaksTaken} ${log.stressLevel}${log.energyLevel}${log.sleepQuality} ${symptomsSummary.length > 0 ? symptomsSummary.join(', ').substring(0,30)+'...' : 'None'} ${log.notes.substring(0,30)}${log.notes.length > 30 ? '...' : ''}
`; } const pdfContainer = document.getElementById('swfm-report-content-for-pdf'); pdfContainer.innerHTML = pdfHTML; // Manually apply gradient to gauge for PDF because CSS gradients in html2pdf are tricky const gaugePdf = pdfContainer.querySelector('.swfm-indicator-gauge'); if(gaugePdf) { const c = getComputedStyle(document.documentElement); gaugePdf.style.backgroundImage = `linear-gradient(to right, ${c.getPropertyValue('--success-color')}, ${c.getPropertyValue('--warning-color')}, ${c.getPropertyValue('--danger-color')})`; } const opt = { margin: [0.5, 0.4, 0.5, 0.4], filename: `Work_Fatigue_Report_${analysisStartDate}_to_${analysisEndDate}.pdf`, image: { type: 'jpeg', quality: 0.98 }, html2canvas: { scale: 2, useCORS: true, logging: false, scrollX:0, scrollY: -window.scrollY, windowWidth: pdfContainer.scrollWidth + 100 }, jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' }, pagebreak: { mode: ['avoid-all', 'css', 'legacy'] } }; html2pdf().from(pdfContainer).set(opt).save().then(() => { pdfContainer.innerHTML = ''; }).catch(err => { console.error("Error generating PDF:", err); pdfContainer.innerHTML = ''; alert("An error occurred while generating the PDF. Check console for details."); }); }
Scroll to Top