Skip to content

Commit 00ffa8b

Browse files
committed
new version 1.1
1 parent 3e02311 commit 00ffa8b

3 files changed

Lines changed: 69 additions & 11 deletions

File tree

‎.travis.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ deploy:
3939
file_glob: true
4040
file: dist/*
4141
on:
42-
branch: master
42+
tags: true

‎VERSION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0
1+
1.1

‎pmserver/templates/dashboard.html‎

Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,29 @@ <h1 class="page-header w-100 p-2">
2727
</h1>
2828
</div>
2929
<div class="row">
30-
<div class="badges">
30+
<h4 class="badges">
3131
<div class="badge badge-danger badge-lg m-2" id="statusBadge">
3232
Sensor status:&nbsp;
3333
<div class="badge badge-light">
3434
offline
3535
</div>
3636
</div>
3737

38-
<div class="badge badge-success badge-lg m-2">
38+
<div class="badge badge-success m-2">
3939
Version:&nbsp;
4040
<div class="badge badge-light">{{ version }}</div>
4141
</div>
42-
</div>
42+
43+
<div class="badge badge-success m-2" id="pm10max">
44+
PM10 max (40 µg/m³): &nbsp;
45+
<div class="badge badge-light">0 [0%]</div>
46+
</div>
47+
48+
<div class="badge badge-success m-2" id="pm25max">
49+
PM2.5 max (25 µg/m³): &nbsp;
50+
<div class="badge badge-light">0 [0%]</div>
51+
</div>
52+
</h4>
4353
</div>
4454

4555
{% with messages = get_flashed_messages(with_categories=True) %}
@@ -99,12 +109,14 @@ <h3>Data</h3>
99109
{% block scripts %}
100110
{{ super() }}
101111
<script>
102-
var host = 'http://localhost:5000';
103-
var data = [];
104-
var pm10 = [];
105-
var pm25 = [];
106-
var connected = false;
107-
var dataFormat = 'json';
112+
const host = 'http://localhost:5000';
113+
let data = [];
114+
let pm10 = [];
115+
let pm25 = [];
116+
let connected = false;
117+
let dataFormat = 'json';
118+
let pm10max = 0;
119+
let pm25max = 0;
108120

109121
// status handler
110122
statusHandler = function () {
@@ -126,6 +138,7 @@ <h3>Data</h3>
126138
// update DOM
127139
updateRaw();
128140
updatePlot(response);
141+
updateMax();
129142
});
130143
}
131144
};
@@ -173,6 +186,51 @@ <h3>Data</h3>
173186

174187
};
175188

189+
// update maximum values
190+
updateMax = function () {
191+
// not sure if there is a easier way
192+
let pm10only = [];
193+
let pm25only = [];
194+
pm10.forEach(e => pm10only.push(e.y));
195+
pm25.forEach(e => pm25only.push(e.y));
196+
const maxpm10 = Math.max.apply(Math, pm10only);
197+
const maxpm25 = Math.max.apply(Math, pm25only);
198+
199+
// update the badge
200+
b10 = $('#pm10max');
201+
b25 = $('#pm25max');
202+
203+
// update the value
204+
b10.children().html(maxpm10 + ' [' + Math.round((maxpm10 / 40.) * 100) + '%]');
205+
b25.children().html(maxpm25 + ' [' + Math.round((maxpm25 / 25.) * 100) + '%]');
206+
207+
// update the color
208+
if (maxpm10 >= 40) {
209+
b10.removeClass();
210+
b10.addClass('badge badge-danger m-2');
211+
}
212+
if ((maxpm10 < 40) & (maxpm10 >= 30)) {
213+
b10.removeClass();
214+
b10.addClass('badge badge-warning m-2');
215+
}
216+
if (maxpm10 < 30) {
217+
b10.removeClass();
218+
b10.addClass('badge badge-success m-2');
219+
}
220+
if (maxpm25 >= 25) {
221+
b25.removeClass();
222+
b25.addClass('badge badge-danger m-2');
223+
}
224+
if ((maxpm25 < 25) & (maxpm25 >= 18)) {
225+
b25.removeClass();
226+
b25.addClass('badge badge-warning m-2');
227+
}
228+
if (maxpm25 < 18) {
229+
b25.removeClass();
230+
b25.addClass('badge badge-success m-2');
231+
}
232+
};
233+
176234
initPlot = function () {
177235
// convert data
178236
data.forEach(el => {

0 commit comments

Comments
 (0)