Fix upstream links yielding no results on the Query Log if names are shown

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2023-11-16 12:53:08 +01:00
parent 35ab1fd4a0
commit feea661daf
2 changed files with 11 additions and 1 deletions
+4 -1
View File
@@ -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;
}
});
}
+7
View File
@@ -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]]);
});