Set default dhcp interface on page load

This commit is contained in:
billz 2020-11-21 13:52:20 +00:00
parent 73deab78cf
commit b63a53e182
3 changed files with 7 additions and 7 deletions

View file

@ -223,7 +223,7 @@ function contentLoaded() {
case "hostapd_conf": case "hostapd_conf":
loadChannel(); loadChannel();
case "dhcpd_conf": case "dhcpd_conf":
loadInterfaceDHCPSelect('wlan0'); loadInterfaceDHCPSelect();
break; break;
} }
} }
@ -240,9 +240,8 @@ function loadWifiStations(refresh) {
} }
$(".js-reload-wifi-stations").on("click", loadWifiStations(true)); $(".js-reload-wifi-stations").on("click", loadWifiStations(true));
function loadInterfaceDHCPSelect(default_iface) { function loadInterfaceDHCPSelect() {
var iface = (default_iface) ? default_iface : $('#cbxdhcpiface').val(); var iface = $('#cbxdhcpiface').val();
$('#cbxdhcpiface').val(iface);
$.get('ajax/networking/get_netcfg.php?iface='+iface,function(data){ $.get('ajax/networking/get_netcfg.php?iface='+iface,function(data){
jsonData = JSON.parse(data); jsonData = JSON.parse(data);
$('#dhcp-iface')[0].checked = jsonData.DHCPEnabled; $('#dhcp-iface')[0].checked = jsonData.DHCPEnabled;

View file

@ -44,17 +44,18 @@ function DisplayDHCPConfig()
} }
} }
} }
getWifiInterface();
$serviceStatus = $dnsmasq_state ? "up" : "down"; $serviceStatus = $dnsmasq_state ? "up" : "down";
exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces); exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces);
exec('cat ' . RASPI_DNSMASQ_LEASES, $leases); exec('cat ' . RASPI_DNSMASQ_LEASES, $leases);
$ap_iface = $_SESSION['ap_interface'];
echo renderTemplate( echo renderTemplate(
"dhcp", compact( "dhcp", compact(
"status", "status",
"serviceStatus", "serviceStatus",
"dnsmasq_state", "dnsmasq_state",
"conf", "ap_iface",
"dhcpHost", "dhcpHost",
"interfaces", "interfaces",
"leases" "leases"

View file

@ -3,7 +3,7 @@
<div class="row"> <div class="row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="code">Interface</label> <label for="code">Interface</label>
<?php SelectorOptions('interface', $interfaces, $conf['interface'], 'cbxdhcpiface', 'loadInterfaceDHCPSelect', $DHCPDisabled); ?> <?php SelectorOptions('interface', $interfaces, $ap_iface, 'cbxdhcpiface', 'loadInterfaceDHCPSelect', $DHCPDisabled); ?>
</div> </div>
</div> </div>