From 6b1340cfdfcee321b07a2915de848ebc32a6bfc4 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 19 May 2020 07:54:05 +0100 Subject: [PATCH 1/3] Add staveSave property bool to DHCP tables to remember last used sort direction/column Signed-off-by: Adam Warner --- scripts/pi-hole/js/settings.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js index 132935e0..533f08d9 100644 --- a/scripts/pi-hole/js/settings.js +++ b/scripts/pi-hole/js/settings.js @@ -174,7 +174,8 @@ $(document).ready(function () { scrollCollapse: true, scrollY: "200px", scrollX: true, - order: [[2, "asc"]] + order: [[2, "asc"]], + stateSave: true }); } @@ -186,7 +187,8 @@ $(document).ready(function () { scrollCollapse: true, scrollY: "200px", scrollX: true, - order: [[2, "asc"]] + order: [[2, "asc"]], + stateSave: true }); } From eb05394b66af57684d16e4195dd274e4f19ebc38 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Fri, 22 May 2020 13:27:52 +0100 Subject: [PATCH 2/3] Add saveState/loadState callbacks Signed-off-by: Adam Warner --- scripts/pi-hole/js/settings.js | 44 ++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js index 533f08d9..2900672a 100644 --- a/scripts/pi-hole/js/settings.js +++ b/scripts/pi-hole/js/settings.js @@ -175,7 +175,27 @@ $(document).ready(function () { scrollY: "200px", scrollX: true, order: [[2, "asc"]], - stateSave: true + stateSave: true, + stateSaveCallback: function(settings, data) { + // Store current state in client's local storage area + localStorage.setItem("activeDhcpLeaseTable", JSON.stringify(data)); + }, + stateLoadCallback: function() { + // Receive previous state from client's local storage area + var data = localStorage.getItem("activeDhcpLeaseTable"); + // Return if not available + if (data === null) { + return null; + } + + data = JSON.parse(data); + // Always start on the first page to show most recent queries + data.start = 0; + // Always start with empty search field + data.search.search = ""; + // Apply loaded state to table + return data; + } }); } @@ -188,7 +208,27 @@ $(document).ready(function () { scrollY: "200px", scrollX: true, order: [[2, "asc"]], - stateSave: true + stateSave: true, + stateSaveCallback: function(settings, data) { + // Store current state in client's local storage area + localStorage.setItem("staticDhcpLeaseTable", JSON.stringify(data)); + }, + stateLoadCallback: function() { + // Receive previous state from client's local storage area + var data = localStorage.getItem("staticDhcpLeaseTable"); + // Return if not available + if (data === null) { + return null; + } + + data = JSON.parse(data); + // Always start on the first page to show most recent queries + data.start = 0; + // Always start with empty search field + data.search.search = ""; + // Apply loaded state to table + return data; + } }); } From 3957e9eef1382a852e5be2ba0202c57175279f23 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Fri, 22 May 2020 13:48:31 +0100 Subject: [PATCH 3/3] Move some duplicated code to utils.js Signed-off-by: Adam Warner --- groups-domains.php | 2 +- network.php | 1 + queries.php | 1 + scripts/pi-hole/js/groups-adlists.js | 16 ++-------- scripts/pi-hole/js/groups-clients.js | 16 ++-------- scripts/pi-hole/js/groups-domains.js | 16 ++-------- scripts/pi-hole/js/groups.js | 16 ++-------- scripts/pi-hole/js/messages.js | 17 ++-------- scripts/pi-hole/js/network.js | 20 ++---------- scripts/pi-hole/js/queries.js | 20 ++---------- scripts/pi-hole/js/settings.js | 46 ++++++---------------------- scripts/pi-hole/js/utils.js | 25 ++++++++++++++- settings.php | 1 + 13 files changed, 54 insertions(+), 143 deletions(-) diff --git a/groups-domains.php b/groups-domains.php index a6c25074..374f1601 100644 --- a/groups-domains.php +++ b/groups-domains.php @@ -40,7 +40,7 @@
  • - +
    diff --git a/network.php b/network.php index 1fc64187..3aa7342d 100644 --- a/network.php +++ b/network.php @@ -77,5 +77,6 @@ $token = $_SESSION['token']; require "scripts/pi-hole/php/footer.php"; ?> + diff --git a/queries.php b/queries.php index 3b18a4ea..1ede7b45 100644 --- a/queries.php +++ b/queries.php @@ -156,6 +156,7 @@ if(strlen($showing) > 0)
    + +