Skip to content

Commit

Permalink
Merge pull request #346 from pi-hole/tweak/display_IPs
Browse files Browse the repository at this point in the history
Display IP addresses in Top Clients and Forward Destinations
  • Loading branch information
AzureMarker authored Jan 8, 2017
2 parents b2279ad + 1e694b3 commit 0cee148
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions scripts/pi-hole/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,25 @@ function escapeHtml(text) {
function updateTopClientsChart() {
$.getJSON("api.php?summaryRaw&getQuerySources", function(data) {
var clienttable = $("#client-frequency").find("tbody:last");
var domain, percentage, domainname;
var domain, percentage, domainname, domainip;
for (domain in data.top_sources) {

if ({}.hasOwnProperty.call(data.top_sources, domain)){
// Sanitize domain
domain = escapeHtml(domain);
if(domain.indexOf("|") > -1)
{
domainname = domain.substr(0, domain.indexOf("|"));
var idx = domain.indexOf("|");
domainname = domain.substr(0, idx);
domainip = domain.substr(idx+1, domain.length-idx);
}
else
{
domainname = domain;
domainip = domain;
}

var url = "<a href=\"queries.php?client="+domain+"\">"+domainname+"</a>";
var url = "<a href=\"queries.php?client="+domain+"\" title=\""+domainip+"\">"+domainname+"</a>";
percentage = data.top_sources[domain] / data.dns_queries_today * 100;
clienttable.append("<tr> <td>" + url +
"</td> <td>" + data.top_sources[domain] + "</td> <td> <div class=\"progress progress-sm\" title=\""+percentage.toFixed(1)+"%\"> <div class=\"progress-bar progress-bar-blue\" style=\"width: " +
Expand All @@ -172,7 +175,8 @@ function updateForwardDestinations() {
c.push(colors.shift());
if(key.indexOf("|") > -1)
{
key = key.substr(0, key.indexOf("|"));
var idx = key.indexOf("|");
key = key.substr(0, idx)+" ("+key.substr(idx+1, key.length-idx)+")";
}
forwardDestinationChart.data.labels.push(key);
});
Expand Down

0 comments on commit 0cee148

Please sign in to comment.