diff --git a/plugins/webstats/index.html b/plugins/webstats/index.html index bd0580289..028f37282 100755 --- a/plugins/webstats/index.html +++ b/plugins/webstats/index.html @@ -86,13 +86,13 @@ .indicators-label { display: inline-block; - width: 95px; + width: 88px; height: 26px; line-height: 26px; cursor: pointer; } -.indicators-label input { +.indicators-label input[type=radio] { height: 13px; margin: 0 5px 0 0; vertical-align: -2px; diff --git a/plugins/webstats/index.py b/plugins/webstats/index.py index 1101447d2..c89944e88 100755 --- a/plugins/webstats/index.py +++ b/plugins/webstats/index.py @@ -654,17 +654,19 @@ def getLogsRealtimeInfo(): ''' import datetime args = getArgs() - check = checkArgs(args, ['site', 'type']) + check = checkArgs(args, ['site', 'type','second']) if not check[0]: return check[1] domain = args['site'] dtype = args['type'] + second = int(args['second']) + conn = pSqliteDb('web_logs', domain) timeInt = time.mktime(datetime.datetime.now().timetuple()) - conn = conn.where("time>=?", (int(timeInt) - 10,)) + conn = conn.where("time>=?", (int(timeInt) - second,)) field = 'time,body_length' field_sum = toSumField(field.replace("time,", "")) diff --git a/plugins/webstats/js/stats.js b/plugins/webstats/js/stats.js index 6fd849517..c7678d694 100644 --- a/plugins/webstats/js/stats.js +++ b/plugins/webstats/js/stats.js @@ -192,7 +192,7 @@ function wsOverviewRequest(page){ var data = rdata.data.data; var statData = rdata.data.stat_list; - console.log(statData, data); + // console.log(statData, data); var stat_pv = statData['pv'] == null?0:statData['pv']; var stat_uv = statData['uv'] == null?0:statData['uv']; @@ -383,11 +383,13 @@ function wsOverviewRequest(page){ var select_option = $('.indicators-container input:checked').parent().attr('data-name'); if (select_option != "realtime_traffic" && select_option != 'realtime_request' ){ clearInterval(ovTimer); - console.log("get_logs_realtime_info over:"+select_option); + // console.log("get_logs_realtime_info over:"+select_option); return; } - wsOriginPost("get_logs_realtime_info",'',{"site":args["site"], "type":select_option} , function(rdata){ + var second = $('#check_realtime_second').val(); + + wsOriginPost("get_logs_realtime_info",'',{"site":args["site"], "type":select_option,'second':second} , function(rdata){ var rdata = $.parseJSON(rdata.data); @@ -488,11 +490,11 @@ var html = '
\

0

\
\
\ -

实时流量?

\ +

实时流量?

\

0

\
\
\ -

每秒请求?

\ +

每秒请求?

\

0

\
\ \ @@ -525,7 +527,11 @@ var html = '
\
\
\ \ - 每秒请求\ + 每X秒请求\ +
\ +
\ + \ + \
\ \ \ @@ -592,8 +598,35 @@ $('#search_time button').click(function(){ }); -$('.indicators-container input').click(function(){ - $('.indicators-container input').each(function(){ +function initRealtimeTraffic(){ + var check_realtime_second = $('#check_realtime_second').val(); + if (check_realtime_second<1){ + check_realtime_second = 1; + $('#check_realtime_second').val(check_realtime_second); + } + + if (check_realtime_second>10){ + check_realtime_second = 10; + $('#check_realtime_second').val(check_realtime_second); + } + var title = "每秒请求"; + if (check_realtime_second > 1){ + title = '每'+check_realtime_second+'秒请求' + } + + $('#ov_title_req_second').text(title) + $('.check_realtime_request').text(title); +} + + +initRealtimeTraffic(); +$('#check_realtime_second').change(function(){ + initRealtimeTraffic(); + wsOverviewRequest(1); +}); + +$('.indicators-container input[type=radio]').click(function(){ + $('.indicators-container input[type=radio]').each(function(){ $(this).removeAttr('checked'); }); $(this).prop({'checked':true});