Add DHCP netmask field and nicely format API errors (#2805)

This commit is contained in:
DL6ER
2023-11-15 11:09:46 +01:00
committed by GitHub
2 changed files with 19 additions and 3 deletions

View File

@@ -114,6 +114,7 @@ function setConfigValues(topic, key, value) {
function saveSettings() { function saveSettings() {
var settings = {}; var settings = {};
utils.disableAll();
$("[data-key]").each(function () { $("[data-key]").each(function () {
var key = $(this).data("key"); var key = $(this).data("key");
var value = $(this).val(); var value = $(this).val();
@@ -168,6 +169,7 @@ function saveSettings() {
contentType: "application/json; charset=utf-8", contentType: "application/json; charset=utf-8",
}) })
.done(function () { .done(function () {
utils.enableAll();
// Success // Success
utils.showAlert( utils.showAlert(
"success", "success",
@@ -178,7 +180,10 @@ function saveSettings() {
// Reload page // Reload page
location.reload(); location.reload();
}) })
.fail(function (data) { .fail(function (data, exception) {
utils.enableAll();
utils.showAlert("error", "", "Error while applying settings", data.responseText);
console.log(exception); // eslint-disable-line no-console
apiFailure(data); apiFailure(data);
}); });
} }

View File

@@ -32,7 +32,7 @@ mg.include('scripts/pi-hole/lua/settings_header.lp','r')
<div class="col-xs-12 col-sm-6 col-md-12 col-lg-6"> <div class="col-xs-12 col-sm-6 col-md-12 col-lg-6">
<div class="form-group"> <div class="form-group">
<div class="input-group"> <div class="input-group">
<div class="input-group-addon">From</div> <div class="input-group-addon">Start</div>
<input type="text" class="form-control DHCPgroup" id="dhcp.start" data-key="dhcp.start" <input type="text" class="form-control DHCPgroup" id="dhcp.start" data-key="dhcp.start"
autocomplete="off" spellcheck="false" autocapitalize="none" autocomplete="off" spellcheck="false" autocapitalize="none"
autocorrect="off" value=""> autocorrect="off" value="">
@@ -42,7 +42,7 @@ mg.include('scripts/pi-hole/lua/settings_header.lp','r')
<div class="col-xs-12 col-sm-6 col-md-12 col-lg-6"> <div class="col-xs-12 col-sm-6 col-md-12 col-lg-6">
<div class="form-group"> <div class="form-group">
<div class="input-group"> <div class="input-group">
<div class="input-group-addon">To</div> <div class="input-group-addon">End</div>
<input type="text" class="form-control DHCPgroup" id="dhcp.end" data-key="dhcp.end" <input type="text" class="form-control DHCPgroup" id="dhcp.end" data-key="dhcp.end"
autocomplete="off" spellcheck="false" autocapitalize="none" autocomplete="off" spellcheck="false" autocapitalize="none"
autocorrect="off" value=""> autocorrect="off" value="">
@@ -60,6 +60,17 @@ mg.include('scripts/pi-hole/lua/settings_header.lp','r')
</div> </div>
</div> </div>
</div> </div>
<div class="col-xs-12 col-sm-6 col-md-12 col-lg-6">
<label>Netmask (<code>0.0.0.0</code> = auto)</label>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">Netmask</div>
<input type="text" class="form-control DHCPgroup" id="dhcp.netmask" data-key="dhcp.netmask"
autocomplete="off" spellcheck="false" autocapitalize="none"
autocorrect="off" value="">
</div>
</div>
</div>
<div class="col-md-12"> <div class="col-md-12">
<div><input type="checkbox" id="dhcp.ipv6" data-key="dhcp.ipv6" class="DHCPgroup">&nbsp;<label for="dhcp.ipv6"><strong>Enable additional IPv6 support (SLAAC + RA)</strong></label></div> <div><input type="checkbox" id="dhcp.ipv6" data-key="dhcp.ipv6" class="DHCPgroup">&nbsp;<label for="dhcp.ipv6"><strong>Enable additional IPv6 support (SLAAC + RA)</strong></label></div>
<p>Enable this option to enable IPv6 support for the Pi-hole DHCP server. This will allow the Pi-hole to hand out IPv6 addresses to clients and also provide IPv6 router advertisements (RA) to clients. This option is only useful if the Pi-hole is configured with an IPv6 address.</p> <p>Enable this option to enable IPv6 support for the Pi-hole DHCP server. This will allow the Pi-hole to hand out IPv6 addresses to clients and also provide IPv6 router advertisements (RA) to clients. This option is only useful if the Pi-hole is configured with an IPv6 address.</p>