Ensure IP addresses w/o MAC addresses are also shown and that already added clients are hidden.

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2020-05-13 22:59:28 +02:00
parent bdca8104e5
commit 68b99658ad
2 changed files with 13 additions and 10 deletions
+7 -7
View File
@@ -32,12 +32,12 @@ function reload_client_suggestions() {
continue;
}
// Add MAC address
var text = key.toUpperCase();
// Check if this is a valid MAC address (skip mock devices)
if (!utils.validateMAC(text)) {
continue;
var text = key,
key_plain = key;
if (key.startsWith("IP-")) {
// Mock MAC address for address-only devices
key_plain = key.substring(3);
text = key_plain;
}
// Append host name if available
@@ -45,7 +45,7 @@ function reload_client_suggestions() {
text += " (" + data[key] + ")";
}
sel.append($("<option />").val(key).text(text));
sel.append($("<option />").val(key_plain).text(text));
}
},
"json"
+6 -3
View File
@@ -216,7 +216,7 @@ if ($_POST['action'] == 'get_groups') {
// Loop over results
$ips = array();
while ($res = $query->fetchArray(SQLITE3_ASSOC)) {
$ips[$res['hwaddr']] = $res['name'] !== null ? $res['name'] : '';
$ips[strtoupper($res['hwaddr'])] = $res['name'] !== null ? $res['name'] : '';
}
$FTLdb->close();
@@ -227,8 +227,11 @@ if ($_POST['action'] == 'get_groups') {
// Loop over results, remove already configured clients
while (($res = $query->fetchArray(SQLITE3_ASSOC)) !== false) {
if (isset($ips[$res['hwaddr']])) {
unset($ips[$res['hwaddr']]);
if (isset($ips[$res['ip']])) {
unset($ips[$res['ip']]);
}
if (isset($ips["IP-".$res['ip']])) {
unset($ips["IP-".$res['ip']]);
}
}