mirror of
https://github.com/pi-hole/web.git
synced 2026-04-27 12:15:00 +01:00
@@ -35,6 +35,7 @@ function showAlert(type, icon, title, message) {
|
||||
} else {
|
||||
$.notify(opts);
|
||||
}
|
||||
|
||||
break;
|
||||
case "warning":
|
||||
opts = {
|
||||
@@ -48,6 +49,7 @@ function showAlert(type, icon, title, message) {
|
||||
} else {
|
||||
$.notify(opts);
|
||||
}
|
||||
|
||||
break;
|
||||
case "error":
|
||||
opts = {
|
||||
@@ -61,9 +63,9 @@ function showAlert(type, icon, title, message) {
|
||||
} else {
|
||||
$.notify(opts);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,10 +92,7 @@ $(document).ready(function() {
|
||||
|
||||
$("#select").on("change", function() {
|
||||
$("#ip-custom").val("");
|
||||
$("#ip-custom").prop(
|
||||
"disabled",
|
||||
$("#select option:selected").val() !== "custom"
|
||||
);
|
||||
$("#ip-custom").prop("disabled", $("#select option:selected").val() !== "custom");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -130,9 +129,7 @@ function initTable() {
|
||||
|
||||
var disabled = data.enabled === 0;
|
||||
$("td:eq(1)", row).html(
|
||||
'<input type="checkbox" id="status"' +
|
||||
(disabled ? "" : " checked") +
|
||||
">"
|
||||
'<input type="checkbox" id="status"' + (disabled ? "" : " checked") + ">"
|
||||
);
|
||||
var status = $("#status", row);
|
||||
status.bootstrapToggle({
|
||||
@@ -154,9 +151,7 @@ function initTable() {
|
||||
comment.on("change", editAdlist);
|
||||
|
||||
$("td:eq(3)", row).empty();
|
||||
$("td:eq(3)", row).append(
|
||||
'<select id="multiselect" multiple="multiple"></select>'
|
||||
);
|
||||
$("td:eq(3)", row).append('<select id="multiselect" multiple="multiple"></select>');
|
||||
var sel = $("#multiselect", row);
|
||||
// Add all known groups
|
||||
for (var i = 0; i < groups.length; i++) {
|
||||
@@ -164,12 +159,14 @@ function initTable() {
|
||||
if (!groups[i].enabled) {
|
||||
extra = " (disabled)";
|
||||
}
|
||||
|
||||
sel.append(
|
||||
$("<option />")
|
||||
.val(groups[i].id)
|
||||
.text(groups[i].name + extra)
|
||||
);
|
||||
}
|
||||
|
||||
// Select assigned groups
|
||||
sel.val(data.groups);
|
||||
// Initialize multiselect
|
||||
@@ -200,6 +197,7 @@ function initTable() {
|
||||
if (data === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
data = JSON.parse(data);
|
||||
// Always start on the first page to show most recent queries
|
||||
data.start = 0;
|
||||
@@ -249,31 +247,16 @@ function addAdlist() {
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
showAlert(
|
||||
"success",
|
||||
"glyphicon glyphicon-plus",
|
||||
"Successfully added adlist",
|
||||
address
|
||||
);
|
||||
showAlert("success", "glyphicon glyphicon-plus", "Successfully added adlist", address);
|
||||
$("#new_address").val("");
|
||||
$("#new_comment").val("");
|
||||
table.ajax.reload();
|
||||
} else {
|
||||
showAlert(
|
||||
"error",
|
||||
"",
|
||||
"Error while adding new adlist: ",
|
||||
response.message
|
||||
);
|
||||
showAlert("error", "", "Error while adding new adlist: ", response.message);
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
showAlert(
|
||||
"error",
|
||||
"",
|
||||
"Error while adding new adlist: ",
|
||||
jqXHR.responseText
|
||||
);
|
||||
showAlert("error", "", "Error while adding new adlist: ", jqXHR.responseText);
|
||||
console.log(exception);
|
||||
}
|
||||
});
|
||||
@@ -331,7 +314,7 @@ function editAdlist() {
|
||||
"error",
|
||||
"",
|
||||
"Error while " + not_done + " adlist with ID " + id,
|
||||
+response.message
|
||||
Number(response.message)
|
||||
);
|
||||
}
|
||||
},
|
||||
@@ -360,31 +343,15 @@ function deleteAdlist() {
|
||||
data: { action: "delete_adlist", id: id, token: token },
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
showAlert(
|
||||
"success",
|
||||
"glyphicon glyphicon-trash",
|
||||
"Successfully deleted adlist ",
|
||||
address
|
||||
);
|
||||
showAlert("success", "glyphicon glyphicon-trash", "Successfully deleted adlist ", address);
|
||||
table
|
||||
.row(tr)
|
||||
.remove()
|
||||
.draw(false);
|
||||
} else
|
||||
showAlert(
|
||||
"error",
|
||||
"",
|
||||
"Error while deleting adlist with ID " + id,
|
||||
response.message
|
||||
);
|
||||
} else showAlert("error", "", "Error while deleting adlist with ID " + id, response.message);
|
||||
},
|
||||
error: function(jqXHR, exception) {
|
||||
showAlert(
|
||||
"error",
|
||||
"",
|
||||
"Error while deleting adlist with ID " + id,
|
||||
jqXHR.responseText
|
||||
);
|
||||
showAlert("error", "", "Error while deleting adlist with ID " + id, jqXHR.responseText);
|
||||
console.log(exception);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user