diff --git a/scripts/pi-hole/js/charts.js b/scripts/pi-hole/js/charts.js index f7fc2282..583896a3 100644 --- a/scripts/pi-hole/js/charts.js +++ b/scripts/pi-hole/js/charts.js @@ -5,6 +5,8 @@ * This file is copyright under the latest version of the EUPL. * Please see LICENSE file for your rights under this license. */ +/* global upstreams */ + // eslint-disable-next-line no-unused-vars var THEME_COLORS = [ "#f56954", @@ -97,7 +99,8 @@ const htmlLegendPlugin = { window.location.href = "queries.lp?type=" + item.text; } else if (chart.canvas.id === "forwardDestinationPieChart") { // Encode the forward destination as it may contain an "#" character - window.location.href = "queries.lp?upstream=" + encodeURIComponent(item.text); + const upstream = encodeURIComponent(upstreams[item.text]); + window.location.href = "queries.lp?upstream=" + upstream; } }); } diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index af0d756d..d70fe881 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -200,6 +200,7 @@ function updateClientsOverTime() { }); } +var upstreams = {}; function updateForwardDestinationsPie() { $.getJSON("/api/stats/upstreams", function (data) { var v = [], @@ -221,6 +222,12 @@ function updateForwardDestinationsPie() { label += "#" + item.port; } + // Store upstreams for generating links to the Query Log + upstreams[label] = item.ip; + if (item.port > 0) { + upstreams[label] += "#" + item.port; + } + var percent = (100 * item.count) / sum; values.push([label, percent, THEME_COLORS[i++ % THEME_COLORS.length]]); });