Merge remote-tracking branch 'upstream/devel' into feat/avoid-window-open

Signed-off-by: Paul Mannarino <paul.mannarino@gmail.com>
This commit is contained in:
Paul Mannarino
2021-12-02 18:31:43 -05:00
50 changed files with 3317 additions and 1515 deletions
+6
View File
@@ -64,6 +64,10 @@ $(function () {
);
},
},
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
lengthMenu: [
[10, 25, 50, 100, -1],
@@ -71,6 +75,7 @@ $(function () {
],
order: [[0, "asc"]],
stateSave: true,
stateDuration: 0,
stateSaveCallback: function (settings, data) {
utils.stateSaveCallback("LocalCNAMETable", data);
},
@@ -81,6 +86,7 @@ $(function () {
$(".deleteCustomCNAME").on("click", deleteCustomCNAME);
},
});
// Disable autocorrect in the search box
var input = document.querySelector("input[type=search]");
input.setAttribute("autocomplete", "off");
+5
View File
@@ -64,6 +64,10 @@ $(function () {
);
},
},
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
lengthMenu: [
[10, 25, 50, 100, -1],
@@ -71,6 +75,7 @@ $(function () {
],
order: [[0, "asc"]],
stateSave: true,
stateDuration: 0,
stateSaveCallback: function (settings, data) {
utils.stateSaveCallback("LocalDNSTable", data);
},
+37 -15
View File
@@ -7,7 +7,7 @@
/* global utils:false, Chart:false, moment:false */
var start__ = moment().subtract(6, "days");
var start__ = moment().subtract(7, "days");
var from = moment(start__).utc().valueOf() / 1000;
var end__ = moment();
var until = moment(end__).utc().valueOf() / 1000;
@@ -15,6 +15,12 @@ var interval = 0;
var dateformat = "MMMM Do YYYY, HH:mm";
// get the database min timestamp
var mintimestamp;
$.getJSON("api_db.php?getMinTimestamp", function (ts) {
mintimestamp = ts.mintimestamp * 1000 || 0; // return the timestamp in milliseconds or zero (in case of NaN)
});
$(function () {
$("#querytime").daterangepicker(
{
@@ -30,15 +36,15 @@ $(function () {
moment().subtract(1, "days").startOf("day"),
moment().subtract(1, "days").endOf("day"),
],
"Last 7 Days": [moment().subtract(6, "days"), moment()],
"Last 30 Days": [moment().subtract(29, "days"), moment()],
"Last 7 Days": [moment().subtract(7, "days"), moment()],
"Last 30 Days": [moment().subtract(30, "days"), moment()],
"This Month": [moment().startOf("month"), moment()],
"Last Month": [
moment().subtract(1, "month").startOf("month"),
moment().subtract(1, "month").endOf("month"),
],
"This Year": [moment().startOf("year"), moment()],
"All Time": [moment(0), moment()],
"All Time": [moment(mintimestamp), moment()],
},
opens: "center",
showDropdowns: true,
@@ -69,19 +75,21 @@ function updateQueriesOverTime() {
// Default displaying axis scaling
timeLineChart.options.scales.xAxes[0].time.unit = "hour";
if (num * interval >= 6 * 29 * 24 * 60 * 60) {
// If the requested data is more than 3 months, set ticks interval to quarterly
// Xaxis scaling based on selected daterange
if (num * interval > 4 * 365 * 24 * 60 * 60) {
// If the requested data is more than 4 years, set ticks interval to year
timeLineChart.options.scales.xAxes[0].time.unit = "year";
} else if (num * interval >= 366 * 24 * 60 * 60) {
// If the requested data is more than 1 year, set ticks interval to quarter
timeLineChart.options.scales.xAxes[0].time.unit = "quarter";
} else if (num * interval >= 3 * 29 * 24 * 60 * 60) {
} else if (num * interval >= 92 * 24 * 60 * 60) {
// If the requested data is more than 3 months, set ticks interval to months
timeLineChart.options.scales.xAxes[0].time.unit = "month";
}
if (num * interval >= 29 * 24 * 60 * 60) {
// If the requested data is more than 1 month, set ticks interval to weeks
} else if (num * interval >= 31 * 24 * 60 * 60) {
// If the requested data is 1 month or more, set ticks interval to weeks
timeLineChart.options.scales.xAxes[0].time.unit = "week";
} else if (num * interval >= 6 * 24 * 60 * 60) {
// If the requested data is more than 1 week, set ticks interval to days
} else if (num * interval > 3 * 24 * 60 * 60) {
// If the requested data is more than 3 days (72 hours), set ticks interval to days
timeLineChart.options.scales.xAxes[0].time.unit = "day";
}
@@ -152,6 +160,9 @@ $(function () {
var ctx = document.getElementById("queryOverTimeChart").getContext("2d");
var blockedColor = "#999";
var permittedColor = "#00a65a";
var gridColor = $(".graphs-grid").css("background-color");
var ticksColor = $(".graphs-ticks").css("color");
timeLineChart = new Chart(ctx, {
type: utils.getGraphType(),
data: {
@@ -286,10 +297,17 @@ $(function () {
day: "MMM DD",
week: "MMM DD",
month: "MMM",
quarter: "MMM",
year: "YYYY MMM",
quarter: "YYYY MMM",
year: "YYYY",
},
},
gridLines: {
color: gridColor,
zeroLineColor: gridColor,
},
ticks: {
fontColor: ticksColor,
},
},
],
yAxes: [
@@ -297,6 +315,10 @@ $(function () {
stacked: true,
ticks: {
beginAtZero: true,
fontColor: ticksColor,
},
gridLines: {
color: gridColor,
},
},
],
+5 -5
View File
@@ -7,7 +7,7 @@
/* global utils:false, moment:false */
var start__ = moment().subtract(6, "days");
var start__ = moment().subtract(7, "days");
var from = moment(start__).utc().valueOf() / 1000;
var end__ = moment();
var until = moment(end__).utc().valueOf() / 1000;
@@ -32,8 +32,8 @@ $(function () {
moment().subtract(1, "days").startOf("day"),
moment().subtract(1, "days").endOf("day"),
],
"Last 7 Days": [moment().subtract(6, "days"), moment()],
"Last 30 Days": [moment().subtract(29, "days"), moment()],
"Last 7 Days": [moment().subtract(7, "days"), moment()],
"Last 30 Days": [moment().subtract(30, "days"), moment()],
"This Month": [moment().startOf("month"), moment()],
"Last Month": [
moment().subtract(1, "month").startOf("month"),
@@ -140,7 +140,7 @@ function updateTopDomainsChart() {
percentage.toFixed(1) +
"% of " +
sum +
'"> <div class="progress-bar queries-blocked" style="width: ' +
'"> <div class="progress-bar queries-permitted" style="width: ' +
percentage +
'%"></div> </div> </td> </tr> '
);
@@ -187,7 +187,7 @@ function updateTopAdsChart() {
percentage.toFixed(1) +
"% of " +
sum +
'"> <div class="progress-bar queries-permitted" style="width: ' +
'"> <div class="progress-bar queries-blocked" style="width: ' +
percentage +
'%"></div> </div> </td> </tr> '
);
+23 -5
View File
@@ -7,7 +7,7 @@
/* global moment:false, utils:false */
var start__ = moment().subtract(6, "days");
var start__ = moment().subtract(7, "days");
var from = moment(start__).utc().valueOf() / 1000;
var end__ = moment();
var until = moment(end__).utc().valueOf() / 1000;
@@ -15,6 +15,8 @@ var instantquery = false;
var daterange;
var timeoutWarning = $("#timeoutWarning");
var reloadBox = $(".reload-box");
var datepickerManuallySelected = false;
var dateformat = "MMMM Do YYYY, HH:mm";
@@ -50,8 +52,8 @@ $(function () {
moment().subtract(1, "days").startOf("day"),
moment().subtract(1, "days").endOf("day"),
],
"Last 7 Days": [moment().subtract(6, "days"), moment()],
"Last 30 Days": [moment().subtract(29, "days"), moment()],
"Last 7 Days": [moment().subtract(7, "days"), moment()],
"Last 30 Days": [moment().subtract(30, "days"), moment()],
"This Month": [moment().startOf("month"), moment()],
"Last Month": [
moment().subtract(1, "month").startOf("month"),
@@ -175,6 +177,7 @@ var reloadCallback = function () {
function refreshTableData() {
timeoutWarning.show();
reloadBox.hide();
var APIstring = "api_db.php?getAllQueries&from=" + from + "&until=" + until;
// Check if query type filtering is enabled
var queryType = getQueryTypes();
@@ -340,8 +343,8 @@ $(function () {
},
},
{ width: "10%" },
{ width: "40%", render: $.fn.dataTable.render.text() },
{ width: "20%", type: "ip-address", render: $.fn.dataTable.render.text() },
{ width: "40%" },
{ width: "20%", type: "ip-address" },
{ width: "10%" },
{ width: "5%" },
],
@@ -355,6 +358,10 @@ $(function () {
data: null,
defaultContent: "",
},
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
initComplete: reloadCallback,
});
@@ -374,5 +381,16 @@ $(function () {
$("#querytime").on("apply.daterangepicker", function (ev, picker) {
$(this).val(picker.startDate.format(dateformat) + " to " + picker.endDate.format(dateformat));
datepickerManuallySelected = true;
refreshTableData();
});
$("input[id^=type]").change(function () {
if (datepickerManuallySelected) {
reloadBox.show();
}
});
$(".bt-reload").click(function () {
refreshTableData();
});
+6 -2
View File
@@ -137,8 +137,12 @@ function initCheckboxRadioStyle() {
function applyCheckboxRadioStyle(style) {
boxsheet.attr("href", getCheckboxURL(style));
// Get all radio/checkboxes for theming, with the exception of the two radio buttons on the custom disable timer
var sel = $("input[type='radio'],input[type='checkbox']").not("#selSec").not("#selMin");
// Get all radio/checkboxes for theming, with the exception of the two radio buttons on the custom disable timer,
// as well as every element with an id that starts with "status_"
var sel = $("input[type='radio'],input[type='checkbox']")
.not("#selSec")
.not("#selMin")
.not("[id^=status_]");
sel.parent().removeClass();
sel.parent().addClass("icheck-" + style);
}
+11
View File
@@ -124,6 +124,16 @@ function initTable() {
{ data: "groups", searchable: false },
{ data: null, width: "80px", orderable: false },
],
columnDefs: [
{
targets: [0, 2],
orderable: false,
},
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
drawCallback: function () {
$('button[id^="deleteAdlist_"]').on("click", deleteAdlist);
// Remove visible dropdown to prevent orphaning
@@ -289,6 +299,7 @@ function initTable() {
[10, 25, 50, 100, "All"],
],
stateSave: true,
stateDuration: 0,
stateSaveCallback: function (settings, data) {
utils.stateSaveCallback("groups-adlists-table", data);
},
+7
View File
@@ -97,6 +97,12 @@ function initTable() {
{ data: "groups", searchable: false },
{ data: "name", width: "80px", orderable: false },
],
columnDefs: [
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
drawCallback: function () {
$('button[id^="deleteClient_"]').on("click", deleteClient);
// Remove visible dropdown to prevent orphaning
@@ -217,6 +223,7 @@ function initTable() {
[10, 25, 50, 100, "All"],
],
stateSave: true,
stateDuration: 0,
stateSaveCallback: function (settings, data) {
utils.stateSaveCallback("groups-clients-table", data);
},
+7
View File
@@ -76,6 +76,12 @@ function initTable() {
{ data: "groups", searchable: false, visible: showtype === "all" },
{ data: null, width: "80px", orderable: false },
],
columnDefs: [
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
drawCallback: function () {
$('button[id^="deleteDomain_"]').on("click", deleteDomain);
// Remove visible dropdown to prevent orphaning
@@ -246,6 +252,7 @@ function initTable() {
[10, 25, 50, 100, "All"],
],
stateSave: true,
stateDuration: 0,
stateSaveCallback: function (settings, data) {
utils.stateSaveCallback("groups-domains-table", data);
},
+7
View File
@@ -27,6 +27,12 @@ $(function () {
{ data: "description" },
{ data: null, width: "60px", orderable: false },
],
columnDefs: [
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
drawCallback: function () {
$('button[id^="deleteGroup_"]').on("click", deleteGroup);
},
@@ -86,6 +92,7 @@ $(function () {
[10, 25, 50, 100, "All"],
],
stateSave: true,
stateDuration: 0,
stateSaveCallback: function (settings, data) {
utils.stateSaveCallback("groups-table", data);
},
+2
View File
@@ -919,6 +919,7 @@ $(function () {
},
gridLines: {
color: gridColor,
zeroLineColor: gridColor,
},
ticks: {
fontColor: ticksColor,
@@ -997,6 +998,7 @@ $(function () {
},
gridLines: {
color: gridColor,
zeroLineColor: gridColor,
},
ticks: {
fontColor: ticksColor,
+41
View File
@@ -88,6 +88,40 @@ function renderMessage(data, type, row) {
" seconds)"
);
case "DNSMASQ_WARN":
return "Warning in <code>dnsmasq</code> core:<pre>" + row.message + "</pre>";
case "LOAD":
return (
"Long-term load (15min avg) larger than number of processors: <strong>" +
parseFloat(row.blob1).toFixed(1) +
" &gt; " +
parseInt(row.blob2, 10) +
"</strong><br>This may slow down DNS resolution and can cause bottlenecks."
);
case "SHMEM":
return (
"RAM shortage (<code>" +
utils.escapeHtml(row.message) +
"</code>) ahead: <strong>" +
parseInt(row.blob1, 10) +
"% used</strong><pre>" +
utils.escapeHtml(row.blob2) +
"</pre>"
);
case "DISK":
return (
"Disk shortage (<code>" +
utils.escapeHtml(row.message) +
"</code>) ahead: <strong>" +
parseInt(row.blob1, 10) +
"% used</strong><pre>" +
utils.escapeHtml(row.blob2) +
"</pre>"
);
default:
return "Unknown message type<pre>" + JSON.stringify(row) + "</pre>";
}
@@ -114,6 +148,12 @@ $(function () {
{ data: "blob5", visible: false },
{ data: null, width: "80px", orderable: false },
],
columnDefs: [
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
drawCallback: function () {
$('button[id^="deleteMessage_"]').on("click", deleteMessage);
// Remove visible dropdown to prevent orphaning
@@ -141,6 +181,7 @@ $(function () {
emptyTable: "No issues found.",
},
stateSave: true,
stateDuration: 0,
stateSaveCallback: function (settings, data) {
utils.stateSaveCallback("messages-table", data);
},
+10 -4
View File
@@ -236,10 +236,10 @@ $(function () {
order: [[6, "desc"]],
columns: [
{ data: "id", visible: false },
{ data: "ip", type: "ip-address", width: "10%", render: $.fn.dataTable.render.text() },
{ data: "hwaddr", width: "10%", render: $.fn.dataTable.render.text() },
{ data: "interface", width: "4%", render: $.fn.dataTable.render.text() },
{ data: "name", width: "15%", render: $.fn.dataTable.render.text() },
{ data: "ip", type: "ip-address", width: "10%" },
{ data: "hwaddr", width: "10%" },
{ data: "interface", width: "4%" },
{ data: "name", width: "15%" },
{
data: "firstSeen",
width: "8%",
@@ -266,6 +266,7 @@ $(function () {
{ data: "", width: "6%", orderable: false },
{ data: "", width: "6%", orderable: false },
],
drawCallback: function () {
$('button[id^="deleteNetworkEntry_"]').on("click", deleteNetworkEntry);
// Remove visible dropdown to prevent orphaning
@@ -276,6 +277,7 @@ $(function () {
[10, 25, 50, 100, "All"],
],
stateSave: true,
stateDuration: 0,
stateSaveCallback: function (settings, data) {
utils.stateSaveCallback("network_table", data);
},
@@ -288,6 +290,10 @@ $(function () {
data: null,
defaultContent: "",
},
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
});
// Disable autocorrect in the search box
+8 -3
View File
@@ -183,7 +183,7 @@ $(function () {
case "10":
fieldtext =
"<span class='text-red'>Blocked <br class='hidden-lg'>(regex blacklist, CNAME)</span>";
blocked = true;
if (data.length > 9 && data[9] > 0) {
regexLink = true;
}
@@ -323,8 +323,8 @@ $(function () {
},
},
{ width: "4%" },
{ width: "36%", render: $.fn.dataTable.render.text() },
{ width: "8%", type: "ip-address", render: $.fn.dataTable.render.text() },
{ width: "36%" },
{ width: "8%", type: "ip-address" },
{ width: "14%", orderData: 4 },
{ width: "8%", orderData: 5 },
{ width: "10%", orderData: 4 },
@@ -334,6 +334,7 @@ $(function () {
[10, 25, 50, 100, "All"],
],
stateSave: true,
stateDuration: 0,
stateSaveCallback: function (settings, data) {
utils.stateSaveCallback("query_log_table", data);
},
@@ -346,6 +347,10 @@ $(function () {
data: null,
defaultContent: "",
},
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
initComplete: function () {
var api = this.api();
+1 -1
View File
@@ -88,7 +88,7 @@ function eventsource() {
}
// Handle enter key
$("#domain_1, #domain_2").keypress(function (e) {
$("#domain").keypress(function (e) {
if (e.which === 13) {
// Enter was pressed, and the input has focus
exact = "";
+15 -2
View File
@@ -216,13 +216,20 @@ $(function () {
if (document.getElementById("DHCPLeasesTable")) {
leasetable = $("#DHCPLeasesTable").DataTable({
dom: "<'row'<'col-sm-12'tr>><'row'<'col-sm-6'i><'col-sm-6'f>>",
columnDefs: [{ bSortable: false, orderable: false, targets: -1 }],
columnDefs: [
{ bSortable: false, orderable: false, targets: -1 },
{
targets: [0, 1, 2],
render: $.fn.dataTable.render.text(),
},
],
paging: false,
scrollCollapse: true,
scrollY: "200px",
scrollX: true,
order: [[2, "asc"]],
stateSave: true,
stateDuration: 0,
stateSaveCallback: function (settings, data) {
utils.stateSaveCallback("activeDhcpLeaseTable", data);
},
@@ -235,7 +242,13 @@ $(function () {
if (document.getElementById("DHCPStaticLeasesTable")) {
staticleasetable = $("#DHCPStaticLeasesTable").DataTable({
dom: "<'row'<'col-sm-12'tr>><'row'<'col-sm-12'i>>",
columnDefs: [{ bSortable: false, orderable: false, targets: -1 }],
columnDefs: [
{ bSortable: false, orderable: false, targets: -1 },
{
targets: [0, 1, 2],
render: $.fn.dataTable.render.text(),
},
],
paging: false,
scrollCollapse: true,
scrollY: "200px",
+5 -1
View File
@@ -187,6 +187,10 @@
<meta name="theme-color" content="#272c30">
<?php } elseif ($theme == "default-darker") { ?>
<meta name="theme-color" content="#2e6786">
<?php } elseif ($theme == "lcars") { ?>
<meta name="theme-color" content="#4488FF">
<link rel="stylesheet" href="style/vendor/fonts/ubuntu-mono/ubuntu-mono.css?v=<?=$cacheVer?>">
<link rel="stylesheet" href="style/vendor/fonts/antonio/antonio.css?v=<?=$cacheVer?>">
<?php } ?>
<?php if ($darkmode) { ?>
@@ -259,7 +263,7 @@ if($auth) {
<ul class="nav navbar-nav">
<li id="pihole-diagnosis" class="hidden">
<a href="messages.php">
<i class="fa fa-exclamation-triangle"></i>
<i class="fa fa-exclamation-triangle fa-2x icon-bounce"></i>
<span class="label label-warning" id="pihole-diagnosis-count"></span>
</a>
</li>
+15 -31
View File
@@ -209,10 +209,19 @@ function addStaticDHCPLease($mac, $ip, $hostname) {
{
foreach(["v4_1", "v4_2", "v6_1", "v6_2"] as $type)
{
if(@array_key_exists("DNSserver".str_replace(".","_",$value[$type]),$_POST))
{
array_push($DNSservers,$value[$type]);
}
// Skip if this IP type does not
// exist (e.g. IPv4-only or only
// one IPv6 address upstream
// server)
if(!array_key_exists($type, $value))
continue;
// If server exists and is set
// (POST), we add it to the
// array of DNS servers
$server = str_replace(".", "_", $value[$type]);
if(array_key_exists("DNSserver".$server, $_POST))
array_push($DNSservers, $value[$type]);
}
}
@@ -439,26 +448,12 @@ function addStaticDHCPLease($mac, $ip, $hostname) {
if(isset($_POST["querylog-permitted"]) && isset($_POST["querylog-blocked"]))
{
pihole_execute("-a setquerylog all");
if(!isset($_POST["privacyMode"]))
{
$success .= "All entries will be shown in Query Log";
}
else
{
$success .= "Only blocked entries will be shown in Query Log";
}
$success .= "All entries will be shown in Query Log";
}
elseif(isset($_POST["querylog-permitted"]))
{
pihole_execute("-a setquerylog permittedonly");
if(!isset($_POST["privacyMode"]))
{
$success .= "Only permitted will be shown in Query Log";
}
else
{
$success .= "No entries will be shown in Query Log";
}
$success .= "Only permitted will be shown in Query Log";
}
elseif(isset($_POST["querylog-blocked"]))
{
@@ -471,17 +466,6 @@ function addStaticDHCPLease($mac, $ip, $hostname) {
$success .= "No entries will be shown in Query Log";
}
if(isset($_POST["privacyMode"]))
{
pihole_execute("-a privacymode true");
$success .= " (privacy mode enabled)";
}
else
{
pihole_execute("-a privacymode false");
}
break;
case "webUI":
+2
View File
@@ -18,6 +18,8 @@ $available_themes["default-dark"] = array("Pi-hole midnight theme (dark)", true,
$available_themes["default-darker"] = array("Pi-hole deep-midnight theme (dark)", true, "default-darker");
// Option to have the theme go with the device dark mode setting, always set the background to black to avoid flashing
$available_themes["default-auto"] = array("Pi-hole auto theme (light/dark)", true, "default-auto");
$available_themes["lcars"] = array("Star Trek LCARS theme (dark)", true, "lcars");
$webtheme = "";
// Try to load theme settings from setupVars.conf