-
Notifications
You must be signed in to change notification settings - Fork 61
/
lab_env_db_v5.html
238 lines (214 loc) · 8.57 KB
/
lab_env_db_v5.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Basic Page Needs
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta charset="utf-8">
<title>Lab Conditions by RPi</title>
<meta name="description" content="Lab conditions - RPi">
<meta name="author" content="Peter Dalmaris">
<!-- Mobile Specific Metas
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- FONT
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
<!-- CSS
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="stylesheet" href="/static/css/normalize.css">
<link rel="stylesheet" href="/static/css/skeleton.css">
<!-- Favicon
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="icon" type="image/png" href="/static/images/favicon.png">
</head>
<body>
<div class="container">
<!-- Datetimepicker form start -->
<div class="row">
<form id="datetime_range" action="/lab_env_db" method="GET">
<div class="three columns">
<label for="from">From date</label>
<input class="u-full-width" id="datetimepicker1" type="text" value="{{from_date}}" name="from">
</div>
<div class="three columns">
<label for="to">To date</label>
<input class="u-full-width" id="datetimepicker2" type="text" value="{{to_date}}" name="to">
</div>
<div class="two columns">
<input type="hidden" class="timezone" name="timezone" /> <!-- Timezone info goes here -->
<input class="button-primary" type="submit" value="Submit" style="position:relative; top: 28px" id="submit_button" />
</div>
</form>
</div>
<!-- Datetimepicker form end -->
<div class="row">
<div class="eleven columns">
<form id="range_select" action = "/lab_env_db" method="GET">
<input type="hidden" class="timezone" name="timezone" /> <!-- Timezone info goes here -->
<div class="one column">
<input type="radio" name="range_h" value="3" id="radio_3" /><label for="radio_3">3hrs</label>
</div>
<div class="one column">
<input type="radio" name="range_h" value="6" id="radio_6" /><label for="radio_6">6hrs</label>
</div>
<div class="one column">
<input type="radio" name="range_h" value="12" id="radio_12" /><label for="radio_12">12hrs</label>
</div>
<div class="one column">
<input type="radio" name="range_h" value="24" id="radio_24" /><label for="radio_24">24hrs</label>
</div>
</form>
</div>
</div>
<div class="row">
<div class="one-third column" style="margin-top: 5%">
<strong>Showing all records</strong>
<h2>Temperatures</h2>
<table class="u-full-width">
<thead>
<tr>
<th>Date</th>
<th>°C</th>
</tr>
</thead>
<tbody>
{% for row in temp %}
<tr>
<td>{{row[0]}}</td>
<td>{{'%0.2f'|format(row[1])}}</td>
</tr>
{% endfor %}
</tbody>
</table>
<h2>Humidities</h2>
<table class="u-full-width">
<thead>
<tr>
<th>Date</th>
<th>%</th>
</tr>
</thead>
<tbody>
{% for row in hum %}
<tr>
<td>{{row[0]}}</td>
<td>{{'%0.2f'|format(row[1])}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- Google Charts Code start -->
<div class="two-thirds column" style="margin-top: 5%">
<div class="row">
<div class="row">
<div class="three columns">
<div id="chart_temps"></div>
<div id="chart_humid"></div>
</div>
</div>
</div>
</div>
<!-- Google Charts Code end -->
</div>
</body>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<!-- Datetimepicker files start -->
<link rel="stylesheet" type="text/css" href="/static/css/jquery.datetimepicker.css"/ >
<script src="/static/javascript/jquery.datetimepicker.js"></script>
<!-- jstimezonedetect script start -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstimezonedetect/1.0.4/jstz.min.js" ></script>
<script>
//This code is for the datetime range form
jQuery( "#datetime_range" ).submit(function( event ) {
timezone = jstz.determine();
jQuery(".timezone").val(timezone.name());
});
</script>
<!-- jstimezonedetect script end -->
<script>
jQuery('#datetimepicker1').datetimepicker(
{
format:'Y-m-d H:i',
defaultDate:'{{from_date}}'
});
jQuery('#datetimepicker2').datetimepicker({
format:'Y-m-d H:i',
defaultDate:'{{to_date}}'
});
jQuery("#range_select input[type=radio]").click(function(){
timezone = jstz.determine(); // Datetimepicker code
jQuery(".timezone").val(timezone.name()); // Datetimepicker code
jQuery("#range_select").submit();
});
</script>
<!-- Datetimepicker files end -->
<script>
jQuery("#range_select input[type=radio]").click(function(){
jQuery("#range_select").submit();
});
</script>
<!-- Google Charts JS start -->
<script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1','packages':['corechart']}]}"></script>
<script>
google.load('visualization', '1', {packages: ['corechart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('datetime', 'Time');
data.addColumn('number', 'Temperature');
data.addRows([
{% for row in temp %}
[new Date({{row[0][0:4]}},{{row[0][5:7]}},{{row[0][8:10]}},{{row[0][11:13]}},{{row[0][14:16]}}),
{{'%0.2f'|format(row[1])}}],
{% endfor %}
]);
var options = {
width: 600,
height: 563,
hAxis: {
title: "Date",
gridlines: { count: {{temp_items}}, color: '#CCC' },
format: 'dd-MMM-yyyy HH:mm' },
vAxis: {
title: 'Degrees'
},
title: 'Temperature',
curveType: 'function' //Makes line curved
};
var chart = new google.visualization.LineChart(document.getElementById('chart_temps'));
chart.draw(data, options);
}
</script>
<script>
google.load('visualization', '1', {packages: ['corechart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('datetime', 'Time');
data.addColumn('number', 'Humidity');
data.addRows([
{% for row in hum %}
[new Date({{row[0][0:4]}},{{row[0][5:7]}},{{row[0][8:10]}},{{row[0][11:13]}},{{row[0][14:16]}}),{{'%0.2f'|format(row[1])}}],
{% endfor %}
]);
var options = {
width: 600,
height: 563,
hAxis: {
title: "Date",
gridlines: { count: {{hum_items}}, color: '#CCC' },
format: 'dd-MMM-yyyy HH:mm' },
vAxis: {
title: 'Percent'
},
title: 'Humidity',
curveType: 'function' //Makes line curved
};
var chart = new google.visualization.LineChart(document.getElementById('chart_humid'));
chart.draw(data, options);
}
</script>
<!-- Google Charts JS end -->
</html>