mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Be able to call queries.js with preset filters from the main page
This commit is contained in:
+14
-3
@@ -224,7 +224,8 @@ function updateTopClientsChart() {
|
||||
$.getJSON("api.php?summaryRaw&getQuerySources", function(data) {
|
||||
var clienttable = $('#client-frequency').find('tbody:last');
|
||||
for (domain in data.top_sources) {
|
||||
clienttable.append('<tr> <td>' + domain +
|
||||
var url = '<a href="queries.php?client='+domain+'">'+domain+'</a>';
|
||||
clienttable.append('<tr> <td>' + url +
|
||||
'</td> <td>' + data.top_sources[domain] + '</td> <td> <div class="progress progress-sm"> <div class="progress-bar progress-bar-blue" style="width: ' +
|
||||
data.top_sources[domain] / data.dns_queries_today * 100 + '%"></div> </div> </td> </tr> ');
|
||||
}
|
||||
@@ -260,14 +261,24 @@ function updateTopLists() {
|
||||
$.getJSON("api.php?summaryRaw&topItems", function(data) {
|
||||
var domaintable = $('#domain-frequency').find('tbody:last');
|
||||
var adtable = $('#ad-frequency').find('tbody:last');
|
||||
var url;
|
||||
|
||||
for (domain in data.top_queries) {
|
||||
domaintable.append('<tr> <td>' + domain +
|
||||
if(domain !== "pi.hole")
|
||||
{
|
||||
url = '<a href="queries.php?domain='+domain+'">'+domain+'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
url = domain;
|
||||
}
|
||||
domaintable.append('<tr> <td>' + url +
|
||||
'</td> <td>' + data.top_queries[domain] + '</td> <td> <div class="progress progress-sm"> <div class="progress-bar progress-bar-green" style="width: ' +
|
||||
data.top_queries[domain] / data.dns_queries_today * 100 + '%"></div> </div> </td> </tr> ');
|
||||
}
|
||||
for (domain in data.top_ads) {
|
||||
adtable.append('<tr> <td>' + domain +
|
||||
url = '<a href="queries.php?domain='+domain+'">'+domain+'</a>';
|
||||
adtable.append('<tr> <td>' + url +
|
||||
'</td> <td>' + data.top_ads[domain] + '</td> <td> <div class="progress progress-sm"> <div class="progress-bar progress-bar-yellow" style="width: ' +
|
||||
data.top_ads[domain] / data.ads_blocked_today * 100 + '%"></div> </div> </td> </tr> ');
|
||||
}
|
||||
|
||||
@@ -40,6 +40,33 @@ $(document).ready(function() {
|
||||
add(data[2],"black");
|
||||
}
|
||||
} );
|
||||
|
||||
// Do we want to filter queries?
|
||||
var GETDict = {}
|
||||
location.search.substr(1).split("&").forEach(function(item) {GETDict[item.split("=")[0]] = item.split("=")[1]})
|
||||
if("client" in GETDict)
|
||||
{
|
||||
if(GETDict["client"] == "localhost(127.0.0.1)")
|
||||
{
|
||||
// Have to use normal search, as regexp of DataTable is broken
|
||||
// It should be fixed in next release which might come up next
|
||||
// year. In the meantime, we work around using normal search.
|
||||
tableApi.column(3).search("localhost");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Search in third column (zero indexed)
|
||||
// Use regular expression to only show exact matches, i.e.
|
||||
// don't show 192.168.0.100 when searching for 192.168.0.1
|
||||
// true = use regex, false = don't use smart search
|
||||
tableApi.column(3).search("^"+GETDict["client"]+"$",true,false);
|
||||
}
|
||||
}
|
||||
if("domain" in GETDict)
|
||||
{
|
||||
// Search in second column (zero indexed)
|
||||
tableApi.column(2).search("^"+GETDict["domain"]+"$",true,false);
|
||||
}
|
||||
} );
|
||||
|
||||
function refreshData() {
|
||||
|
||||
Reference in New Issue
Block a user