Skip to content

Commit f2970bb

Browse files
Copilotdorkmo
andcommitted
Add sample data injection for both server website previews
Co-authored-by: dorkmo <[email protected]>
1 parent 4e3c8d2 commit f2970bb

File tree

1 file changed

+141
-10
lines changed

1 file changed

+141
-10
lines changed

.github/workflows/html-render.yml

Lines changed: 141 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,23 +112,56 @@ jobs:
112112
113113
# Add sample data for dynamic content
114114
if page_name == 'dashboard':
115-
# Add sample tank data at the end before closing body tag
115+
# Add sample tank data grouped by sites
116116
sample_data = '''
117+
<h2>North Facility</h2>
117118
<div class="tank-container">
118119
<div class="tank-card">
119-
<div class="tank-header">Site A - Tank #1</div>
120-
<div class="tank-level">Level: 75%</div>
121-
<div class="tank-change positive">Change: +5%</div>
122-
<div class="status-normal">Status: Normal</div>
120+
<div class="tank-header">Tank #1</div>
121+
<div class="tank-level">Level: 85.3%</div>
122+
<div class="tank-change positive">24hr Change: +2.1%</div>
123+
<div class="status status-normal">Status: Normal</div>
124+
<div style="font-size: 12px; color: #666; margin-top: 10px;">Updated: 11/22/2025, 4:55:56 AM</div>
123125
</div>
124126
<div class="tank-card">
125-
<div class="tank-header">Site B - Tank #2</div>
126-
<div class="tank-level">Level: 30%</div>
127-
<div class="tank-change negative">Change: -10%</div>
128-
<div class="status-alarm">Status: LOW ALARM</div>
127+
<div class="tank-header">Tank #2</div>
128+
<div class="tank-level">Level: 52.1%</div>
129+
<div class="tank-change negative">24hr Change: -3.2%</div>
130+
<div class="status status-normal">Status: Normal</div>
131+
<div style="font-size: 12px; color: #666; margin-top: 10px;">Updated: 11/22/2025, 4:55:56 AM</div>
129132
</div>
130133
</div>
131-
<div class="footer">Last updated: 2025-11-12 18:00:00 UTC</div>
134+
<h2>South Facility</h2>
135+
<div class="tank-container">
136+
<div class="tank-card">
137+
<div class="tank-header">Tank #1</div>
138+
<div class="tank-level">Level: 22.5%</div>
139+
<div class="tank-change negative">24hr Change: -8.5%</div>
140+
<div class="status status-alarm">Status: LOW</div>
141+
<div style="font-size: 12px; color: #666; margin-top: 10px;">Updated: 11/22/2025, 4:54:56 AM</div>
142+
</div>
143+
</div>
144+
<h2>East Facility</h2>
145+
<div class="tank-container">
146+
<div class="tank-card">
147+
<div class="tank-header">Tank #1</div>
148+
<div class="tank-level">Level: 95.8%</div>
149+
<div class="tank-change positive">24hr Change: +1.2%</div>
150+
<div class="status status-normal">Status: Normal</div>
151+
<div style="font-size: 12px; color: #666; margin-top: 10px;">Updated: 11/22/2025, 4:56:26 AM</div>
152+
</div>
153+
</div>
154+
<h2>West Facility</h2>
155+
<div class="tank-container">
156+
<div class="tank-card">
157+
<div class="tank-header">Tank #1</div>
158+
<div class="tank-level">Level: 15.2%</div>
159+
<div class="tank-change negative">24hr Change: -12.8%</div>
160+
<div class="status status-alarm">Status: CRITICAL</div>
161+
<div style="font-size: 12px; color: #666; margin-top: 10px;">Updated: 11/22/2025, 4:57:26 AM</div>
162+
</div>
163+
</div>
164+
<div class="footer">Last updated: 2025-11-22 18:00:00 UTC</div>
132165
</body>
133166
</html>
134167
'''
@@ -155,6 +188,8 @@ jobs:
155188
mkdir -p /tmp/html-112025
156189
python3 << 'EOF'
157190
import re
191+
import json
192+
import time
158193
159194
ino_file = 'TankAlarm-112025-Server-BluesOpta/TankAlarm-112025-Server-BluesOpta.ino'
160195
output_dir = '/tmp/html-112025'
@@ -169,11 +204,107 @@ jobs:
169204
if match:
170205
html_content = match.group(1)
171206
207+
# Create sample data for the server dashboard
208+
current_time = int(time.time())
209+
sample_data = {
210+
"serverUid": "dev:server001",
211+
"server": {
212+
"name": "Demo Tank Alarm Server",
213+
"clientFleet": "demo-tankalarm-clients",
214+
"webRefreshSeconds": 60,
215+
"pinConfigured": True
216+
},
217+
"nextDailyEmailEpoch": current_time + 43200, # 12 hours from now
218+
"lastSyncEpoch": current_time - 180, # 3 minutes ago
219+
"clients": [
220+
{
221+
"uid": "dev:client001",
222+
"site": "North Facility",
223+
"lastUpdate": current_time - 180,
224+
"tanks": [
225+
{
226+
"tank": 1,
227+
"label": "Primary",
228+
"levelInches": 78.5,
229+
"percent": 85.3,
230+
"alarm": False,
231+
"lastUpdate": current_time - 180
232+
},
233+
{
234+
"tank": 2,
235+
"label": "Secondary",
236+
"levelInches": 45.2,
237+
"percent": 52.1,
238+
"alarm": False,
239+
"lastUpdate": current_time - 180
240+
}
241+
]
242+
},
243+
{
244+
"uid": "dev:client002",
245+
"site": "South Facility",
246+
"lastUpdate": current_time - 240,
247+
"tanks": [
248+
{
249+
"tank": 1,
250+
"label": "Storage",
251+
"levelInches": 18.3,
252+
"percent": 22.5,
253+
"alarm": True,
254+
"alarmType": "LOW",
255+
"lastUpdate": current_time - 240
256+
}
257+
]
258+
},
259+
{
260+
"uid": "dev:client003",
261+
"site": "East Facility",
262+
"lastUpdate": current_time - 150,
263+
"tanks": [
264+
{
265+
"tank": 1,
266+
"label": "Main",
267+
"levelInches": 92.1,
268+
"percent": 95.8,
269+
"alarm": False,
270+
"lastUpdate": current_time - 150
271+
}
272+
]
273+
},
274+
{
275+
"uid": "dev:client004",
276+
"site": "West Facility",
277+
"lastUpdate": current_time - 90,
278+
"tanks": [
279+
{
280+
"tank": 1,
281+
"label": "Backup",
282+
"levelInches": 12.7,
283+
"percent": 15.2,
284+
"alarm": True,
285+
"alarmType": "CRITICAL",
286+
"lastUpdate": current_time - 90
287+
}
288+
]
289+
}
290+
]
291+
}
292+
293+
# Inject the sample data
294+
sample_data_json = json.dumps(sample_data)
295+
296+
# Replace the refreshData() call with data injection
297+
html_content = html_content.replace(
298+
'refreshData();',
299+
f'applyServerData({sample_data_json}, null);'
300+
)
301+
172302
output_file = output_dir + '/dashboard.html'
173303
with open(output_file, 'w', encoding='utf-8') as out:
174304
out.write(html_content)
175305
176306
print(f'Extracted dashboard HTML: {len(html_content)} bytes')
307+
print(f'Injected sample data with {len(sample_data["clients"])} clients')
177308
178309
# Find the CONFIG_GENERATOR_HTML constant
179310
config_pattern = r'static const char CONFIG_GENERATOR_HTML\[\] PROGMEM = R"HTML\((.*?)\)HTML"'

0 commit comments

Comments
 (0)