Browse Source

Added subnet mask display/edit

pull/749/head
billz 2 years ago
parent
commit
495f33eaa3
  1. 3
      ajax/networking/get_netcfg.php
  2. 6
      app/js/custom.js
  3. 7
      templates/dhcp/general.php

3
ajax/networking/get_netcfg.php

@ -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;

6
app/js/custom.js

@ -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);
}
});
}

7
templates/dhcp/general.php

@ -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>

Loading…
Cancel
Save