Commit all changes

This commit is contained in:
2025-04-27 17:43:41 +02:00
parent 66884527f1
commit 1c5b38fade
5 changed files with 1071 additions and 85 deletions
+25
View File
@@ -28,6 +28,7 @@ class HealthAnalyticsApp {
this.reportDetailSelect = document.getElementById('report-detail');
this.customPromptTextarea = document.getElementById('custom-prompt');
this.showGptInputCheckbox = document.getElementById('show-gpt-input');
this.sleepGoalInput = document.getElementById('sleep-goal-input');
// Buttons
this.useSampleDataButton = document.getElementById('use-sample-data');
@@ -37,6 +38,12 @@ class HealthAnalyticsApp {
// Report section
this.reportSection = document.querySelector('.report-section');
// Initialize sleep goal input from localStorage
const storedGoal = localStorage.getItem('sleep_goal');
if (storedGoal !== null) {
this.sleepGoalInput.value = storedGoal;
}
}
/**
@@ -47,6 +54,16 @@ class HealthAnalyticsApp {
this.metricsFileInput.addEventListener('change', (e) => this.handleFileInputChange(e, this.metricsFilename));
this.workoutsFileInput.addEventListener('change', (e) => this.handleFileInputChange(e, this.workoutsFilename));
// Sleep goal input event
this.sleepGoalInput.addEventListener('input', (e) => {
const value = e.target.value;
if (value && !isNaN(value)) {
localStorage.setItem('sleep_goal', value);
} else {
localStorage.removeItem('sleep_goal');
}
});
// Button click events
this.useSampleDataButton.addEventListener('click', () => this.handleUseSampleData());
this.generateReportButton.addEventListener('click', () => this.handleGenerateReport());
@@ -123,6 +140,14 @@ class HealthAnalyticsApp {
// Get analysis options
const options = this.getAnalysisOptions();
// Pass sleep goal to chartsManager
const sleepGoalValue = parseFloat(this.sleepGoalInput.value);
if (!isNaN(sleepGoalValue) && sleepGoalValue > 0) {
chartsManager.sleepGoal = sleepGoalValue;
} else {
chartsManager.sleepGoal = null;
}
// Prepare data for analysis
const data = dataProcessor.prepareDataForAnalysis();