Add static IP fields, fallback, toggle state

This commit is contained in:
billz 2020-11-26 17:16:54 +00:00
parent d3e842f6db
commit 6d331c3ebd
2 changed files with 67 additions and 7 deletions

View file

@ -245,6 +245,9 @@ function loadInterfaceDHCPSelect() {
$.get('ajax/networking/get_netcfg.php?iface='+iface,function(data){
jsonData = JSON.parse(data);
$('#dhcp-iface')[0].checked = jsonData.DHCPEnabled;
$('#txtipaddress').val(jsonData.StaticIP);
$('#txtgateway').val(jsonData.StaticRouters);
$('#chkfallback')[0].checked = jsonData.FallbackEnabled;
$('#txtrangestart').val(jsonData.RangeStart);
$('#txtrangeend').val(jsonData.RangeEnd);
$('#txtrangeleasetime').val(jsonData.leaseTime);
@ -253,6 +256,14 @@ function loadInterfaceDHCPSelect() {
$('#cbxrangeleasetimeunits').val(jsonData.leaseTimeInterval);
$('#no-resolv')[0].checked = jsonData.upstreamServersEnabled;
$('#cbxdhcpupstreamserver').val(jsonData.upstreamServers[0]);
$('#txtmetric').val(jsonData.Metric);
if (jsonData.StaticIP !== null && jsonData.StaticIP !== '') {
$('#chkstatic').closest('.btn').button('toggle');
$('#chkstatic').closest('.btn').blur();
} else {
$('#chkdhcp').closest('.btn').button('toggle');
$('#chkdhcp').closest('.btn').blur();
}
});
}

View file

@ -7,6 +7,48 @@
</div>
</div>
<h5 class="mt-1"><?php echo _("Adapter IP Address Settings"); ?></h5>
<div class="row">
<div class="form-group col-md-6">
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-light active">
<input type="radio" name="adapter-ip" id="chkdhcp" autocomplete="off" checked>DHCP
</label>
<label class="btn btn-light">
<input type="radio" name="adapter-ip" id="chkstatic" autocomplete="off">Static IP
</label>
</div>
</div>
</div>
<div class="row">
<div class="form-group col-md-6">
<div class="custom-control custom-switch">
<input class="custom-control-input" id="chkfallback" type="checkbox" name="Fallback" value="1" aria-describedby="fallback-description">
<label class="custom-control-label" for="fallback"><?php echo _("Enable fallback to static option") ?></label>
</div>
<p class="mb-0" id="fallback-description">
<small><?php echo _("Enable this option to configure a static profile and fall back to it when DHCP lease fails.") ?></small>
</p>
</div>
</div>
<h5 class="mt-1">Static IP options</h5>
<div class="row">
<div class="form-group col-md-6">
<label for="code"><?php echo _("IP Address"); ?></label>
<input type="text" class="form-control" id="txtipaddress" name="StaticIP" />
</div>
</div>
<div class="row">
<div class="form-group col-md-6">
<label for="code"><?php echo _("Default gateway"); ?></label>
<input type="text" class="form-control" id="txtgateway" name="DefaultGateway" />
</div>
</div>
<h5 class="mt-1">DHCP options</h5>
<div class="row">
<div class="form-group col-md-6">
<div class="input-group">
@ -16,7 +58,7 @@
<label class="custom-control-label" for="dhcp-iface"><?php echo _("Enable DHCP for this interface") ?></label>
</div>
<p class="mb-0" id="dhcp-iface-description">
<small><?php echo _("Enable this option if you want RaspAP to assign IP addresses on the selected interface.") ?></small>
<small><?php echo _("Enable this option if you want RaspAP to assign IP addresses to clients on the selected interface. A static IP address is required for this option.") ?></small>
</p>
</div>
</div>
@ -25,21 +67,21 @@
<div class="row">
<div class="form-group col-md-6">
<label for="code"><?php echo _("Starting IP Address"); ?></label>
<input type="text" class="form-control" id="txtrangestart" name="RangeStart" value="<?php echo htmlspecialchars($RangeStart, ENT_QUOTES); ?>" />
<input type="text" class="form-control" id="txtrangestart" name="RangeStart" />
</div>
</div>
<div class="row">
<div class="form-group col-md-6">
<label for="code"><?php echo _("Ending IP Address"); ?></label>
<input type="text" class="form-control" id="txtrangeend" name="RangeEnd" value="<?php echo htmlspecialchars($RangeEnd, ENT_QUOTES); ?>" />
<input type="text" class="form-control" id="txtrangeend" name="RangeEnd" />
</div>
</div>
<div class="row">
<div class="form-group col-xs-3 col-sm-3">
<label for="code"><?php echo _("Lease Time"); ?></label>
<input type="text" class="form-control" id="txtrangeleasetime" name="RangeLeaseTime" value="<?php echo htmlspecialchars($arrRangeLeaseTime[1], ENT_QUOTES); ?>" />
<input type="text" class="form-control" id="txtrangeleasetime" name="RangeLeaseTime" />
</div>
<div class="col-xs-3 col-sm-3">
<label for="code"><?php echo _("Interval"); ?></label>
@ -55,14 +97,21 @@
<div class="row">
<div class="form-group col-md-6">
<label for="code"><?php echo _("DNS Server"); ?> 1</label>
<input type="text" class="form-control" id="txtdns1" name="DNS1" value="<?php echo htmlspecialchars($DNS1, ENT_QUOTES); ?>" />
<input type="text" class="form-control" id="txtdns1" name="DNS1" />
</div>
</div>
<div class="row">
<div class="form-group col-md-6">
<label for="code"><?php echo _("DNS Server"); ?> 2</label>
<input type="text" class="form-control" id="txtdns2" name="DNS2" value="<?php echo htmlspecialchars($DNS2, ENT_QUOTES); ?>" />
<input type="text" class="form-control" id="txtdns2" name="DNS2" />
</div>
</div>
<div class="row">
<div class="form-group col-md-6">
<label for="<metric"><?php echo _("Metric") ?></label>
<input type="text" class="form-control" id="txtmetric" name="Metric">
</div>
</div>