Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

get settings from server on initial connection

  • Loading branch information...
commit 92bd7b2c0a9699151e782242c16f0a0b8a98cabf 1 parent a82125a
Rico Chen authored
Showing with 11 additions and 4 deletions.
  1. +1 −1  app.js
  2. +2 −1  config.js
  3. +8 −2 views/flot.jade
View
2  app.js
@@ -68,7 +68,7 @@ function parse_uptime(data) {
}, interval*1000);
})();
io.sockets.on('connection', function(socket) {
- socket.emit('setint', interval);
+ socket.emit('init', {interval:interval, limit:config.limit});
socket.on( 'reqint', function(d) {
if(!isNaN(d)) {
interval=d;
View
3  config.js
@@ -1,5 +1,6 @@
var config={
- interval:5
+ interval:5,
+ limit:1440
};
module.exports=config;
View
10 views/flot.jade
@@ -8,7 +8,7 @@ block extra_js
script(src='/javascripts/jquery.flot.js')
script(type="text/javascript")
var socket=io.connect(), d1=[], d5=[], d15=[];;
- var limit=1440; // show 2 hours data (7200/5)
+ var interval,limit=1440; // show 2 hours data (7200/5)
socket.on('newdata', function(v) {
d1.push(v[0]);
d5.push(v[1]);
@@ -16,6 +16,11 @@ block extra_js
re_flot();
});
+ socket.on('init', function(v) {
+ interval=v.interval;
+ limit=v.limit;
+ $('#update_int_lbl').text(interval);
+ });
socket.on('setint', function(v) {
if(!isNaN(v)) {
$('#update_int_lbl').text(v);
@@ -50,6 +55,7 @@ block extra_js
min:1,
max:30,
step:1,
+ value:interval,
slide: function(event, ui) {
$('#update_int_lbl').text(ui.value);
socket.emit('reqint', ui.value);
@@ -62,7 +68,7 @@ block content
p Monitoring #{what}
p Update Interval
- span#update_int_lbl (default 1000ms)
+ span#update_int_lbl
div#update_int
Please sign in to comment.
Something went wrong with that request. Please try again.