mirror of
https://github.com/pi-hole/web.git
synced 2025-12-20 10:48:26 +00:00
Query Log: Simplify specifying "type" via URI parameters (via types pie chart)
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user