Skip to content

Commit

Permalink
Add an 'initialized' status to plugins to ensure they only start draw…
Browse files Browse the repository at this point in the history
…ing data once ready
  • Loading branch information
MrRio committed Jun 27, 2014
1 parent 21cb69b commit 0d8d2ea
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ var App = function() {
var c = chart.chart;
c.clear();

if (! charts[chartKey].plugin.initialized) {
return false;
}

var dataPointsToKeep = 5000;

charts[chartKey].values[position] = charts[chartKey].plugin.currentValue;
Expand Down
3 changes: 3 additions & 0 deletions sensors/cpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ var plugin = {
*/
interval: 200,

initialized: false,

currentValue: 0,
/**
* Grab the current value, from 0-100
*/
poll: function() {
os.cpuUsage(function(v){
plugin.currentValue = (Math.floor(v * 100));
plugin.initialized = true;
});
}
};
Expand Down
4 changes: 4 additions & 0 deletions sensors/memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ var plugin = {
*/
interval: 200,

initialized: false,


currentValue: 0,
/**
* Grab the current value, from 0-100
*/
poll: function() {
plugin.currentValue = (100 - Math.floor(os.freememPercentage() * 100));
plugin.initialized = true;
}
};

Expand Down
4 changes: 4 additions & 0 deletions sensors/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ var plugin = {
*/
interval: 2000,

initialized: false,

sort: 'cpu',

columns: ['Command', 'CPU %', 'Count', 'Memory %'],
Expand Down Expand Up @@ -113,6 +115,8 @@ var plugin = {
});

plugin.currentValue = statsArray;
plugin.initialized = true;

});
}
};
Expand Down

0 comments on commit 0d8d2ea

Please sign in to comment.