diff --git a/.dockerignore b/.dockerignore index 665431c..e85971e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -38,4 +38,4 @@ calendar.db **/tests/ # Migrations (not needed for builds) -migrations/ \ No newline at end of file +migrations/ diff --git a/backend/migrations/004_add_style_preference.sql b/backend/migrations/004_add_style_preference.sql new file mode 100644 index 0000000..ff26dd5 --- /dev/null +++ b/backend/migrations/004_add_style_preference.sql @@ -0,0 +1,2 @@ +-- Add calendar style preference to user preferences +ALTER TABLE user_preferences ADD COLUMN calendar_style TEXT DEFAULT 'default'; \ No newline at end of file diff --git a/backend/src/auth.rs b/backend/src/auth.rs index b62e182..cb47cba 100644 --- a/backend/src/auth.rs +++ b/backend/src/auth.rs @@ -91,6 +91,7 @@ impl AuthService { calendar_time_increment: preferences.calendar_time_increment, calendar_view_mode: preferences.calendar_view_mode, calendar_theme: preferences.calendar_theme, + calendar_style: preferences.calendar_style, calendar_colors: preferences.calendar_colors, }, }) diff --git a/backend/src/db.rs b/backend/src/db.rs index aa286aa..0f6fdc7 100644 --- a/backend/src/db.rs +++ b/backend/src/db.rs @@ -93,6 +93,7 @@ pub struct UserPreferences { pub calendar_time_increment: Option, pub calendar_view_mode: Option, pub calendar_theme: Option, + pub calendar_style: Option, pub calendar_colors: Option, // JSON string pub updated_at: DateTime, } @@ -106,6 +107,7 @@ impl UserPreferences { calendar_time_increment: Some(15), calendar_view_mode: Some("month".to_string()), calendar_theme: Some("light".to_string()), + calendar_style: Some("default".to_string()), calendar_colors: None, updated_at: Utc::now(), } @@ -264,14 +266,15 @@ impl<'a> PreferencesRepository<'a> { sqlx::query( "INSERT INTO user_preferences (user_id, calendar_selected_date, calendar_time_increment, - calendar_view_mode, calendar_theme, calendar_colors, updated_at) - VALUES (?, ?, ?, ?, ?, ?, ?)", + calendar_view_mode, calendar_theme, calendar_style, calendar_colors, updated_at) + VALUES (?, ?, ?, ?, ?, ?, ?, ?)", ) .bind(&prefs.user_id) .bind(&prefs.calendar_selected_date) .bind(&prefs.calendar_time_increment) .bind(&prefs.calendar_view_mode) .bind(&prefs.calendar_theme) + .bind(&prefs.calendar_style) .bind(&prefs.calendar_colors) .bind(&prefs.updated_at) .execute(self.db.pool()) @@ -286,7 +289,7 @@ impl<'a> PreferencesRepository<'a> { sqlx::query( "UPDATE user_preferences SET calendar_selected_date = ?, calendar_time_increment = ?, - calendar_view_mode = ?, calendar_theme = ?, + calendar_view_mode = ?, calendar_theme = ?, calendar_style = ?, calendar_colors = ?, updated_at = ? WHERE user_id = ?", ) @@ -294,6 +297,7 @@ impl<'a> PreferencesRepository<'a> { .bind(&prefs.calendar_time_increment) .bind(&prefs.calendar_view_mode) .bind(&prefs.calendar_theme) + .bind(&prefs.calendar_style) .bind(&prefs.calendar_colors) .bind(Utc::now()) .bind(&prefs.user_id) diff --git a/backend/src/handlers/preferences.rs b/backend/src/handlers/preferences.rs index 74a656c..aa405e2 100644 --- a/backend/src/handlers/preferences.rs +++ b/backend/src/handlers/preferences.rs @@ -38,6 +38,7 @@ pub async fn get_preferences( calendar_time_increment: preferences.calendar_time_increment, calendar_view_mode: preferences.calendar_view_mode, calendar_theme: preferences.calendar_theme, + calendar_style: preferences.calendar_style, calendar_colors: preferences.calendar_colors, })) } @@ -78,6 +79,9 @@ pub async fn update_preferences( if request.calendar_theme.is_some() { preferences.calendar_theme = request.calendar_theme; } + if request.calendar_style.is_some() { + preferences.calendar_style = request.calendar_style; + } if request.calendar_colors.is_some() { preferences.calendar_colors = request.calendar_colors; } @@ -94,6 +98,7 @@ pub async fn update_preferences( calendar_time_increment: preferences.calendar_time_increment, calendar_view_mode: preferences.calendar_view_mode, calendar_theme: preferences.calendar_theme, + calendar_style: preferences.calendar_style, calendar_colors: preferences.calendar_colors, }), )) diff --git a/backend/src/models.rs b/backend/src/models.rs index b14f9f8..d53b020 100644 --- a/backend/src/models.rs +++ b/backend/src/models.rs @@ -28,6 +28,7 @@ pub struct UserPreferencesResponse { pub calendar_time_increment: Option, pub calendar_view_mode: Option, pub calendar_theme: Option, + pub calendar_style: Option, pub calendar_colors: Option, } @@ -37,6 +38,7 @@ pub struct UpdatePreferencesRequest { pub calendar_time_increment: Option, pub calendar_view_mode: Option, pub calendar_theme: Option, + pub calendar_style: Option, pub calendar_colors: Option, } diff --git a/calendar.db b/calendar.db index 46985a5..0fd9415 100644 Binary files a/calendar.db and b/calendar.db differ diff --git a/compose.yml b/compose.yml index ac729d4..ad09c3e 100644 --- a/compose.yml +++ b/compose.yml @@ -1,17 +1,16 @@ services: calendar-backend: build: . - env_file: - - .env ports: - "3000:3000" volumes: - ./data/site_dist:/srv/www + - ./data/db:/db calendar-frontend: image: caddy - env_file: - - .env + environment: + - BACKEND_API_URL=http://localhost:3000/api ports: - "80:80" - "443:443" diff --git a/frontend/Cargo.toml b/frontend/Cargo.toml index 407cf33..cd2759d 100644 --- a/frontend/Cargo.toml +++ b/frontend/Cargo.toml @@ -13,6 +13,8 @@ web-sys = { version = "0.3", features = [ "HtmlSelectElement", "HtmlInputElement", "HtmlTextAreaElement", + "HtmlLinkElement", + "HtmlHeadElement", "Event", "MouseEvent", "InputEvent", diff --git a/frontend/index.html b/frontend/index.html index de3186b..452dfb4 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -6,6 +6,7 @@ +