diff --git a/api_FTL.php b/api_FTL.php index f677d55c..19a94f82 100644 --- a/api_FTL.php +++ b/api_FTL.php @@ -336,9 +336,11 @@ 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]; + $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..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]); + 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 = [];