mirror of
https://github.com/pi-hole/web.git
synced 2025-12-20 02:38:28 +00:00
Disable settings inputs if they are already set by environment variable. Add a padlock icon to the setting section title if any of the settings contained therin are set by environment variable
This commit is contained in:
@@ -50,7 +50,7 @@ function generateRow(topic, key, value) {
|
||||
? ' <i class="fas fa-redo text-orange" title="Setting requires FTL restart on change"></i>'
|
||||
: "") +
|
||||
(value.flags.env_var
|
||||
? ' <i class="fas fa-times-circle text-red" title="Setting overwritten by an environmental variable are read-only"></i>'
|
||||
? ' <i class="fas fa-lock text-orange" title="Settings overwritten by an environmental variable are read-only"></i>'
|
||||
: "") +
|
||||
"</h3>" +
|
||||
"<p>" +
|
||||
|
||||
@@ -18,6 +18,12 @@ function removeFromArray(arr, what) {
|
||||
}
|
||||
|
||||
function fillDNSupstreams(value, servers) {
|
||||
var disabledStr = "";
|
||||
if (value.flags.env_var === true) {
|
||||
$("#DNSupstreamsTextfield").prop("disabled", true);
|
||||
disabledStr = 'disabled="Disabled"';
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
var customServers = value.value.length;
|
||||
servers.forEach(element => {
|
||||
@@ -30,21 +36,21 @@ function fillDNSupstreams(value, servers) {
|
||||
// Loop over available addresses (up to 2)
|
||||
for (let index = 0; index < 2; index++) {
|
||||
if (address.length > index) {
|
||||
row +=
|
||||
'<td title="' +
|
||||
address[index] +
|
||||
'"><div><input type="checkbox" id="DNSupstreams-' +
|
||||
i +
|
||||
'"';
|
||||
var checkedStr = "";
|
||||
if (
|
||||
value.value.includes(address[index]) ||
|
||||
value.value.includes(address[index] + "#53")
|
||||
) {
|
||||
row += " checked";
|
||||
checkedStr = "checked";
|
||||
customServers--;
|
||||
}
|
||||
|
||||
row += '><label for="DNSupstreams-' + i++ + '"></label></div></td>';
|
||||
row += `<td title="${address[index]}">
|
||||
<div>
|
||||
<input type="checkbox" id="DNSupstreams-${i}" ${disabledStr} ${checkedStr}>
|
||||
<label for="DNSupstreams-${i++}"></label>
|
||||
</div>
|
||||
</td>`;
|
||||
} else {
|
||||
row += "<td></td>";
|
||||
}
|
||||
|
||||
@@ -37,6 +37,19 @@ function setConfigValues(topic, key, value) {
|
||||
|
||||
// else: we have a setting we can set
|
||||
var escapedKey = key.replaceAll(".", "\\.");
|
||||
|
||||
if (value.flags.env_var) {
|
||||
// If this setting has been set by environment variable, display a padlock in the section title
|
||||
var envTitle = $(`.${escapedKey}`);
|
||||
if (envTitle.find(".env-warning").length === 0) {
|
||||
envTitle.append(
|
||||
`<span class="env-warning"> <i class="fas fa-lock text-orange env-warning" title="Settings overwritten by an environmental variable are read-only"></i></span>`
|
||||
);
|
||||
}
|
||||
|
||||
$(`#${escapedKey}`).prop("disabled", "disabled");
|
||||
}
|
||||
|
||||
switch (value.type) {
|
||||
case "enum (unsigned integer)": // fallthrough
|
||||
case "enum (string)": {
|
||||
@@ -44,6 +57,7 @@ function setConfigValues(topic, key, value) {
|
||||
$("#" + escapedKey + " option").remove();
|
||||
// Add allowed select items (if available)
|
||||
value.allowed.forEach(function (allowedValue) {
|
||||
$("#" + escapedKey + "-" + allowedValue.item).prop("disabled", value.flags.env_var);
|
||||
var newopt = $("<option></option>")
|
||||
.attr("value", allowedValue.item)
|
||||
.text(allowedValue.description);
|
||||
@@ -70,7 +84,6 @@ function setConfigValues(topic, key, value) {
|
||||
case "string array": {
|
||||
// Set input field values from array (if available)
|
||||
$("#" + escapedKey).val(value.value.join("\n"));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ mg.include('scripts/pi-hole/lua/settings_header.lp','r')
|
||||
<div class="col-md-12 settings-level-1">
|
||||
<div class="box box-warning">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Exclusions</h3>
|
||||
<h3 class="box-title webserver.api.excludeDomains webserver.api.excludeClients">Exclusions</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
@@ -40,7 +40,7 @@ mg.include('scripts/pi-hole/lua/settings_header.lp','r')
|
||||
<div class="col-md-12 settings-level-0">
|
||||
<div class="box box-warning">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Theme settings</h3>
|
||||
<h3 class="box-title webserver.interface.theme webserver.interface.boxed">Theme settings</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
@@ -65,7 +65,7 @@ mg.include('scripts/pi-hole/lua/settings_header.lp','r')
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!--
|
||||
</div><!-- TODO: Why is this commented out?
|
||||
<div class="col-md-6">
|
||||
<div class="box box-warning">
|
||||
<div class="box-header with-border">
|
||||
@@ -92,7 +92,7 @@ mg.include('scripts/pi-hole/lua/settings_header.lp','r')
|
||||
<div class="col-md-6 settings-level-1">
|
||||
<div class="box box-warning">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Advanced Settings</h3>
|
||||
<h3 class="box-title webserver.api.localAPIauth webserver.api.prettyJSON webserver.api.allow_destructive webserver.api.temp.limit webserver.api.temp.unit">Advanced Settings</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
|
||||
@@ -18,7 +18,7 @@ mg.include('scripts/pi-hole/lua/settings_header.lp','r')
|
||||
<div class="col-md-6 settings-level-0">
|
||||
<div class="box box-warning">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">DHCP Settings</h3>
|
||||
<h3 class="box-title dhcp.active dhcp.start dhcp.end dhcp.router dhcp.ipv6">DHCP Settings</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
@@ -71,7 +71,7 @@ mg.include('scripts/pi-hole/lua/settings_header.lp','r')
|
||||
<div class="col-md-6 settings-level-1">
|
||||
<div class="box box-warning">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Advanced DHCP Settings</h3>
|
||||
<h3 class="box-title dhcp.domain dhcp.leaseTime dhcp.rapidCommit chdp.multiDNS">Advanced DHCP Settings</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
|
||||
@@ -17,7 +17,7 @@ mg.include('scripts/pi-hole/lua/settings_header.lp','r')
|
||||
<div class="col-lg-6">
|
||||
<div class="box box-warning">
|
||||
<div class="box-header with-border">
|
||||
<h1 class="box-title">Upstream DNS Servers</h1>
|
||||
<h1 class="box-title dns.upstreams" id="lblDNSupstreams">Upstream DNS Servers</h1>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
@@ -59,7 +59,7 @@ mg.include('scripts/pi-hole/lua/settings_header.lp','r')
|
||||
</div>
|
||||
<div class="box box-warning settings-level-1">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Conditional forwarding <i class="fas fa-wrench" title="This is an advanced-level setting"></i></h3>
|
||||
<h3 class="box-title dns.revServer.active dns.revServer.cidr dns.revServer.target dns.revServer.domain">Conditional forwarding <i class="fas fa-wrench" title="This is an advanced-level setting"></i></h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
@@ -125,7 +125,7 @@ mg.include('scripts/pi-hole/lua/settings_header.lp','r')
|
||||
<div class="col-lg-6 settings-level-1">
|
||||
<div class="box box-warning">
|
||||
<div class="box-header with-border">
|
||||
<h1 class="box-title">Interface settings <i class="fas fa-wrench" title="This is an advanced-level setting"></i></h1>
|
||||
<h1 class="box-title dns.listeningMode">Interface settings <i class="fas fa-wrench" title="This is an advanced-level setting"></i></h1>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
@@ -166,7 +166,7 @@ mg.include('scripts/pi-hole/lua/settings_header.lp','r')
|
||||
</div>
|
||||
<div class="box box-warning">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Advanced DNS settings</h3>
|
||||
<h3 class="box-title dns.domainNeeded dns.bogusPriv dns.dnssec">Advanced DNS settings</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
@@ -212,7 +212,7 @@ mg.include('scripts/pi-hole/lua/settings_header.lp','r')
|
||||
</div>
|
||||
<div class="box box-warning settings-level-2">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Rate-limiting <i class="fas fa-wrench" title="This is an advanced-level setting"></i></h3>
|
||||
<h3 class="box-title dns.rateLimit.count dns.rateLimit.interval">Rate-limiting <i class="fas fa-wrench" title="This is an advanced-level setting"></i></h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
|
||||
@@ -19,7 +19,7 @@ mg.include('scripts/pi-hole/lua/settings_header.lp','r')
|
||||
<div class="col-md-12">
|
||||
<div class="box box-warning">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Query Logging</h3>
|
||||
<h3 class="box-title dns.queryLogging">Query Logging</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
@@ -37,7 +37,7 @@ mg.include('scripts/pi-hole/lua/settings_header.lp','r')
|
||||
<div class="col-md-12 settings-level-2">
|
||||
<div class="box box-warning">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Privacy-related database settings</h3>
|
||||
<h3 class="box-title database.DBimport database.DBexport database.maxDBdays database.network.expire">Privacy-related database settings</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
@@ -70,7 +70,7 @@ mg.include('scripts/pi-hole/lua/settings_header.lp','r')
|
||||
<div class="col-md-6 settings-level-1">
|
||||
<div class="box box-warning">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Query Anonymization ("Privacy Level")</h3>
|
||||
<h3 class="box-title misc.privacylevel">Query Anonymization ("Privacy Level")</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
|
||||
Reference in New Issue
Block a user