mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-18 03:54:17 +02:00
Add AMS humidity/temperature history tracking with charts
- Add database model for storing AMS sensor history (humidity, temperature) - Record sensor data every 5 minutes via background task - Add API endpoint to retrieve history with min/max/avg statistics - Create AMSHistoryModal component with Recharts line charts - Make humidity/temperature indicators clickable to open history - Support time range selection (6h, 24h, 48h, 7d) - Show threshold reference lines on charts (Good/Fair levels) - Add configurable data retention (default 30 days) in Settings - Auto-cleanup old data daily - Fix dark theme styling in modal using inline styles - Add Escape key to close modal
This commit is contained in:
@@ -432,6 +432,7 @@ export interface AppSettings {
|
||||
ams_humidity_fair: number; // <= this is orange, > is red
|
||||
ams_temp_good: number; // <= this is green/blue
|
||||
ams_temp_fair: number; // <= this is orange, > is red
|
||||
ams_history_retention_days: number; // days to keep AMS sensor history
|
||||
// Date/time format settings
|
||||
date_format: 'system' | 'us' | 'eu' | 'iso';
|
||||
time_format: 'system' | '12h' | '24h';
|
||||
@@ -1893,4 +1894,28 @@ export const api = {
|
||||
}),
|
||||
deleteAPIKey: (id: number) =>
|
||||
request<{ message: string }>(`/api-keys/${id}`, { method: 'DELETE' }),
|
||||
|
||||
// AMS History
|
||||
getAMSHistory: (printerId: number, amsId: number, hours = 24) =>
|
||||
request<AMSHistoryResponse>(`/ams-history/${printerId}/${amsId}?hours=${hours}`),
|
||||
};
|
||||
|
||||
// AMS History types
|
||||
export interface AMSHistoryPoint {
|
||||
recorded_at: string;
|
||||
humidity: number | null;
|
||||
humidity_raw: number | null;
|
||||
temperature: number | null;
|
||||
}
|
||||
|
||||
export interface AMSHistoryResponse {
|
||||
printer_id: number;
|
||||
ams_id: number;
|
||||
data: AMSHistoryPoint[];
|
||||
min_humidity: number | null;
|
||||
max_humidity: number | null;
|
||||
avg_humidity: number | null;
|
||||
min_temperature: number | null;
|
||||
max_temperature: number | null;
|
||||
avg_temperature: number | null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user