mirror of
https://github.com/pi-hole/web.git
synced 2026-05-08 17:49:49 +01:00
Merge pull request #2107 from pi-hole/maxlogage_via_API
Retreives maxlogage calling api_FTL.php
This commit is contained in:
+10
@@ -61,6 +61,16 @@ else
|
||||
$data = array_merge($data,$stats);
|
||||
}
|
||||
|
||||
if (isset($_GET["getMaxlogage"]) && $auth) {
|
||||
sendRequestFTL("maxlogage");
|
||||
// Convert seconds to hours and rounds to one decimal place.
|
||||
$ret = round(intval(getResponseFTL()[0]) / 3600, 1);
|
||||
// Return 24h if value is 0, empty, null or non numeric.
|
||||
$ret = $ret ?: 24;
|
||||
|
||||
$data = array_merge($data, array("maxlogage" => $ret));
|
||||
}
|
||||
|
||||
if (isset($_GET['overTimeData10mins']))
|
||||
{
|
||||
sendRequestFTL("overTime");
|
||||
|
||||
@@ -5,19 +5,10 @@
|
||||
*
|
||||
* This file is copyright under the latest version of the EUPL.
|
||||
* Please see LICENSE file for your rights under this license. */
|
||||
|
||||
$indexpage = true;
|
||||
require "scripts/pi-hole/php/header.php";
|
||||
require_once "scripts/pi-hole/php/gravity.php";
|
||||
|
||||
function getinterval()
|
||||
{
|
||||
global $piholeFTLConf;
|
||||
if (isset($piholeFTLConf["MAXLOGAGE"])) {
|
||||
return min(round(floatval($piholeFTLConf["MAXLOGAGE"]), 1), 24);
|
||||
} else {
|
||||
return "24";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!-- Sourceing CSS colors from stylesheet to be used in JS code -->
|
||||
<span class="queries-permitted"></span>
|
||||
@@ -84,7 +75,7 @@ function getinterval()
|
||||
<div class="col-md-12">
|
||||
<div class="box" id="queries-over-time">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Total queries over last <?php echo getinterval(); ?> hours</h3>
|
||||
<h3 class="box-title">Total queries over last <span class="maxlogage-interval">24</span> hours</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="chart">
|
||||
@@ -109,7 +100,7 @@ function getinterval()
|
||||
<div class="col-md-12">
|
||||
<div class="box" id="clients">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Client activity over last <?php echo getinterval(); ?> hours</h3>
|
||||
<h3 class="box-title">Client activity over last <span class="maxlogage-interval">24</span> hours</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="chart">
|
||||
|
||||
@@ -862,8 +862,20 @@ function doughnutTooltip(tooltipItems, data) {
|
||||
);
|
||||
}
|
||||
|
||||
var maxlogage = "24";
|
||||
function getMaxlogage() {
|
||||
$.getJSON("api.php?getMaxlogage", function (data) {
|
||||
if (!("FTLnotrunning" in data)) {
|
||||
maxlogage = data.maxlogage;
|
||||
}
|
||||
}).done(function () {
|
||||
$(".maxlogage-interval").html(maxlogage);
|
||||
});
|
||||
}
|
||||
|
||||
$(function () {
|
||||
// Pull in data via AJAX
|
||||
getMaxlogage();
|
||||
updateSummaryData();
|
||||
|
||||
var gridColor = $(".graphs-grid").css("background-color");
|
||||
|
||||
Reference in New Issue
Block a user