Commit e765f87a authored by Jasin's avatar Jasin

Merge branch 'development'

parents f2066872 22eab404
......@@ -2,6 +2,7 @@
header('Access-Control-Allow-Origin: *');
$lineLabel = $_GET['lineLabel'];
$lineLabel = $_GET['date'];
$lineLabel = '"' . $lineLabel . '"';
......@@ -24,6 +25,11 @@ else
echo json_encode($encode);
}
function getAllFromToday($lineLabel)
{
//select * from rnv.tours where lineLabel = '23' and DATE(created) ='2019-04-15'
}
function getAverageValue($lineLabel)
{
require ("db.php");
......
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://rnv-monitor.de/public/server/getInfosForStats.php?lineLabel=" . $_GET['LineLabel'] . "&amount=" . $_GET['Time'],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err)
{
header("Location: 404");
}
else
{
$jsonResponse = json_decode($response);
if ($jsonResponse === null)
{
header("Location: 404");
}
else if(count($jsonResponse) == 0)
{
header("Location: 404");
}
else
{
header("Location: ../main?data=" . $response ."&lineLabel=" . $_GET['LineLabel'] . "&amount=" . $_GET['Time'] . "&method=" . $_GET['Method']);
}
}
\ No newline at end of file
<!doctype html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>StatsTest</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.css"> <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css"> <style>body{background-color: #18bc9c;}.form-control{width: 100%;}.wrapper{background: white; height: 90%; margin: 2%; padding: 2%;}#methodInfo{font-family: 'Lato', sans-serif; color: grey;}button{width: 50%; margin-left: 25%; margin-top: 20px; margin-bottom: 2%; background-color: #18bc9c; color: white; border: 3px solid #18bc9c; border-radius: 25px; -webkit-transition: 0.3s ease-in-out !important; transition: 0.3s ease-in-out !important;}button:hover{background-color: white; color: #18bc9c; -webkit-transition: 0.3s ease-in-out !important; transition: 0.3s ease-in-out !important;}h4{margin-top: 4%; width: 100%; text-align: center; color: #18bc9c;}.h4Underline{width: 10%; background-color: #18bc9c; height: 3px; margin-top: 5px;}</style></head><body><div class="wrapper"> <div class="container"> <div class="row"> <button type="button" data-toggle="modal" data-target="#AddLine" class="button">Weitere Daten hinzufügen</button> </div></div><div class="container"> <canvas class="mainChart" id="myChart"></canvas> <div class="row"> <small id="methodInfo"></small> </div></div></div><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js"></script><script>var myChart;function generateColorAsString(){/*Found: https://stackoverflow.com/questions/23095637/how-do-you-get-random-rgb-in-javascript*/ let o=Math.round, r=Math.random, s=255; return 'rgba(' + o(r()*s) + ',' + o(r()*s) + ',' + o(r()*s) + ', 0.7)';}function addDataSet(delays, name){let color=generateColorAsString(); let Dataset={label: name, backgroundColor: color, borderColor: color, data: delays, fill: false}; chartConfig.data.datasets.push(Dataset); window.myChart.update();}function initChart(config){const ctx=document.getElementById('myChart').getContext('2d'); myChart=new Chart(ctx, config);}let chartConfig={type: 'line', data:{labels: [], datasets: []}, options:{title:{display: true}}};function dataLoader(lineLabel, amount, first){if(first===true){let methodInfoLabel=document.getElementById("methodInfo"); let method=findGetParameter("method"); let response=findGetParameter("data"); response=JSON.parse(response); console.log(response); let dataDelays=[]; for(let i=0; i < response.length; i++){dataDelays.push(response[i].delays);}let labels=[]; for(let e=0; e < findGetParameter("amount"); e++){labels.push(response[e].created);}chartConfig.data.labels=labels; initChart(chartConfig); addDataSet(dataDelays, findGetParameter("lineLabel")); switch (method){case "LineByTime": methodInfoLabel.textContent="Methode: Verspätung nach Linien sortiert. Alle erfassten Verspätungen pro Tag aufsummiert"; break; default: methodInfoLabel.textContent="Methode: Nicht erfasst.";}}else{let settings={"async": true, "crossDomain": true, "url": "https://rnv-monitor.de/public/server/getInfosForStats.php", "method": "GET", "data":{"lineLabel" : lineLabel, "amount": amount}}; $.ajax(settings) .done(function (response){ response=JSON.parse(response); console.log(response); let dataDelays=[]; for(let i=0; i < response.length; i++){dataDelays.push(response[i].delays);}if(first){let labels=[]; for(let e=0; e < amount; e++){labels.push(response[e].created);}chartConfig.data.labels=labels; initChart(chartConfig);}addDataSet(dataDelays, lineLabel);});}}function findGetParameter(parameterName){var result=null, tmp=[]; location.search .substr(1) .split("&") .forEach(function (item){tmp=item.split("="); if (tmp[0]===parameterName) result=decodeURIComponent(tmp[1]);}); return result;}</script><script>$( document ).ready(function(){dataLoader(null, null, true);});</script><?php require_once ("../../Views/AddLineModal.php");?></body></html>
\ No newline at end of file
<?php
$generalStats = getGeneralStatsInformation();
header("Location: ../View/index.php/?data=" . $generalStats ."&lineLabel=" . $_GET['LineLabel'] . "&amount=" . $_GET['Time'] . "&method=" . $_GET['Method']);
function getGeneralStatsInformation()
{
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://rnv-monitor.de/public/server/getInfosForStats.php?lineLabel=" . $_GET['LineLabel'] . "&amount=" . $_GET['Time'],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err)
{
header("Location: 404");
}
else
{
$jsonResponse = json_decode($response);
if ($jsonResponse === null)
{
header("Location: 404");
}
else if(count($jsonResponse) == 0)
{
header("Location: 404");
}
else
{
return strval($response);
//header("Location: ../main?data=" . $response ."&lineLabel=" . $_GET['LineLabel'] . "&amount=" . $_GET['Time'] . "&method=" . $_GET['Method']);
}
}
}
<?php
header("Location: form");
die();
\ No newline at end of file
<?php
header("Location: form");
header("Location: generalStats");
die();
\ No newline at end of file
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>StatsTest</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.css">
<link rel="stylesheet" href="stats.css">
</head>
<body>
<div class="wrapper">
<div class="container">
<canvas class="mainChart" id="myChart"></canvas>
</div>
<div class="container">
<div class="row">
<small id="methodInfo"></small>
</div>
<div class="row">
<button type="button" data-toggle="modal" data-target="#AddLine" class="button">Weitere Daten hinzufügen</button>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js"></script>
<script src="utils.js"></script>
<script>
$( document ).ready(function()
{
dataLoader(null, null, true);
});
</script>
<?php require_once ("Views/AddLineModal.php");?>
</body>
</html>
\ No newline at end of file
body
{
background-color: #18bc9c;
}
.form-control
{
width: 100%;
}
.wrapper
{
background: white;
height: 90%;
margin: 2%;
}
#methodInfo
{
font-family: 'Lato', sans-serif;
color: grey;
}
button
{
width: 50%;
margin-left: 25%;
margin-top: 20px;
margin-bottom: 2%;
background-color: #18bc9c;
color: white;
border: 3px solid #18bc9c;
border-radius: 25px;
-webkit-transition: 0.3s ease-in-out !important;
transition: 0.3s ease-in-out !important;
}
button:hover
{
background-color: white;
color: #18bc9c;
-webkit-transition: 0.3s ease-in-out !important;
transition: 0.3s ease-in-out !important;
}
\ No newline at end of file
var myChart;
function generateColorAsString()
{
//Found: https://stackoverflow.com/questions/23095637/how-do-you-get-random-rgb-in-javascript
let o = Math.round, r = Math.random, s = 255;
return 'rgba(' + o(r()*s) + ',' + o(r()*s) + ',' + o(r()*s) + ', 0.7)';
}
function addDataSet(delays, name)
{
let color = generateColorAsString();
let Dataset =
{
label: name,
backgroundColor: color,
borderColor: color,
data: delays,
fill: false
};
chartConfig.data.datasets.push(Dataset);
window.myChart.update();
}
function initChart(config)
{
const ctx = document.getElementById('myChart').getContext('2d');
myChart = new Chart(ctx, config);
}
let chartConfig =
{
type: 'line',
data: {
labels: [],
datasets: []
},
options:
{
title:
{
display: true
}
}
};
function dataLoader(lineLabel, amount, first)
{
if(first === true)
{
let methodInfoLabel = document.getElementById("methodInfo");
let method = findGetParameter("method");
let response = findGetParameter("data");
response = JSON.parse(response);
console.log(response);
let dataDelays = [];
for(let i = 0; i < response.length; i++)
{
dataDelays.push(response[i].delays);
}
let labels = [];
for(let e = 0; e < findGetParameter("amount"); e++)
{
labels.push(response[e].created);
}
chartConfig.data.labels = labels;
initChart(chartConfig);
addDataSet(dataDelays, findGetParameter("lineLabel"));
switch (method)
{
case "LineByTime":
methodInfoLabel.textContent = "Methode: Verspätung nach Linien sortiert. Alle erfassten Verspätungen pro Tag aufsummiert";
break;
default:
methodInfoLabel.textContent = "Methode: Nicht erfasst.";
}
}
else
{
let settings =
{
"async": true,
"crossDomain": true,
"url": "https://rnv-monitor.de/public/server/getInfosForStats.php",
"method": "GET",
"data":{"lineLabel" : lineLabel, "amount": amount}
};
$.ajax(settings)
.done(function (response)
{
//Get Information
response = JSON.parse(response);
console.log(response);
let dataDelays = [];
for(let i = 0; i < response.length; i++)
{
dataDelays.push(response[i].delays);
}
if(first)
{
let labels = [];
for(let e = 0; e < amount; e++)
{
labels.push(response[e].created);
}
chartConfig.data.labels = labels;
initChart(chartConfig);
}
addDataSet(dataDelays, lineLabel);
});
}
}
function findGetParameter(parameterName) {
var result = null,
tmp = [];
location.search
.substr(1)
.split("&")
.forEach(function (item) {
tmp = item.split("=");
if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
});
return result;
}
\ No newline at end of file
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