Skip to content

Commit

Permalink
Merge branch 'devel' into tweak/exact_searching
Browse files Browse the repository at this point in the history
  • Loading branch information
DL6ER authored Jun 14, 2020
2 parents f4fe04d + 557bd85 commit 1819abe
Show file tree
Hide file tree
Showing 22 changed files with 1,214 additions and 1,121 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ While we are primarily reachable on our <a href="https://discourse.pi-hole.net/"
<img src="https://pi-hole.github.io/graphics/Screenshots/audit-log.png" alt="Pi-hole Web interface">
</p>

## Long Term Statistics to view data over user defined time ranges
## Long-term statistics to view data over user defined time ranges

<p align="center">
<img src="https://pi-hole.github.io/graphics/Screenshots/long-term-stats.png" alt="Long-term stats">
Expand Down
2,008 changes: 1,049 additions & 959 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"eslint-plugin-compat": "^3.7.0",
"postcss-cli": "^7.1.1",
"prettier": "2.0.4",
"xo": "^0.30.0"
"xo": "^0.32.0"
},
"browserslist": [
"defaults",
Expand Down Expand Up @@ -79,7 +79,6 @@
"no-console": "error",
"no-negated-condition": "off",
"one-var": "off",
"radix": "off",
"spaced-comment": "off",
"unicorn/explicit-length-check": [
"error",
Expand Down
10 changes: 6 additions & 4 deletions scripts/pi-hole/js/auditlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,20 @@ $(function () {
// Pull in data via AJAX
updateTopLists();

$("#domain-frequency tbody").on("click", "button", function () {
$("#domain-frequency tbody").on("click", "button", function (event) {
var url = $(this).parents("tr")[0].textContent.split(" ")[0];
if ($(this).context.textContent === " Blacklist") {

if (event.target.textContent.trim() === "Blacklist") {
blacklistUrl(url);
} else {
auditUrl(url);
}
});

$("#ad-frequency tbody").on("click", "button", function () {
$("#ad-frequency tbody").on("click", "button", function (event) {
var url = $(this).parents("tr")[0].textContent.split(" ")[0];
if ($(this).context.textContent === " Whitelist") {

if (event.target.textContent.trim() === "Whitelist") {
whitelistUrl(url);
} else {
auditUrl(url);
Expand Down
10 changes: 5 additions & 5 deletions scripts/pi-hole/js/db_graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ function updateQueriesOverTime() {

for (hour in data.domains_over_time[0]) {
if (Object.prototype.hasOwnProperty.call(data.domains_over_time[0], hour)) {
dates.push(parseInt(data.domains_over_time[0][hour]));
dates.push(parseInt(data.domains_over_time[0][hour], 10));
}
}

for (hour in data.ads_over_time[0]) {
if (Object.prototype.hasOwnProperty.call(data.ads_over_time[0], hour)) {
if (dates.indexOf(parseInt(data.ads_over_time[0][hour])) === -1) {
dates.push(parseInt(data.ads_over_time[0][hour]));
if (dates.indexOf(parseInt(data.ads_over_time[0][hour], 10)) === -1) {
dates.push(parseInt(data.ads_over_time[0][hour], 10));
}
}
}
Expand Down Expand Up @@ -248,8 +248,8 @@ $(function () {
label: function (tooltipItems, data) {
if (tooltipItems.datasetIndex === 0) {
var percentage = 0;
var permitted = parseInt(data.datasets[1].data[tooltipItems.index]);
var blocked = parseInt(data.datasets[0].data[tooltipItems.index]);
var permitted = parseInt(data.datasets[1].data[tooltipItems.index], 10);
var blocked = parseInt(data.datasets[0].data[tooltipItems.index], 10);
if (permitted + blocked > 0) {
percentage = (100 * blocked) / (permitted + blocked);
}
Expand Down
10 changes: 7 additions & 3 deletions scripts/pi-hole/js/db_queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ window.location.search
});

if ("from" in GETDict && "until" in GETDict) {
from = parseInt(GETDict.from);
until = parseInt(GETDict.until);
from = parseInt(GETDict.from, 10);
until = parseInt(GETDict.until, 10);
start__ = moment(1000 * from);
end__ = moment(1000 * until);
instantquery = true;
Expand Down Expand Up @@ -142,7 +142,11 @@ function handleAjaxError(xhr, textStatus) {
} else if (xhr.responseText.indexOf("Connection refused") !== -1) {
alert("An error occurred while loading the data: Connection refused. Is FTL running?");
} else {
alert("An unknown error occurred while loading the data.\n" + xhr.responseText);
alert(
"An unknown error occurred while loading the data.\n" +
xhr.responseText +
"\nCheck the server's log files (/var/log/lighttpd/error.log when you're using the default Pi-hole web server) for details. You may need to increase the memory available for Pi-hole in case you requested a lot of data."
);
}

$("#all-queries_processing").hide();
Expand Down
6 changes: 3 additions & 3 deletions scripts/pi-hole/js/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function piholeChanged(action) {
function countDown() {
var ena = $("#enableLabel");
var enaT = $("#enableTimer");
var target = new Date(parseInt(enaT.html()));
var target = new Date(parseInt(enaT.html(), 10));
var seconds = Math.round((target.getTime() - new Date().getTime()) / 1000);

if (seconds > 0) {
Expand Down Expand Up @@ -207,7 +207,7 @@ function initCPUtemp() {

$(function () {
var enaT = $("#enableTimer");
var target = new Date(parseInt(enaT.html()));
var target = new Date(parseInt(enaT.html(), 10));
var seconds = Math.round((target.getTime() - new Date().getTime()) / 1000);
if (seconds > 0) {
setTimeout(countDown, 100);
Expand Down Expand Up @@ -262,7 +262,7 @@ $("#pihole-disable-custom").on("click", function (e) {

// Session timer
var sessionTimerCounter = document.getElementById("sessiontimercounter");
var sessionvalidity = parseInt(sessionTimerCounter.textContent);
var sessionvalidity = parseInt(sessionTimerCounter.textContent, 10);
var start = new Date();

function updateSessionTimer() {
Expand Down
9 changes: 6 additions & 3 deletions scripts/pi-hole/js/groups-domains.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ function initTable() {
var applyBtn = "#btn_apply_" + data.id;

// Highlight row (if url parameter "domainid=" is used)
if ("domainid" in GETDict && data.id === parseInt(GETDict.domainid)) {
if ("domainid" in GETDict && data.id === parseInt(GETDict.domainid, 10)) {
$(row).find("td").addClass("highlight");
}

Expand Down Expand Up @@ -265,7 +265,10 @@ function initTable() {
},
initComplete: function () {
if ("domainid" in GETDict) {
var pos = table.column(0, { order: "current" }).data().indexOf(parseInt(GETDict.domainid));
var pos = table
.column(0, { order: "current" })
.data()
.indexOf(parseInt(GETDict.domainid, 10));
if (pos >= 0) {
var page = Math.floor(pos / table.page.info().length);
table.page(page).draw(false);
Expand Down Expand Up @@ -361,7 +364,7 @@ function addDomain() {
success: function (response) {
utils.enableAll();
if (response.success) {
utils.showAlert("success", "fas fa-plus", "Successfully added " + domainRegex, domain);
utils.showAlert("success", "fas fa-plus", "Success!", response.message);
domainEl.val("");
commentEl.val("");
wildcardEl.prop("checked", false);
Expand Down
81 changes: 34 additions & 47 deletions scripts/pi-hole/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,33 @@ function updateQueriesOverTime() {
data.ads_over_time[0].splice(-1, 1);
// Remove possibly already existing data
timeLineChart.data.labels = [];
timeLineChart.data.datasets[0].data = [];
timeLineChart.data.datasets[1].data = [];
timeLineChart.data.datasets = [];

var labels = ["Blocked DNS Queries", "Permitted DNS Queries"];
var blockedColor = $(".queries-blocked").css("background-color");
var permittedColor = $(".queries-permitted").css("background-color");
var colors = [blockedColor, permittedColor];

// Collect values and colors, and labels
for (var i = 0; i < labels.length; i++) {
timeLineChart.data.datasets.push({
data: [],
// If we ran out of colors, make a random one
backgroundColor: colors[i],
pointRadius: 0,
pointHitRadius: 5,
pointHoverRadius: 5,
label: labels[i],
cubicInterpolationMode: "monotone"
});
}

// Add data for each hour that is available
for (var hour in data.ads_over_time[0]) {
if (Object.prototype.hasOwnProperty.call(data.ads_over_time[0], hour)) {
var d, h;
h = parseInt(data.domains_over_time[0][hour]);
if (parseInt(data.ads_over_time[0][0]) < 1200) {
h = parseInt(data.domains_over_time[0][hour], 10);
if (parseInt(data.ads_over_time[0][0], 10) < 1200) {
// Fallback - old style
d = new Date().setHours(Math.floor(h / 6), 10 * (h % 6), 0, 0);
} else {
Expand Down Expand Up @@ -299,7 +317,6 @@ function updateQueryTypesPie() {
queryTypePieChart.data.datasets[0] = dd;
queryTypePieChart.data.labels = k;
$("#query-types-pie .overlay").hide();
queryTypePieChart.update();
queryTypePieChart.chart.config.options.cutoutPercentage = 50;
queryTypePieChart.update();
// Don't use rotation animation for further updates
Expand Down Expand Up @@ -352,7 +369,7 @@ function updateClientsOverTime() {
var timestamps = data.over_time[0];
var plotdata = data.over_time[1];
var labels = [];
var key, i, j;
var key;

for (key in data.clients) {
if (Object.prototype.hasOwnProperty.call(data.clients, key)) {
Expand All @@ -363,19 +380,15 @@ function updateClientsOverTime() {

// Remove possibly already existing data
clientsChart.data.labels = [];
clientsChart.data.datasets[0].data = [];
for (i = 1; i < clientsChart.data.datasets.length; i++) {
clientsChart.data.datasets[i].data = [];
}
clientsChart.data.datasets = [];

// Collect values and colors, and labels
clientsChart.data.datasets[0].backgroundColor = THEME_COLORS[0];
clientsChart.data.datasets[0].pointRadius = 0;
clientsChart.data.datasets[0].pointHitRadius = 5;
clientsChart.data.datasets[0].pointHoverRadius = 5;
clientsChart.data.datasets[0].label = labels[0];
var numClients = 0;
if (plotdata.length > 0) {
numClients = plotdata[0].length;
}

for (i = clientsChart.data.datasets.length; plotdata.length && i < plotdata[0].length; i++) {
for (var i = 0; i < numClients; i++) {
clientsChart.data.datasets.push({
data: [],
// If we ran out of colors, make a random one
Expand All @@ -392,7 +405,7 @@ function updateClientsOverTime() {
}

// Add data for each dataset that is available
for (j in timestamps) {
for (var j in timestamps) {
if (!Object.prototype.hasOwnProperty.call(timestamps, j)) {
continue;
}
Expand All @@ -403,7 +416,7 @@ function updateClientsOverTime() {
}
}

var d = new Date(1000 * parseInt(timestamps[j]));
var d = new Date(1000 * parseInt(timestamps[j], 10));
clientsChart.data.labels.push(d);
}

Expand Down Expand Up @@ -462,7 +475,6 @@ function updateForwardDestinationsPie() {
forwardDestinationPieChart.data.datasets[0] = dd;
// and push it at once
$("#forward-destinations-pie .overlay").hide();
forwardDestinationPieChart.update();
forwardDestinationPieChart.chart.config.options.cutoutPercentage = 50;
forwardDestinationPieChart.update();
// Don't use rotation animation for further updates
Expand Down Expand Up @@ -779,39 +791,14 @@ $(function () {
// Pull in data via AJAX
updateSummaryData();

var blockedColor = $(".queries-blocked").css("background-color");
var permittedColor = $(".queries-permitted").css("background-color");
var gridColor = $(".graphs-grid").css("background-color");
var ticksColor = $(".graphs-ticks").css("color");
var ctx = document.getElementById("queryOverTimeChart").getContext("2d");
timeLineChart = new Chart(ctx, {
type: utils.getGraphType(),
data: {
labels: [],
datasets: [
{
label: "Blocked DNS Queries",
fill: true,
backgroundColor: blockedColor,
borderColor: blockedColor,
pointBorderColor: blockedColor,
pointRadius: 1,
pointHoverRadius: 5,
data: [],
pointHitRadius: 5
},
{
label: "Permitted DNS Queries",
fill: true,
backgroundColor: permittedColor,
borderColor: permittedColor,
pointBorderColor: permittedColor,
pointRadius: 1,
pointHoverRadius: 5,
data: [],
pointHitRadius: 5
}
]
datasets: [{ data: [] }]
},
options: {
tooltips: {
Expand All @@ -833,8 +820,8 @@ $(function () {
label: function (tooltipItems, data) {
if (tooltipItems.datasetIndex === 0) {
var percentage = 0;
var permitted = parseInt(data.datasets[1].data[tooltipItems.index]);
var blocked = parseInt(data.datasets[0].data[tooltipItems.index]);
var permitted = parseInt(data.datasets[1].data[tooltipItems.index], 10);
var blocked = parseInt(data.datasets[0].data[tooltipItems.index], 10);
var total = permitted + blocked;
if (total > 0) {
percentage = (100 * blocked) / total;
Expand Down
16 changes: 16 additions & 0 deletions scripts/pi-hole/js/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@ function renderMessage(data, type, row) {
"</pre> to get the group configuration for this client."
);

case "HOSTNAME":
var hint = new Array(row.blob2 + row.message.length + 3).join(" ");
return (
"Hostname contains invalid character <code>" +
decodeURIComponent(escape(row.blob1))[row.blob2] +
"</code>:<pre>" +
hint +
"&darr;\n" +
row.message +
": " +
decodeURIComponent(escape(row.blob1)) +
"\n" +
hint +
"&uarr;</pre>"
);

default:
return "Unknown message type<pre>" + JSON.stringify(row) + "</pre>";
}
Expand Down
8 changes: 4 additions & 4 deletions scripts/pi-hole/js/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */

/* global moment:false, utils:false */
/* global utils:false */

var tableApi;

Expand Down Expand Up @@ -70,7 +70,7 @@ $(function () {
rowCallback: function (row, data) {
var color;
var iconClasses;
var lastQuery = parseInt(data.lastQuery);
var lastQuery = parseInt(data.lastQuery, 10);
var diff = getTimestamp() - lastQuery;
var networkRecent = $(".network-recent").css("background-color");
var networkOld = $(".network-old").css("background-color");
Expand Down Expand Up @@ -161,7 +161,7 @@ $(function () {
width: "8%",
render: function (data, type) {
if (type === "display") {
return moment.unix(data).format("Y-MM-DD [<br class='hidden-lg'>]HH:mm:ss z");
return utils.datetime(data);
}

return data;
Expand All @@ -172,7 +172,7 @@ $(function () {
width: "8%",
render: function (data, type) {
if (type === "display") {
return moment.unix(data).format("Y-MM-DD [<br class='hidden-lg'>]HH:mm:ss z");
return utils.datetime(data);
}

return data;
Expand Down
3 changes: 2 additions & 1 deletion scripts/pi-hole/js/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ $(function () {
isCNAME = true;
break;
default:
fieldtext = "Unknown (" + data[4] + ")";
colorClass = false;
fieldtext = "Unknown (" + parseInt(data[4], 10) + ")";
buttontext = "";
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/pi-hole/js/queryads.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ $("#btnSearchExact").on("click", function () {

// Wrap form-group's buttons to next line when viewed on a small screen
$(window).on("resize", function () {
if ($(window).width() < 991) {
if ($(window).width() < 992) {
$(".form-group.input-group").removeClass("input-group").addClass("input-group-block");
$(".form-group.input-group-block > input").css("margin-bottom", "5px");
$(".form-group.input-group-block > .input-group-btn")
Expand Down
Loading

0 comments on commit 1819abe

Please sign in to comment.