ln.skyscanner/www/checks/index.html

110 lines
3.4 KiB
HTML
Raw Normal View History

2019-04-04 00:50:53 +02:00
<%frame "frame.html"%>
<h1>Checks</h1>
<div class="flex row">
<div>
2019-04-05 00:59:04 +02:00
<select id="interval" style="width: 180px;">
<option value="3600">1 Stunde</option>
<option value="21600">6 Stunden</option>
<option value="43200">12 Stunden</option>
<option value="86400">1 Tag</option>
<option value="604800">1 Woche</option>
</select><br/>
<br/>
2019-04-12 00:52:55 +02:00
<input type="text" id="filter"><br/>
<br/>
2019-04-04 00:50:53 +02:00
<select size="25" id="perfList"></select>
</div>
<div>
<canvas id="perfChart" width="1000" height="500"></canvas>
</div>
</div>
<script type="text/javascript">
moment.defaultFormat = "DD.MM.YYYY HH:mm";
2019-04-06 09:36:43 +02:00
//Chart.defaults.global.defaultColor = 'rgba(0.1,0.1,1.0,1.0)';
2019-04-04 00:50:53 +02:00
var chartCTX = $("#perfChart");
var chart = new Chart( chartCTX, {
2019-04-12 14:19:30 +02:00
type: 'line',
2019-04-04 00:50:53 +02:00
data: {
datasets: [
{
label: "-",
2019-04-06 09:36:43 +02:00
data: [],
backgroundColor: '#04E000',
2019-04-04 00:50:53 +02:00
}
]
},
options: {
scales: {
2019-04-04 19:34:19 +02:00
yAxes: [
{
ticks: {
2019-04-06 09:36:43 +02:00
callback: ScaleSI,
beginAtZero: true,
2019-04-04 19:34:19 +02:00
}
}
],
2019-04-04 00:50:53 +02:00
xAxes: [{
type: 'time',
time: {
unit: "minute",
tooltipFormat: "DD.MM.YYYY HH:mm",
displayFormats: {
minute: "DD.MM.YYYY HH:mm"
},
parser: moment.unix
}
}]
}
}
} );
2019-04-12 00:52:55 +02:00
var perfList = [];
skyapi().getJson("api/checker/checks", function(checks){
perfList = checks;
applyFilter();
2019-04-04 00:50:53 +02:00
});
2019-04-05 00:59:04 +02:00
function showGraph()
{
var perfName = $("#perfList").children("option:selected").val();
if (perfName)
{
2019-04-12 00:52:55 +02:00
skyapi().getJson("api/checker/checks/" + encodeURIComponent(perfName) + "?interval=" + $("#interval").children("option:selected").val(), function(perfValues){
2019-04-05 00:59:04 +02:00
chart.data.labels.length = 0;
chart.data.datasets[0].data.length = 0;
chart.data.datasets[0].label = perfName;
$.each( perfValues, function(){
if (this.TimeStamp != 0)
{
chart.data.datasets[0].data.push( { x: this.TimeStamp, y: this.Value } );
};
});
chart.update();
2019-04-04 00:50:53 +02:00
});
2019-04-05 00:59:04 +02:00
}
}
2019-04-04 00:50:53 +02:00
2019-04-12 00:52:55 +02:00
function applyFilter()
{
var pat = $("#filter").val();
$("#perfList").empty();
$.each( perfList, function(){
if (this.includes(pat))
$("#perfList").append( $( "<option value='"+ this +"'>" + this + "</option>" ) );
});
}
2019-04-05 00:59:04 +02:00
$("#perfList").change( function(e){ showGraph(); } );
$("#interval").change( function(e){ showGraph(); } );
2019-04-12 00:52:55 +02:00
$("#filter").on( "input", function(e){ applyFilter(); } );
2019-04-04 00:50:53 +02:00
2019-04-05 00:59:04 +02:00
skyapi().addRefresh( showGraph, 60 );
2019-04-04 00:50:53 +02:00
</script>