From 8ca63c0396b21bf332a464ed48e2a9ff7aa38454 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Thu, 11 Jul 2024 03:50:31 +0800 Subject: [PATCH] update --- plugins/simpleping/js/simpleping.js | 39 ++++++++++++++++++++++++-- plugins/simpleping/simpleping_index.py | 2 +- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/plugins/simpleping/js/simpleping.js b/plugins/simpleping/js/simpleping.js index 68a195fed..363d8e4ff 100755 --- a/plugins/simpleping/js/simpleping.js +++ b/plugins/simpleping/js/simpleping.js @@ -53,6 +53,25 @@ function pingPostCallbak(method, args, callback){ },'json'); } +function pingPostCallbakN(method, args, callback){ + var req_data = {}; + req_data['name'] = 'simpleping'; + req_data['script'] = 'simpleping_index'; + req_data['func'] = method; + + if (typeof(args) == 'string'){ + req_data['args'] = JSON.stringify(toArrayObject(args)); + } else { + req_data['args'] = JSON.stringify(args); + } + + $.post('/plugins/callback', req_data, function(data) { + if(typeof(callback) == 'function'){ + callback(data); + } + },'json'); +} + function appReadme(){ @@ -103,7 +122,19 @@ function getBeforeDate(n){ function pingDataGraphPosData(){ - console.log(chartPingData.length); + if (chartPingData.length>0){ + var dlen = chartPingData.length; + last_pos = chartPingData[dlen-1]; + // console.log(start,end); + pingPostCallbakN('pingData', {'type':'pos', 'pos':last_pos['created_unix']}, function(data){ + var tmp_data = data.data; + for (x in tmp_data){ + chartPingData.push(tmp_data[x]); + } + pingDataGraphRender(); + }); + + } } @@ -130,9 +161,10 @@ function pingDataGraphData(day){ chartPingData = data.data; pingDataGraphRender(); - setInterval(function() { + clearInterval(posTimer); + posTimer = setTimeout(function() { pingDataGraphPosData(); - }, 3000); + }, 2000); }); } @@ -184,6 +216,7 @@ function pingDataGraphRender(){ // console.log('pingDataGraph'); var chartPing; var chartPingData = []; +var posTimer; function pingDataGraph(){ var tpl = '\
\ diff --git a/plugins/simpleping/simpleping_index.py b/plugins/simpleping/simpleping_index.py index 630510ca3..69a632255 100755 --- a/plugins/simpleping/simpleping_index.py +++ b/plugins/simpleping/simpleping_index.py @@ -33,7 +33,7 @@ def pingData(args = ()): atype = args['type'] if atype == 'pos': pos = args['pos'] - data = conn.where('created_unix>=?',pos).select() + data = conn.where('created_unix>?',(pos,)).select() elif atype == 'range': start = args['start'] end = args['end']