Add settings-privacy.lp

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2023-05-09 20:12:58 +02:00
parent a83411cb0b
commit 74baa97aaf
5 changed files with 146 additions and 3 deletions
+1
View File
@@ -197,6 +197,7 @@ function generateRow(topic, key, value) {
break;
}
case "enum (unsigned integer)": // fallthrough
case "enum (string)": {
box +=
'<label class="col-sm-4 control-label">Selected Option</label>' +
+24
View File
@@ -0,0 +1,24 @@
/* Pi-hole: A black hole for Internet advertisements
* (c) 2023 Pi-hole, LLC (https://pi-hole.net)
* Network-wide ad blocking via your own hardware.
*
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
/* global setConfigValues: false, apiFailure: false */
function getConfig() {
$.ajax({
url: "/api/config/?detailed=true",
})
.done(function (data) {
setConfigValues("", "", data.config);
})
.fail(function (data) {
apiFailure(data);
});
}
$(document).ready(function () {
getConfig();
});
+11 -2
View File
@@ -28,7 +28,9 @@ function setConfigValues(topic, key, value) {
if (!("description" in value)) {
Object.keys(value).forEach(function (subkey) {
var subvalue = value[subkey];
setConfigValues(topic, key + "." + subkey, subvalue);
// If the key is empty, we are at the top level
var newKey = key === "" ? subkey : key + "." + subkey;
setConfigValues(topic, newKey, subvalue);
});
return;
}
@@ -36,6 +38,7 @@ function setConfigValues(topic, key, value) {
// else: we have a setting we can set
var escapedKey = key.replace(/\./g, "\\.");
switch (value.type) {
case "enum (unsigned integer)": // fallthrough
case "enum (string)": {
// Remove all options from select
$("#" + escapedKey + " option").remove();
@@ -68,7 +71,13 @@ function setConfigValues(topic, key, value) {
default: {
// Set input field values (if available)
$("#" + escapedKey).val(value.value);
// Set text if this is a <span> or <code> element
if ($("#" + escapedKey).is("span") || $("#" + escapedKey).is("code")) {
$("#" + escapedKey).text(value.value);
} else {
// Set value if this is an <input> element
$("#" + escapedKey).val(value.value);
}
}
}
}
+1 -1
View File
@@ -155,7 +155,7 @@
</li>
<li class="<? if scriptname == 'settings-privacy.lp' then mg.write(" active") end ?>">
<a href="settings-privacy.lp">
<i class="fa-fw menu-icon fa-solid fa-binoculars"></i> <span class="text-red">Privacy</span>
<i class="fa-fw menu-icon fa-solid fa-binoculars"></i> <span class="text-green">Privacy</span>
</a>
</li>
<li class="<? if scriptname == 'settings-advanced.lp' then mg.write(" active") end ?> settings-level-2">