|
5 | 5 | @implements IDisposable |
6 | 6 |
|
7 | 7 | <div class="blood-sugar-card mb-2"> |
8 | | - <div class="card border-0 shadow-sm"> <div class="card-header bg-info text-white py-2"> |
| 8 | + <div class="card border-0 shadow-sm"> |
| 9 | + <div class="card-header bg-info text-white py-2"> |
9 | 10 | <div class="d-flex justify-content-between align-items-center"> |
10 | 11 | <h6 class="mb-0"> |
11 | 12 | <i class="fas fa-tint me-1"></i> |
12 | 13 | Blood Sugar Monitor |
13 | 14 | </h6> |
14 | | - <button class="btn btn-outline-light btn-sm" @onclick="ForceRefreshBloodSugarData" disabled="@isLoading"> |
| 15 | + <button class="btn btn-outline-light btn-sm" @onclick="ForceRefreshBloodSugarData" |
| 16 | + disabled="@isLoading"> |
15 | 17 | <i class="fas fa-redo me-1"></i> |
16 | | - @if (isLoading) { <span>Loading...</span> } else { <span>Force Refresh</span> } |
| 18 | + @if (isLoading) |
| 19 | + { |
| 20 | + <span>Loading...</span> |
| 21 | + } |
| 22 | + else |
| 23 | + { |
| 24 | + |
| 25 | + <span>Force Refresh</span> |
| 26 | + } |
17 | 27 | </button> |
18 | 28 | </div> |
19 | 29 | </div> |
20 | 30 | <div class="card-body py-2"> |
21 | 31 | @if (bloodSugarStatus?.CurrentReading != null) |
22 | | - { |
23 | | - <div class="row g-2"> |
24 | | - <div class="col-4"> <div class="text-center"> |
25 | | - <div class="mb-2"> |
| 32 | + { <div class="row g-2"> |
| 33 | + <div class="col-4"> |
| 34 | + <div class="text-center"> |
| 35 | + <div class="mb-2 icon-container"> |
26 | 36 | <i class="fas fa-tint fa-2x" style="color: @bloodSugarStatus.StatusColor"></i> |
27 | 37 | </div> |
28 | 38 | <div class="h6 text-muted mb-2">Current</div> |
29 | 39 | <div class="blood-sugar-display"> |
30 | | - <span class="display-1 fw-bold" style="color: @bloodSugarStatus.StatusColor">@bloodSugarStatus.CurrentReading.Sgv</span> |
| 40 | + <span class="display-1 fw-bold" |
| 41 | + style="color: @bloodSugarStatus.StatusColor">@bloodSugarStatus.CurrentReading.Sgv</span> |
31 | 42 | </div> |
32 | 43 | <div class="small text-muted">@bloodSugarStatus.StatusText</div> |
33 | 44 | </div> |
34 | 45 | </div> |
35 | | - <div class="col-4"> <div class="text-center"> |
36 | | - <div class="mb-2"> |
37 | | - <span class="fa-2x" style="color: @GetTrendColor(bloodSugarStatus.CurrentReading.Direction)">@bloodSugarStatus.CurrentReading.DirectionIcon</span> |
| 46 | + <div class="col-4"> |
| 47 | + <div class="text-center"> |
| 48 | + <div class="mb-2 icon-container"> |
| 49 | + <span class="trend-icon fw-bold" |
| 50 | + style="color: @GetTrendColor(bloodSugarStatus.CurrentReading.Direction); text-shadow: 2px 2px 4px rgba(0,0,0,0.3); filter: drop-shadow(0 0 8px @GetTrendColor(bloodSugarStatus.CurrentReading.Direction)50);">@bloodSugarStatus.CurrentReading.DirectionIcon</span> |
38 | 51 | </div> |
39 | 52 | <div class="h6 text-muted mb-2">Trend</div> |
40 | 53 | <div class="trend-display"> |
41 | | - <span class="h3 fw-semibold" style="color: @GetTrendColor(bloodSugarStatus.CurrentReading.Direction)">@bloodSugarStatus.CurrentReading.DirectionDescription</span> |
| 54 | + <span class="h3 fw-semibold" |
| 55 | + style="color: @GetTrendColor(bloodSugarStatus.CurrentReading.Direction)">@bloodSugarStatus.CurrentReading.DirectionDescription</span> |
42 | 56 | </div> |
43 | 57 | </div> |
44 | 58 | </div> |
45 | | - <div class="col-4"> <div class="text-center"> |
46 | | - <div class="mb-2"> |
47 | | - <i class="fas fa-clock fa-2x" style="color: @(bloodSugarStatus.IsStale ? "#dc3545" : "#28a745")"></i> |
| 59 | + <div class="col-4"> |
| 60 | + <div class="text-center"> |
| 61 | + <div class="mb-2 icon-container"> |
| 62 | + <i class="fas fa-clock fa-2x" |
| 63 | + style="color: @(bloodSugarStatus.IsStale ? "#dc3545" : "#28a745")"></i> |
48 | 64 | </div> |
49 | 65 | <div class="h6 text-muted mb-2">Last Reading</div> |
50 | 66 | <div class="time-display"> |
51 | | - <span class="small" style="color: @(bloodSugarStatus.IsStale ? "#dc3545" : "#6c757d")">@FormatTimeSince(bloodSugarStatus.TimeSinceLastReading)</span> |
| 67 | + <span class="small" |
| 68 | + style="color: @(bloodSugarStatus.IsStale ? "#dc3545" : "#6c757d")">@FormatTimeSince(bloodSugarStatus.TimeSinceLastReading)</span> |
52 | 69 | </div> |
53 | 70 | </div> |
54 | 71 | </div> |
55 | 72 | </div> |
56 | | - <div class="text-center mt-1"> |
| 73 | + <div class="text-center mt-1"> |
57 | 74 | <small class="text-muted"> |
58 | 75 | Updated: @lastUpdated.ToString("HH:mm:ss") |
59 | 76 | @if (bloodSugarStatus.IsStale) |
|
64 | 81 | { |
65 | 82 | <span class="ms-1">• Cached: @FormatTimeSince(DateTime.Now - bloodSugarStatus.LastUpdated)</span> |
66 | 83 | } |
67 | | - </small> </div> |
| 84 | + </small> |
| 85 | + </div> |
68 | 86 | } |
69 | 87 | else if (isLoading) |
70 | 88 | { |
|
92 | 110 | </div> |
93 | 111 | </div> |
94 | 112 |
|
95 | | -<style> .blood-sugar-card .blood-sugar-display { |
| 113 | +<style> |
| 114 | + .blood-sugar-card .blood-sugar-display { |
96 | 115 | margin: 0.25rem 0; |
97 | 116 | line-height: 0.9; |
98 | | - } .blood-sugar-card .blood-sugar-display .display-1 { |
99 | | - font-size: 3.0rem !important; |
100 | | - text-shadow: 1px 1px 2px rgba(0,0,0,0.3); |
101 | 117 | } |
102 | | - |
103 | | - /* Extra large on smaller screens for better visibility */ |
| 118 | +
|
| 119 | + .blood-sugar-card .blood-sugar-display .display-1 { |
| 120 | + font-size: 3.0rem !important; |
| 121 | + text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3); |
| 122 | + } /* Extra large on smaller screens for better visibility */ |
104 | 123 | @@media (max-width: 1024px) { |
105 | 124 | .blood-sugar-card .blood-sugar-display .display-1 { |
106 | 125 | font-size: 3.6rem !important; |
107 | 126 | } |
108 | | - }.blood-sugar-card .trend-display { |
| 127 | + } |
| 128 | +
|
| 129 | + .blood-sugar-card .trend-display { |
109 | 130 | margin: 0.25rem 0; |
110 | 131 | line-height: 1.1; |
111 | 132 | } |
112 | | - |
| 133 | +
|
113 | 134 | .blood-sugar-card .time-display { |
114 | 135 | margin: 0.25rem 0; |
115 | 136 | } |
116 | | - |
| 137 | +
|
117 | 138 | .blood-sugar-card .badge { |
118 | 139 | white-space: nowrap; |
119 | 140 | font-size: 0.7rem; |
120 | 141 | } |
121 | | - |
| 142 | +
|
122 | 143 | .blood-sugar-card .fas { |
123 | 144 | margin-bottom: 4px; |
124 | 145 | opacity: 0.8; |
125 | 146 | } |
126 | | - |
| 147 | +
|
127 | 148 | .blood-sugar-card .fas:hover { |
128 | 149 | opacity: 1; |
129 | 150 | transform: scale(1.05); |
130 | 151 | transition: all 0.2s ease-in-out; |
131 | | - } .blood-sugar-card .card-body { |
| 152 | + } |
| 153 | +
|
| 154 | + .blood-sugar-card .card-body { |
132 | 155 | padding: 1rem; |
133 | 156 | } |
134 | | - |
| 157 | +
|
135 | 158 | .blood-sugar-card .small { |
136 | 159 | font-size: 0.8rem; |
| 160 | + } /* Icon alignment containers */ |
| 161 | + .blood-sugar-card .icon-container { |
| 162 | + height: 80px; |
| 163 | + display: flex; |
| 164 | + align-items: center; |
| 165 | + justify-content: center; |
| 166 | + } |
| 167 | +
|
| 168 | + /* Custom sizing for trend icon to match fa-3x */ |
| 169 | + .blood-sugar-card .trend-icon { |
| 170 | + font-size: 4.5rem; |
| 171 | + line-height: 1; |
| 172 | + display: inline-block; |
| 173 | + vertical-align: middle; |
137 | 174 | } |
138 | 175 | </style> |
139 | 176 |
|
|
145 | 182 | protected override async Task OnInitializedAsync() |
146 | 183 | { |
147 | 184 | Logger.LogInformation("Initializing BloodSugarMonitor component..."); |
148 | | - |
| 185 | + |
149 | 186 | await RefreshBloodSugarData(); |
150 | | - // Set up auto-refresh every 1 minute (server has smart cache based on reading age) |
151 | | - refreshTimer = new Timer(async _ => |
| 187 | + // Set up auto-refresh every 1 minute (server has smart cache based on reading age) |
| 188 | + refreshTimer = new Timer(async _ => |
152 | 189 | { |
153 | 190 | try |
154 | 191 | { |
|
164 | 201 | } |
165 | 202 | }, null, TimeSpan.Zero, TimeSpan.FromMinutes(1)); |
166 | 203 | } |
167 | | - |
| 204 | + |
168 | 205 | private async Task RefreshBloodSugarData() |
169 | 206 | { |
170 | 207 | Logger.LogInformation("Refreshing blood sugar data..."); |
|
173 | 210 | { |
174 | 211 | isLoading = true; |
175 | 212 | StateHasChanged(); |
176 | | - |
| 213 | + |
177 | 214 | bloodSugarStatus = await BloodSugarService.GetBloodSugarStatusAsync(); |
178 | 215 | lastUpdated = DateTime.Now; |
179 | 216 | isLoading = false; |
180 | | - |
| 217 | + |
181 | 218 | Logger.LogInformation("Blood sugar data refreshed successfully"); |
182 | 219 | StateHasChanged(); |
183 | 220 | } |
|
220 | 257 | { |
221 | 258 | isLoading = true; |
222 | 259 | StateHasChanged(); |
223 | | - |
| 260 | + |
224 | 261 | bloodSugarStatus = await BloodSugarService.RefreshAsync(); |
225 | 262 | lastUpdated = DateTime.Now; |
226 | 263 | isLoading = false; |
227 | 264 | StateHasChanged(); |
228 | | - |
| 265 | + |
229 | 266 | Logger.LogInformation("Blood sugar data force refreshed successfully"); |
230 | 267 | } |
231 | 268 | catch (Exception ex) |
|
248 | 285 | else |
249 | 286 | return $"{(int)timeSince.TotalDays}d ago"; |
250 | 287 | } |
251 | | - |
| 288 | + |
252 | 289 | private string GetTrendColor(string direction) => direction switch |
253 | 290 | { |
254 | 291 | "DoubleUp" or "SingleUp" => "#007bff", // Blue for rising |
|
0 commit comments