mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 20:55:28 +00:00
Fix multi-deletion of DHCP leases
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -163,7 +163,7 @@ function deleteLease() {
|
||||
|
||||
function delLease(ip) {
|
||||
utils.disableAll();
|
||||
utils.showAlert("info", "", "Deleting lease...");
|
||||
const toast = utils.showAlert("info", "", "Deleting lease...", ip, null);
|
||||
|
||||
$.ajax({
|
||||
url: "/api/dhcp/leases/" + encodeURIComponent(ip),
|
||||
@@ -172,10 +172,10 @@ function delLease(ip) {
|
||||
.done(function (response) {
|
||||
utils.enableAll();
|
||||
if (response === undefined) {
|
||||
utils.showAlert("success", "far fa-trash-alt", "Successfully deleted lease", "");
|
||||
utils.showAlert("success", "far fa-trash-alt", "Successfully deleted lease", ip, toast);
|
||||
dhcpLeaesTable.ajax.reload(null, false);
|
||||
} else {
|
||||
utils.showAlert("error", "", "Error while deleting lease: " + ip, response.lease);
|
||||
utils.showAlert("error", "", "Error while deleting lease: " + ip, response.lease, toast);
|
||||
}
|
||||
|
||||
// Clear selection after deletion
|
||||
@@ -184,7 +184,7 @@ function delLease(ip) {
|
||||
})
|
||||
.fail(function (jqXHR, exception) {
|
||||
utils.enableAll();
|
||||
utils.showAlert("error", "", "Error while deleting lease: " + ip, jqXHR.responseText);
|
||||
utils.showAlert("error", "", "Error while deleting lease: " + ip, jqXHR.responseText, toast);
|
||||
console.log(exception); // eslint-disable-line no-console
|
||||
});
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ function padNumber(num) {
|
||||
}
|
||||
|
||||
var showAlertBox = null;
|
||||
function showAlert(type, icon, title, message) {
|
||||
function showAlert(type, icon, title, message, toast) {
|
||||
const options = {
|
||||
title: " <strong>" + escapeHtml(title) + "</strong><br>",
|
||||
message: escapeHtml(message),
|
||||
@@ -138,16 +138,28 @@ function showAlert(type, icon, title, message) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type === "info") {
|
||||
// Create a new notification for info boxes
|
||||
showAlertBox = $.notify(options, settings);
|
||||
} else if (showAlertBox !== null) {
|
||||
// Update existing notification for other boxes (if available)
|
||||
showAlertBox.update(options);
|
||||
showAlertBox.update(settings);
|
||||
if (toast === undefined) {
|
||||
if (type === "info") {
|
||||
// Create a new notification for info boxes
|
||||
showAlertBox = $.notify(options, settings);
|
||||
return showAlertBox;
|
||||
} else if (showAlertBox !== null) {
|
||||
// Update existing notification for other boxes (if available)
|
||||
showAlertBox.update(options);
|
||||
showAlertBox.update(settings);
|
||||
return showAlertBox;
|
||||
} else {
|
||||
// Create a new notification for other boxes if no previous info box exists
|
||||
return $.notify(options, settings);
|
||||
}
|
||||
} else if (toast === null) {
|
||||
// Always create a new toast
|
||||
return $.notify(options, settings);
|
||||
} else {
|
||||
// Create a new notification for other boxes if no previous info box exists
|
||||
$.notify(options, settings);
|
||||
// Update existing toast
|
||||
toast.update(options);
|
||||
toast.update(settings);
|
||||
return toast;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user