Commit 28d4eb48 authored by Jasin's avatar Jasin

Merge remote-tracking branch 'origin/development'

parents bb5402aa f9e966e5
......@@ -19,6 +19,8 @@
<link href="css/freelancer.min.css" rel="stylesheet">
<link href="css/dataSection.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.css">
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-84269579-2"></script>
<script>
......@@ -191,6 +193,23 @@
</div>
</section>
<!-- About Section -->
<section class="text-white mb-0" id="stats">
<div class="container">
<h2 class="text-center text-uppercase text-secondary">Statistik</h2>
<hr class="star-dark mb-5">
<div class="row">
<canvas class="mainChart" id="myChart"></canvas>
</div>
<div class="text-center mt-4">
<a class="btn btn-xl btn-primary" href="https://rnv-monitor.de/public/stats">
<i class="far fa-chart-bar mr-2"></i>
Statistik zu Ihrer Verbindung
</a>
</div>
</div>
</section>
<!-- About Section -->
<section class="bg-primary text-white mb-0" id="about">
<div class="container">
......@@ -306,7 +325,13 @@
<th scope="row">3</th>
<td>2019-05-18 12:29:07 - 2019-05-20 10:31:22</td>
<td>Ausfall des Serveranbieters - "massive Probleme mit dem Cluster"</td>
<td>Ausfall des gesamten Systems</td>
<td>Ausfall des gesamten Systems & Website</td>
</tr>
<tr>
<th scope="row">4</th>
<td>2019-06-07 08:40:19 - 2019-06-11 09:26:34</td>
<td>Ausfall des Serveranbieters - "massive Probleme mit dem Cluster"</td>
<td>Ausfall des gesamten Systems & Website</td>
</tr>
<tr>
<th scope="row">4</th>
......@@ -374,6 +399,15 @@
<script src="js/freelancer.min.js"></script>
<script src="js/dataLoader.js"></script>
<script src="js/chart.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js"></script>
<script>
$( document ).ready(function()
{
statsDataLoader();
});
</script>
</body>
</html>
var myChart;
function addDataSet(delays, name)
{
console.log("Add Dataset");
let color = "rgba(24, 188, 156, 1)";
let Dataset =
{
label: name,
backgroundColor: color,
borderColor: color,
data: delays,
fill: false
};
chartConfig.data.datasets.push(Dataset);
window.myChart.update();
}
function initChart(config)
{
console.log("init chart");
const ctx = document.getElementById('myChart').getContext('2d');
myChart = new Chart(ctx, config);
}
let chartConfig =
{
type: 'line',
data: {
labels: [],
datasets: []
},
options:
{
title:
{
display: true
}
}
};
function statsDataLoader()
{
console.log("Start Loading stats");
let settings =
{
"async": true,
"crossDomain": true,
"url": "https://rnv-monitor.de/public/server/getGeneralStats.php",
"method": "GET"
};
$.ajax(settings)
.done(function (response)
{
//Get Information
response = JSON.parse(response);
console.log(response);
let dataDelays = [];
let labels = [];
for(let i = 0; i < response.length; i++)
{
dataDelays.push(response[i].delays);
labels.push(response[i].created);
}
chartConfig.data.labels = labels;
initChart(chartConfig);
addDataSet(dataDelays, "Versptäung in Minuten");
});
}
\ No newline at end of file
<?php
header('Access-Control-Allow-Origin: *');
require ("db.php");
$sql = 'select CAST(created AS DATE) as "created", SUM(delay) as "delays" from rnv.tours group by CAST(created AS DATE)';
$res = mysqli_query($conn, $sql);
if ($conn->errno)
{
var_dump($conn);
die ("Fehler beim lesen der Datenbank");
}
$temp = array();
while($row = $res->fetch_assoc())
{
array_push($temp, $row);
}
die(json_encode($temp));
\ No newline at end of file
......@@ -38,12 +38,12 @@ let chartConfig =
datasets: []
},
options:
{
title:
{
display: true
}
}
{
title:
{
display: true
}
}
};
function dataLoader(lineLabel, amount, first)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment