Commit 077beabd authored by Jasin's avatar Jasin

New Form WIP

parent 6529916a
......@@ -17,8 +17,6 @@ curl_setopt_array($curl, array(
$response = curl_exec($curl);
die($response);
$err = curl_error($curl);
curl_close($curl);
......@@ -31,15 +29,16 @@ else
{
$jsonResponse = json_decode($response);
var_dump($jsonResponse);
die();
if ($jsonResponse === null)
{
header("Location: 404");
}
else if(count($jsonResponse) == 0)
{
header("Location: 404");
}
else
{
die("Jetzt Stats laden");
header("Location: ../main?data=" . $response);
}
}
\ No newline at end of file
......@@ -13,47 +13,14 @@
<body>
<canvas id="myChart"></canvas>
<div class="container">
<div class="row">
<div class="col-md-1 col-sm-1"></div>
<div class="col-md-4 col-sm-4">
<div class="form-group">
<input type="text" class="form-control" id="lineLabel" placeholder="Linien Name">
</div>
</div>
<div class="col-md-2 col-sm-2"></div>
<div class="col-md-4 col-sm-4">
<div class="form-group">
<input type="number" class="form-control" id="amount" placeholder="Anzahl der Einträge">
</div>
</div>
<div class="col-md-1 col-sm-1"></div>
</div>
<div class="row">
<button id="submitButton" class="btn btn-primary">Submit</button>
</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>
let first = true;
document.getElementById("submitButton").addEventListener("click", function(){
let amount = document.getElementById("amount").value;
document.getElementById("amount").disabled = true;
let lineLabel = document.getElementById("lineLabel").value;
dataLoader(lineLabel, amount, first);
first = false;
$( document ).ready(function()
{
dataLoader(null, null, true);
});
</script>
</body>
......
......@@ -48,41 +48,80 @@ let chartConfig =
function dataLoader(lineLabel, amount, first)
{
let settings =
if(first === true)
{
let response = findGetParameter("data");
response = JSON.parse(response);
console.log(response);
let dataDelays = [];
for(let i = 0; i < response.length; i++)
{
"async": true,
"crossDomain": true,
"url": "https://rnv-monitor.de/public/server/getInfosForStats.php",
"method": "GET",
"data":{"lineLabel" : lineLabel, "amount": amount}
};
dataDelays.push(response[i].delays);
}
$.ajax(settings)
.done(function (response)
let labels = [];
for(let e = 0; e < amount; e++)
{
//Get Information
response = JSON.parse(response);
console.log(response);
let dataDelays = [];
labels.push(response[e].created);
}
chartConfig.data.labels = labels;
for(let i = 0; i < response.length; i++)
initChart(chartConfig);
addDataSet(dataDelays, lineLabel);
}
else
{
let settings =
{
dataDelays.push(response[i].delays);
}
"async": true,
"crossDomain": true,
"url": "https://rnv-monitor.de/public/server/getInfosForStats.php",
"method": "GET",
"data":{"lineLabel" : lineLabel, "amount": amount}
};
if(first)
$.ajax(settings)
.done(function (response)
{
let labels = [];
for(let e = 0; e < amount; e++)
//Get Information
response = JSON.parse(response);
console.log(response);
let dataDelays = [];
for(let i = 0; i < response.length; i++)
{
labels.push(response[e].created);
dataDelays.push(response[i].delays);
}
chartConfig.data.labels = labels;
initChart(chartConfig);
}
if(first)
{
let labels = [];
for(let e = 0; e < amount; e++)
{
labels.push(response[e].created);
}
chartConfig.data.labels = labels;
addDataSet(dataDelays, lineLabel);
});
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