Add very basic support for viewing probe readings as graph
can only view the last hour of readings, so far
This commit is contained in:
parent
c6b2f831e5
commit
0e13e5606a
3 changed files with 114 additions and 0 deletions
66
tailbone/templates/tempmon/probes/graph.mako
Normal file
66
tailbone/templates/tempmon/probes/graph.mako
Normal file
|
@ -0,0 +1,66 @@
|
|||
## -*- coding: utf-8; -*-
|
||||
<%inherit file="/base.mako" />
|
||||
|
||||
<%def name="title()">Temperature Graph</%def>
|
||||
|
||||
<%def name="extra_javascript()">
|
||||
${parent.extra_javascript()}
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.bundle.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function() {
|
||||
|
||||
var ctx = $('#tempchart');
|
||||
|
||||
var chart = new Chart(ctx, {
|
||||
type: 'scatter',
|
||||
data: {
|
||||
datasets: [{
|
||||
label: "${probe.description}",
|
||||
data: ${json.dumps(readings_data)|n}
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
xAxes: [{
|
||||
type: 'time',
|
||||
time: {unit: 'minute'},
|
||||
position: 'bottom'
|
||||
}]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
</%def>
|
||||
|
||||
<div class="form-wrapper">
|
||||
|
||||
<div class="field-wrapper">
|
||||
<label>Appliance</label>
|
||||
<div class="field">
|
||||
% if probe.appliance:
|
||||
<a href="${url('tempmon.appliances.view', uuid=probe.appliance.uuid)}">${probe.appliance}</a>
|
||||
% endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field-wrapper">
|
||||
<label>Probe Location</label>
|
||||
<div class="field">${probe.location}</div>
|
||||
</div>
|
||||
|
||||
<div class="field-wrapper">
|
||||
<label>Showing</label>
|
||||
<div class="field">
|
||||
<select name="showing-window" id="showing-window" auto-enhance="true">
|
||||
<option value="last-hour">Last Hour</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<canvas id="tempchart" width="400" height="150"></canvas>
|
|
@ -41,6 +41,11 @@
|
|||
## rendering methods
|
||||
##############################
|
||||
|
||||
<%def name="context_menu_items()">
|
||||
${parent.context_menu_items()}
|
||||
<li>${h.link_to("View Readings as Graph", action_url('graph', instance))}</li>
|
||||
</%def>
|
||||
|
||||
<%def name="render_main_fields(form)">
|
||||
${form.render_field_readonly('client')}
|
||||
${form.render_field_readonly('config_key')}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue