Merge pull request #2107 from pi-hole/maxlogage_via_API

Retreives maxlogage calling api_FTL.php
This commit is contained in:
Adam Warner
2022-02-03 18:04:58 +00:00
committed by GitHub
3 changed files with 25 additions and 12 deletions
+10
View File
@@ -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");
+3 -12
View File
@@ -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">
+12
View File
@@ -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");