Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retreives maxlogage calling api_FTL.php #2107

Merged
merged 1 commit into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions api_FTL.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@
$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");
Expand Down
15 changes: 3 additions & 12 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
yubiuser marked this conversation as resolved.
Show resolved Hide resolved
</div>
<div class="box-body">
<div class="chart">
Expand All @@ -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">
Expand Down
12 changes: 12 additions & 0 deletions scripts/pi-hole/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down