mirror of https://github.com/aredn/aredn.git
Merge commit '9b2e95238c506d763e6698d123b836958027e4a2' into develop
* commit '9b2e95238c506d763e6698d123b836958027e4a2': fixed realtime charts
This commit is contained in:
commit
abf5a8e7b0
|
@ -3,10 +3,11 @@ BEGIN {push @INC, '/www/cgi-bin'};
|
|||
use perlfunc;
|
||||
|
||||
my $filename = '/tmp/snrlog';
|
||||
my $MAXLINES=48960; # 17bytes * 60mins * 24 hours * 2 days
|
||||
# my $MAXLINES=48960; # 17bytes * 60mins * 24 hours * 2 days
|
||||
my $MAXLINES=132480; # 23bytes * 60mins * 24 hours * 4 days
|
||||
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
|
||||
$d = sprintf ("%02d:%02d:%02d", $hour, $min, $sec);
|
||||
$d = sprintf ("%02d/%02d %02d:%02d:%02d",$mon, $mday,$hour, $min, $sec);
|
||||
($s, $n) = get_wifi_signal(get_interface("wifi"));
|
||||
$s = $n if $s eq "N/A";
|
||||
|
||||
|
|
|
@ -60,6 +60,8 @@ $header = <<EOF;
|
|||
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/canvasjs/1.7.0/jquery.canvasjs.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
var dps=[[{"label":"Init","y":0}],[{"label":"Init","y":-95}]];
|
||||
|
||||
// Read a page's GET URL variables and return them as an associative array.
|
||||
function getUrlVars()
|
||||
{
|
||||
|
@ -75,8 +77,6 @@ $header = <<EOF;
|
|||
}
|
||||
|
||||
\$(document).ready(function () {
|
||||
var dps0=[];
|
||||
var dps1=[];
|
||||
var MAXPOINTS=10;
|
||||
var chart = new CanvasJS.Chart("chartContainer", {
|
||||
backgroundColor: "#E7E7E7",
|
||||
|
@ -88,48 +88,46 @@ $header = <<EOF;
|
|||
verticalAlign: "center", // top, center, bottom
|
||||
},
|
||||
axisX: {
|
||||
title: "Time",
|
||||
title: "Time (in UTC)",
|
||||
labelAngle: -45,
|
||||
},
|
||||
axisY: {
|
||||
title: "dB",
|
||||
interlacedColor: "#F0F8FF",
|
||||
},
|
||||
data: [{
|
||||
type: "spline",
|
||||
showInLegend: true,
|
||||
legendText: "Signal",
|
||||
toolTipContent: "Signal: {y}db @ {label}",
|
||||
dataPoints: dps0,
|
||||
},
|
||||
{
|
||||
type: "line",
|
||||
showInLegend: true,
|
||||
legendText: "Noise",
|
||||
toolTipContent: "Noise: {y}db @ {label}",
|
||||
dataPoints: dps1,
|
||||
}]
|
||||
});
|
||||
data: [
|
||||
{
|
||||
type: "spline",
|
||||
showInLegend: true,
|
||||
legendText: "Signal",
|
||||
toolTipContent: "Signal: {y}db @ {label}",
|
||||
dataPoints: dps[0]
|
||||
},{
|
||||
type: "line",
|
||||
showInLegend: true,
|
||||
legendText: "Noise",
|
||||
toolTipContent: "Noise: {y}db @ {label}",
|
||||
dataPoints: dps[1]
|
||||
}
|
||||
],
|
||||
}); // --- chart
|
||||
|
||||
var updateArchiveChart = function () {
|
||||
\$.getJSON("/cgi-bin/signal2.json", function (result) {
|
||||
dps0 = result[0];
|
||||
dps1 = result[1];
|
||||
# chart.options.data[0].dataPoints = result[0];
|
||||
# chart.options.data[1].dataPoints = result[1];
|
||||
//if (chart.options.data[0].dataPoints.length > MAXPOINTS)
|
||||
//{
|
||||
// chart.options.data[0].dataPoints.shift();
|
||||
// chart.options.data[1].dataPoints.shift();
|
||||
//}
|
||||
chart.options.data[0].dataPoints = result[0];
|
||||
chart.options.data[1].dataPoints = result[1];
|
||||
chart.render();
|
||||
});
|
||||
};
|
||||
|
||||
var updateRealtimeChart = function () {
|
||||
\$.getJSON("/cgi-bin/signal2.json?realtime=1", function (result) {
|
||||
chart.options.data[0].dataPoints=result[0];
|
||||
chart.options.data[1].dataPoints=result[1];
|
||||
//if (dps[0].length > MAXPOINTS) {
|
||||
// dps[0].shift();
|
||||
// dps[1].shift();
|
||||
//}
|
||||
dps[0].push(result[0][0]);
|
||||
dps[1].push(result[1][0]);
|
||||
chart.render();
|
||||
});
|
||||
};
|
||||
|
@ -138,12 +136,13 @@ $header = <<EOF;
|
|||
|
||||
if(dmode) {
|
||||
updateRealtimeChart();
|
||||
setInterval(function(){updateRealtimeChart()}, 2000);
|
||||
setInterval(function() {updateRealtimeChart()}, 1000);
|
||||
} else {
|
||||
updateArchiveChart();
|
||||
setInterval(function() {updateArchiveChart()}, 60000);
|
||||
}
|
||||
});
|
||||
chart.render();
|
||||
}); // --- document.ready
|
||||
</script>
|
||||
</head>
|
||||
EOF
|
||||
|
@ -157,6 +156,7 @@ $page = <<EOF;
|
|||
<h1><big>$node</big></h1><hr>
|
||||
<nobr>
|
||||
<div id="chartContainer" style="width: 800px; height: 380px;"></div>
|
||||
<button onclick="window.location.href='/cgi-bin/signal2'">Archive</button><button onclick="window.location.href='/cgi-bin/signal2?realtime=1'">Realtime</button><button onclick="window.location.href='/cgi-bin/status'">Quit</button>
|
||||
</center>
|
||||
EOF
|
||||
|
||||
|
|
Loading…
Reference in New Issue