From 6f93f89e59a4a16478172623b8b1d5427c88a280 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sun, 3 Jun 2018 16:13:59 -0400 Subject: [PATCH 1/3] Use new `client-names` FTL response format Signed-off-by: Mcat12 --- api_FTL.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/api_FTL.php b/api_FTL.php index d2966f34..f1d7a5a7 100644 --- a/api_FTL.php +++ b/api_FTL.php @@ -353,9 +353,7 @@ else $client_names = array(); foreach($return as $line) { - $tmp = explode(" ",$line); - // returned data is in format: "ID count hostname" - $client_names[intval($tmp[0])] = $tmp[2]; + $client_names[] = $line; } $result = array('clients' => $client_names); From 357da1d15af7044e9658652c470d68391bd460fa Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Wed, 6 Jun 2018 18:27:55 -0400 Subject: [PATCH 2/3] Expose both name and IP of client Signed-off-by: Mcat12 --- api_FTL.php | 6 +++++- scripts/pi-hole/js/index.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/api_FTL.php b/api_FTL.php index f1d7a5a7..3cf3f5f4 100644 --- a/api_FTL.php +++ b/api_FTL.php @@ -353,7 +353,11 @@ else $client_names = array(); foreach($return as $line) { - $client_names[] = $line; + $tmp = explode(" ", $line); + $client_names[] = array( + "name" => $tmp[0], + "ip" => $tmp[1] + ); } $result = array('clients' => $client_names); diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 0ace02af..e91369eb 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -386,7 +386,7 @@ function updateClientsOverTime() { for (key in data.clients) { if (!{}.hasOwnProperty.call(data.clients, key)) continue; - labels.push(data.clients[key]); + labels.push(data.clients[key].name); } // Get colors from AdminLTE var colors = []; From 2aef23504091eda7b68201139db43fc84e7131c7 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 7 Jun 2018 19:03:39 +0200 Subject: [PATCH 3/3] Use client address if name is empty Signed-off-by: DL6ER --- scripts/pi-hole/js/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index e91369eb..c765b33f 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -386,7 +386,16 @@ function updateClientsOverTime() { for (key in data.clients) { if (!{}.hasOwnProperty.call(data.clients, key)) continue; - labels.push(data.clients[key].name); + var clientname; + if(data.clients[key].name.length > 0) + { + clientname = data.clients[key].name; + } + else + { + clientname = data.clients[key].ip; + } + labels.push(clientname); } // Get colors from AdminLTE var colors = [];