diff --git a/scripts/pi-hole/js/charts.js b/scripts/pi-hole/js/charts.js index 0c7cc257..88b547cb 100644 --- a/scripts/pi-hole/js/charts.js +++ b/scripts/pi-hole/js/charts.js @@ -5,8 +5,6 @@ * This file is copyright under the latest version of the EUPL. * Please see LICENSE file for your rights under this license. */ -/* global querytypeids:false */ - // eslint-disable-next-line no-unused-vars var THEME_COLORS = [ "#f56954", @@ -81,7 +79,7 @@ const htmlLegendPlugin = { textLink.addEventListener("click", () => { if (chart.canvas.id === "queryTypePieChart") { - window.location.href = "queries.lp?querytype=" + querytypeids[item.index]; + window.location.href = "queries.lp?type=" + item.text; } else if (chart.canvas.id === "forwardDestinationPieChart") { window.location.href = "queries.lp?forwarddest=" + encodeURIComponent(item.text); } diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 57a0d63a..babaf6f0 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -74,7 +74,6 @@ function updateQueriesOverTime() { }); } -var querytypeids = []; function updateQueryTypesPie() { $.getJSON("/api/stats/query_types", function (data) { var v = [], @@ -89,13 +88,11 @@ function updateQueryTypesPie() { }); // Fill chart with data (only include query types which appeared recently) - querytypeids = []; Object.keys(data.types).forEach(function (item) { if (data.types[item] > 0) { v.push((100 * data.types[item]) / sum); c.push(THEME_COLORS[i % THEME_COLORS.length]); k.push(item); - querytypeids.push(i + 1); } i++; diff --git a/scripts/pi-hole/js/queries.js b/scripts/pi-hole/js/queries.js index b4a33928..4ccf5748 100644 --- a/scripts/pi-hole/js/queries.js +++ b/scripts/pi-hole/js/queries.js @@ -27,7 +27,7 @@ var filters = [ "dnssec", ]; -function init_datepicker() { +function initDateRangePicker() { $("#querytime").daterangepicker( { timePicker: true, @@ -423,8 +423,7 @@ function parseFilters() { function filterOn(param, dict) { const typ = typeof dict[param]; - console.log([param, dict, typ]); - return param in dict && (typ === "number" || typ === "string" && dict[param].length > 0); + return param in dict && (typ === "number" || (typ === "string" && dict[param].length > 0)); } function getAPIURL(filters) { @@ -432,17 +431,13 @@ function getAPIURL(filters) { for (var key in filters) { if (Object.hasOwnProperty.call(filters, key)) { var filter = filters[key]; - if (filterOn(key, filters)) - { - if(!apiurl.endsWith("?")) apiurl += "&"; + if (filterOn(key, filters)) { + if (!apiurl.endsWith("?")) apiurl += "&"; apiurl += key + "=" + filter; } } } - console.log(filters); - console.log(apiurl); - // Omit from/until filtering if we cannot reach these times. This will speed // up the database lookups notably on slow devices. if (from > beginningOfTime) apiurl += "&from=" + from; @@ -478,15 +473,17 @@ $(function () { getSuggestions(GETDict); var apiurl = getAPIURL(GETDict); - if("from" in GETDict) { - from = GETDict["from"]; + if ("from" in GETDict) { + from = GETDict.from; $("#from").val(moment.unix(from).format("Y-MM-DD HH:mm:ss")); } - if("until" in GETDict) { - until = GETDict["until"]; + + if ("until" in GETDict) { + until = GETDict.until; $("#until").val(moment.unix(until).format("Y-MM-DD HH:mm:ss")); } - init_datepicker(); + + initDateRangePicker(); table = $("#all-queries").DataTable({ ajax: { @@ -617,8 +614,8 @@ function refreshTable() { // Source data from API var filters = parseFilters(); - filters["from"] = from; - filters["until"] = until; + filters.from = from; + filters.until = until; var apiurl = getAPIURL(filters); table.ajax.url(apiurl).draw(); }