-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added User Preferences & other UX Improvements
- Loading branch information
1 parent
b1c2e7f
commit ba96490
Showing
13 changed files
with
171 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/com/akshathsaipittala/streamspace/entity/Preference.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.akshathsaipittala.streamspace.entity; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.experimental.Accessors; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@Accessors(chain = true) | ||
@NoArgsConstructor | ||
public class Preference { | ||
|
||
@Id | ||
private Integer prefId; | ||
private String name; | ||
private boolean enabled; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/com/akshathsaipittala/streamspace/repository/UserPreferences.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.akshathsaipittala.streamspace.repository; | ||
|
||
import com.akshathsaipittala.streamspace.entity.Preference; | ||
import org.springframework.data.repository.ListCrudRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface UserPreferences extends ListCrudRepository<Preference, Integer> { | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/com/akshathsaipittala/streamspace/web/api/PreferencesAPI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.akshathsaipittala.streamspace.web.api; | ||
|
||
import com.akshathsaipittala.streamspace.entity.Preference; | ||
import com.akshathsaipittala.streamspace.repository.UserPreferences; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.Optional; | ||
|
||
@Slf4j | ||
@RestController | ||
@RequestMapping("/preference") | ||
@RequiredArgsConstructor | ||
public class PreferencesAPI { | ||
|
||
final UserPreferences userPreferences; | ||
|
||
@PatchMapping | ||
public ResponseEntity<Void> saveDarkModePreference(@RequestBody Preference preference) { | ||
Optional<Preference> existingPref = userPreferences.findById(preference.getPrefId()); | ||
if (existingPref.isPresent()) { | ||
Preference updatedPref = existingPref.get(); | ||
updatedPref.setEnabled(preference.isEnabled()); | ||
userPreferences.save(updatedPref); | ||
} else { | ||
//userPreferences.save(preference); | ||
log.info("Preference with id {} not found", preference.getPrefId()); | ||
} | ||
return ResponseEntity.ok().build(); | ||
} | ||
|
||
} |
14 changes: 13 additions & 1 deletion
14
src/main/java/com/akshathsaipittala/streamspace/web/controllers/WebController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.