Skip to content

Commit

Permalink
Cleanup and custom graph history
Browse files Browse the repository at this point in the history
[FEATURE REQUEST] Add parameter to specify displayed history length of graphs #82
[BUG?] Temperature time scale oscillates between 10min and 10-sampling period #83
  • Loading branch information
LazeMSS committed Dec 11, 2022
1 parent 1840496 commit 7710eae
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
1 change: 1 addition & 0 deletions octoprint_toptemp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def __init__(self):
'decSep': ',',
'gMin': '',
'gMax': '',
'gHisSecs': 600,
'graphSettings': {
'height': 50,
'show': True,
Expand Down
22 changes: 13 additions & 9 deletions octoprint_toptemp/static/js/TopTemp.js
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,13 @@ $(function() {

// UI ready
self.onAllBound = function(){
// We dont wait for this :)
if (typeof Sortable != "function"){
var script = document.createElement('script');
script.src = '/plugin/toptemp/static/js/Sortable.min.js';
document.body.appendChild(script);
}

// Set class
$('#navbar_plugin_toptemp').addClass('navbar-text');

Expand Down Expand Up @@ -1041,13 +1048,6 @@ $(function() {
return;
}

// We dont wait for this :)
if (typeof Sortable != "function"){
var script = document.createElement('script');
script.src = '/plugin/toptemp/static/js/Sortable.min.js';
document.body.appendChild(script);
}

// Wait for js
if (!self.jsLoaded){
return;
Expand Down Expand Up @@ -1300,6 +1300,10 @@ $(function() {
}
}

var maxHis = self.popoverGHist;
if (iSettings.gHisSecs() > 0){
maxHis = 0 - iSettings.gHisSecs();
}
// Custom data or not?
if ($isCustom){
// No data?!
Expand All @@ -1316,7 +1320,7 @@ $(function() {
$.each(temp,function(x,val){
var seconds = val[0]-nowTs;
// only get last 10 min
if (seconds < self.popoverGHist){
if (seconds < maxHis){
return false;
}
dataFound++;
Expand Down Expand Up @@ -1367,7 +1371,7 @@ $(function() {
$.each(temp,function(x,val){
var seconds = Math.round((val[0]-nowTs)/1000);
// only get last 10 min
if (seconds < self.popoverGHist && dataFound > 10){
if (seconds < maxHis && dataFound > 10){
return false;
}
dataFound++;
Expand Down
32 changes: 28 additions & 4 deletions octoprint_toptemp/templates/toptemp_settings.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,14 @@
</label>
</div>
</div>
<div class="control-group" title="Graph history timescale">
<label class="control-label">Show data this many seconds old on graph</label>
<div class="controls">
<input type="number" data-bind="value: settings.plugins.toptemp.bed.gHisSecs" placeholder="seconds">
</div>
</div>
<div class="control-group" title="Graph min and max">
<label class="control-label">Force graph min,max</label>
<label class="control-label">Force graph Y min,max</label>
<div class="controls">
<input type="number" class="input-mini" data-bind="value: settings.plugins.toptemp.bed.gMin" placeholder="min">
<input type="number" class="input-mini" data-bind="value: settings.plugins.toptemp.bed.gMax" placeholder="max">
Expand Down Expand Up @@ -344,8 +350,14 @@
</label>
</div>
</div>
<div class="control-group" title="Graph history timescale">
<label class="control-label">Show data this many seconds old on graph</label>
<div class="controls">
<input type="number" data-bind="value: settings.plugins.toptemp.chamber.gHisSecs" placeholder="seconds">
</div>
</div>
<div class="control-group" title="Graph min and max">
<label class="control-label">Force graph min,max</label>
<label class="control-label">Force graph Y min,max</label>
<div class="controls">
<input type="number" class="input-mini" data-bind="value: settings.plugins.toptemp.chamber.gMin" placeholder="Min">
<input type="number" class="input-mini" data-bind="value: settings.plugins.toptemp.chamber.gMax" placeholder="Max">
Expand Down Expand Up @@ -512,8 +524,14 @@
</label>
</div>
</div>
<div class="control-group" title="Graph history timescale">
<label class="control-label">Show data this many seconds old on graph</label>
<div class="controls">
<input type="number" data-bind="value: $parent.settings.plugins.toptemp['tool'+$index()].gHisSecs" placeholder="seconds">
</div>
</div>
<div class="control-group" title="Graph min and max">
<label class="control-label">Force graph min,max</label>
<label class="control-label">Force graph Y min,max</label>
<div class="controls">
<input type="number" class="input-mini" data-bind="value: $parent.settings.plugins.toptemp['tool'+$index()].gMin" placeholder="Min">
<input type="number" class="input-mini" data-bind="value: $parent.settings.plugins.toptemp['tool'+$index()].gMax" placeholder="Max">
Expand Down Expand Up @@ -742,8 +760,14 @@
</label>
</div>
</div>
<div class="control-group" title="Graph history timescale">
<label class="control-label">Show data this many seconds old on graph</label>
<div class="controls">
<input type="number" data-settings="gHisSecs" placeholder="seconds">
</div>
</div>
<div class="control-group" title="Graph min and max">
<label class="control-label">Force graph min,max</label>
<label class="control-label">Force graph Y min,max</label>
<div class="controls">
<input type="number" class="input-mini" data-settings="gMin" placeholder="Min">
<input type="number" class="input-mini" data-settings="gMax" placeholder="Max">
Expand Down

0 comments on commit 7710eae

Please sign in to comment.