Added subnet mask display/edit

This commit is contained in:
billz 2020-11-30 12:10:44 +00:00
parent 5b1325803a
commit 495f33eaa3
3 changed files with 14 additions and 2 deletions

View file

@ -46,7 +46,8 @@ if (isset($interface)) {
preg_match('/static\sdomain_name_servers=(.*)/', $matched[0], $static_dns);
preg_match('/fallback\sstatic_'.$interface.'/', $matched[0], $fallback);
$dhcpdata['Metric'] = $metric[1];
$dhcpdata['StaticIP'] = $static_ip[1];
$dhcpdata['StaticIP'] = substr($static_ip[1], 0, strpos($static_ip[1],'/'));
$dhcpdata['SubnetMask'] = cidr2mask($static_ip[1]);
$dhcpdata['StaticRouters'] = $static_routers[1];
$dhcpdata['StaticDNS'] = $static_dns[1];
$dhcpdata['FallbackEnabled'] = empty($fallback) ? false: true;

View file

@ -246,6 +246,7 @@ function loadInterfaceDHCPSelect() {
jsonData = JSON.parse(data);
$('#dhcp-iface')[0].checked = jsonData.DHCPEnabled;
$('#txtipaddress').val(jsonData.StaticIP);
$('#txtsubnetmask').val(jsonData.SubnetMask);
$('#txtgateway').val(jsonData.StaticRouters);
$('#chkfallback')[0].checked = jsonData.FallbackEnabled;
$('#txtrangestart').val(jsonData.RangeStart);
@ -257,7 +258,7 @@ function loadInterfaceDHCPSelect() {
$('#no-resolv')[0].checked = jsonData.upstreamServersEnabled;
$('#cbxdhcpupstreamserver').val(jsonData.upstreamServers[0]);
$('#txtmetric').val(jsonData.Metric);
if (jsonData.StaticIP !== null && jsonData.StaticIP !== '') {
if (jsonData.StaticIP !== null && jsonData.StaticIP !== '' && !jsonData.FallbackEnabled) {
$('#chkstatic').closest('.btn').button('toggle');
$('#chkstatic').closest('.btn').button('toggle').blur();
$('#chkstatic').blur();
@ -268,6 +269,9 @@ function loadInterfaceDHCPSelect() {
$('#chkdhcp').blur();
$('#chkfallback').prop('disabled', false);
}
if (jsonData.FallbackEnabled) {
$('#dhcp-iface').prop('disabled', true);
}
});
}

View file

@ -41,6 +41,13 @@
</div>
</div>
<div class="row">
<div class="form-group col-md-6">
<label for="code"><?php echo _("Subnet Mask"); ?></label>
<input type="text" class="form-control" id="txtsubnetmask" name="SubnetMask" />
</div>
</div>
<div class="row">
<div class="form-group col-md-6">
<label for="code"><?php echo _("Default gateway"); ?></label>