mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Fix AJAX JSON data (#2744)
This commit is contained in:
@@ -120,10 +120,11 @@ function piholeChange(action, duration) {
|
||||
url: "/api/dns/blocking",
|
||||
method: "POST",
|
||||
dataType: "json",
|
||||
data: {
|
||||
processData: false,
|
||||
data: JSON.stringify({
|
||||
blocking: action === "enable",
|
||||
timer: parseInt(duration, 10) > 0 ? parseInt(duration, 10) : null,
|
||||
},
|
||||
}),
|
||||
})
|
||||
.done(function (data) {
|
||||
if (data.blocking === action + "d") {
|
||||
|
||||
@@ -516,7 +516,8 @@ function addAdlist(event) {
|
||||
url: "/api/lists",
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
data: { address: address, comment: comment, type: type },
|
||||
processData: false,
|
||||
data: JSON.stringify({ address: address, comment: comment, type: type }),
|
||||
success: function () {
|
||||
utils.enableAll();
|
||||
utils.showAlert("success", "fas fa-plus", "Successfully added " + type + "list", address);
|
||||
@@ -582,12 +583,13 @@ function editAdlist() {
|
||||
url: "/api/lists/" + encodeURIComponent(addressDecoded),
|
||||
method: "put",
|
||||
dataType: "json",
|
||||
data: {
|
||||
processData: false,
|
||||
data: JSON.stringify({
|
||||
groups: groups,
|
||||
comment: comment,
|
||||
enabled: enabled,
|
||||
type: type,
|
||||
},
|
||||
}),
|
||||
success: function () {
|
||||
utils.enableAll();
|
||||
utils.showAlert(
|
||||
|
||||
@@ -440,7 +440,8 @@ function addClient() {
|
||||
url: "/api/clients",
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
data: { client: ip, comment: comment },
|
||||
processData: false,
|
||||
data: JSON.stringify({ client: ip, comment: comment }),
|
||||
success: function () {
|
||||
utils.enableAll();
|
||||
utils.showAlert("success", "fas fa-plus", "Successfully added client", ip);
|
||||
@@ -495,12 +496,13 @@ function editClient() {
|
||||
url: "/api/clients/" + encodeURIComponent(clientDecoded),
|
||||
method: "put",
|
||||
dataType: "json",
|
||||
data: {
|
||||
processData: false,
|
||||
data: JSON.stringify({
|
||||
client: client,
|
||||
groups: groups,
|
||||
comment: comment,
|
||||
enabled: enabled,
|
||||
},
|
||||
}),
|
||||
success: function () {
|
||||
utils.enableAll();
|
||||
utils.showAlert(
|
||||
|
||||
@@ -527,12 +527,13 @@ function addDomain() {
|
||||
url: "/api/domains/" + type + "/" + kind,
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
data: {
|
||||
processData: false,
|
||||
data: JSON.stringify({
|
||||
domain: domain,
|
||||
comment: comment,
|
||||
type: type,
|
||||
kind: kind,
|
||||
},
|
||||
}),
|
||||
success: function () {
|
||||
utils.enableAll();
|
||||
utils.showAlert("success", "fas fa-plus", "Successfully added domain", domain);
|
||||
@@ -609,13 +610,14 @@ function editDomain() {
|
||||
url: "/api/domains/" + newTypestr + "/" + encodeURIComponent(domainDecoded),
|
||||
method: "put",
|
||||
dataType: "json",
|
||||
data: {
|
||||
processData: false,
|
||||
data: JSON.stringify({
|
||||
groups: groups,
|
||||
comment: comment,
|
||||
enabled: enabled,
|
||||
type: oldType,
|
||||
kind: oldKind,
|
||||
},
|
||||
}),
|
||||
success: function () {
|
||||
utils.enableAll();
|
||||
utils.showAlert(
|
||||
|
||||
@@ -294,11 +294,12 @@ function addGroup() {
|
||||
url: "/api/groups",
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
data: {
|
||||
processData: false,
|
||||
data: JSON.stringify({
|
||||
name: name,
|
||||
comment: comment,
|
||||
enabled: true,
|
||||
},
|
||||
}),
|
||||
success: function () {
|
||||
utils.enableAll();
|
||||
utils.showAlert("success", "fas fa-plus", "Successfully added group", name);
|
||||
@@ -360,11 +361,12 @@ function editGroup() {
|
||||
url: "/api/groups/" + oldName,
|
||||
method: "put",
|
||||
dataType: "json",
|
||||
data: {
|
||||
processData: false,
|
||||
data: JSON.stringify({
|
||||
name: name,
|
||||
comment: comment,
|
||||
enabled: enabled,
|
||||
},
|
||||
}),
|
||||
success: function () {
|
||||
utils.enableAll();
|
||||
utils.showAlert("success", "fas fa-pencil-alt", "Successfully " + done + " group", oldName);
|
||||
|
||||
@@ -61,7 +61,8 @@ function doLogin(password) {
|
||||
url: "/api/auth",
|
||||
method: "POST",
|
||||
dataType: "json",
|
||||
data: { password: password, totp: parseInt($("#totp").val(), 10) },
|
||||
processData: false,
|
||||
data: JSON.stringify({ password: password, totp: parseInt($("#totp").val(), 10) }),
|
||||
})
|
||||
.done(function () {
|
||||
wrongPassword(false, true);
|
||||
|
||||
@@ -319,7 +319,8 @@ function setTOTPSecret(secret) {
|
||||
url: "/api/config",
|
||||
type: "PATCH",
|
||||
dataType: "json",
|
||||
data: { config: { webserver: { api: { totp_secret: secret } } } },
|
||||
processData: false,
|
||||
data: JSON.stringify({ config: { webserver: { api: { totp_secret: secret } } } }),
|
||||
contentType: "application/json",
|
||||
})
|
||||
.done(function () {
|
||||
|
||||
@@ -290,6 +290,8 @@ $("#loggingButton").confirm({
|
||||
$.ajax({
|
||||
url: "/api/config/dns/queryLogging",
|
||||
type: "PATCH",
|
||||
dataType: "json",
|
||||
processData: false,
|
||||
data: JSON.stringify(data),
|
||||
})
|
||||
.done(function (data) {
|
||||
|
||||
@@ -138,7 +138,8 @@ function saveSettings() {
|
||||
url: "/api/config",
|
||||
method: "PATCH",
|
||||
dataType: "json",
|
||||
data: { config: settings },
|
||||
processData: false,
|
||||
data: JSON.stringify({ config: settings }),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
})
|
||||
.done(function () {
|
||||
|
||||
@@ -315,12 +315,13 @@ function addFromQueryLog(domain, list) {
|
||||
url: "/api/domains/" + list + "/exact",
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
data: {
|
||||
processData: false,
|
||||
data: JSON.stringify({
|
||||
domain: domain,
|
||||
comment: "Added from Query Log",
|
||||
type: list,
|
||||
kind: "exact",
|
||||
},
|
||||
}),
|
||||
success: function (response) {
|
||||
alProcessing.hide();
|
||||
if ("domains" in response && response.domains.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user