feat: Add JSON file persistence and simplify tank alert system#16
Merged
StuartF303 merged 3 commits intomainfrom Nov 9, 2025
Merged
Conversation
Backend Persistence:
- Add JsonFileStore service for local JSON file-based data persistence
- Store tanks, controls, and configuration in individual JSON files in /data directory
- Auto-load persisted data on startup with fallback to defaults
- Thread-safe concurrent operations with SemaphoreSlim
- Tanks saved to tanks.json, controls to controls.json
Tank Alert System Improvements:
- Replace LowLevelThreshold and HighLevelThreshold with single AlertLevel field
- Add AlertWhenOver boolean to configure alert direction:
* false = alert when UNDER threshold (tank running empty) - for fresh water, LPG, fuel
* true = alert when OVER threshold (tank getting full) - for waste water
- Update default tanks with appropriate alert configurations:
* Fresh Water: Alert at 20% when under (running empty)
* Waste Water: Alert at 80% when over (getting full)
* LPG: Alert at 20% when under (running empty)
- Remove global tank thresholds from SystemConfiguration.AlertSettings
- Alert levels now configured per-tank in Tanks page
UI Updates:
- Tanks.razor: Add alert level slider and "Alert When Over/Under" toggle with visual feedback
- Index.razor: Update tank color indicators to use new alert system
- Settings.razor: Remove global threshold fields, add note about per-tank configuration
- Improved alert messages with actual percentage values
- Dynamic alert severity based on criticality (Warning vs Error)
All data persists to JSON files and survives application restarts.
Data location: {AppContext.BaseDirectory}/data/
…ert system - Remove TankLowLevelThreshold and TankHighLevelThreshold from AlertSettings initialization - Update AlertService.CheckTankAlertsAsync to use AlertLevel and AlertWhenOver properties - Improve alert messages with threshold information - Dynamic severity determination based on alert direction (over vs under)
- Add JsonFileStore mock and ILogger<JsonFileStore> mock to test setup - Create temporary directory for test file storage to avoid conflicts - Update TankService constructor call to include JsonFileStore parameter - All existing tests continue to work with new persistence layer
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backend Persistence:
Tank Alert System Improvements:
UI Updates:
All data persists to JSON files and survives application restarts. Data location: {AppContext.BaseDirectory}/data/