mirror of
https://github.com/pi-hole/web.git
synced 2025-12-22 19:58:27 +00:00
Add button to remove dynamic DHCP leases. They are immediately removed both from FTL and the dhcp.leases file (FTL takes care of updating the file!) WITHOUT the need for a restart of the DHCP/DNS resolver.
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -416,6 +416,13 @@ else
|
|||||||
$data = array_merge($data, $result);
|
$data = array_merge($data, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($_GET['delete_lease']) && $auth)
|
||||||
|
{
|
||||||
|
sendRequestFTL("delete-lease ".$_GET['delete_lease']);
|
||||||
|
$return = getResponseFTL();
|
||||||
|
$data["delete_lease"] = $return[0];
|
||||||
|
}
|
||||||
|
|
||||||
disconnectFTL();
|
disconnectFTL();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
* Please see LICENSE file for your rights under this license. */
|
* Please see LICENSE file for your rights under this license. */
|
||||||
|
|
||||||
/* global utils:false */
|
/* global utils:false */
|
||||||
|
var token = $("#token").text();
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
$("[data-static]").on("click", function () {
|
$("[data-static]").on("click", function () {
|
||||||
@@ -283,3 +284,48 @@ $(function () {
|
|||||||
localStorage.setItem("barchart_chkbox", bargraphs.prop("checked"));
|
localStorage.setItem("barchart_chkbox", bargraphs.prop("checked"));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Delete dynamic DHCP lease
|
||||||
|
$('button[id="removedynamic"]').on("click", function () {
|
||||||
|
var tr = $(this).closest("tr");
|
||||||
|
var ipaddr = utils.escapeHtml(tr.children("#IP").text());
|
||||||
|
var name = utils.escapeHtml(tr.children("#HOST").text());
|
||||||
|
var ipname = name + " (" + ipaddr + ")";
|
||||||
|
|
||||||
|
utils.disableAll();
|
||||||
|
utils.showAlert("info", "", "Deleting DHCP lease...", ipname);
|
||||||
|
$.ajax({
|
||||||
|
url: "api.php",
|
||||||
|
method: "get",
|
||||||
|
dataType: "json",
|
||||||
|
data: {
|
||||||
|
delete_lease: ipaddr,
|
||||||
|
token: token
|
||||||
|
},
|
||||||
|
success: function (response) {
|
||||||
|
utils.enableAll();
|
||||||
|
if (response.delete_lease.startsWith("OK")) {
|
||||||
|
utils.showAlert(
|
||||||
|
"success",
|
||||||
|
"far fa-trash-alt",
|
||||||
|
"Successfully deleted DHCP lease for ",
|
||||||
|
ipname
|
||||||
|
);
|
||||||
|
// Remove column on success
|
||||||
|
tr.remove();
|
||||||
|
// We have to hide the tooltips explicitly or they will stay there forever as
|
||||||
|
// the onmouseout event does not fire when the element is already gone
|
||||||
|
$.each($(".tooltip"), function () {
|
||||||
|
$(this).remove();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
utils.showAlert("error", "Error while deleting DHCP lease for " + ipname, response);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, exception) {
|
||||||
|
utils.enableAll();
|
||||||
|
utils.showAlert("error", "Error while deleting DHCP lease for " + ipname, jqXHR.responseText);
|
||||||
|
console.log(exception); // eslint-disable-line no-console
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -717,6 +717,9 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "adlists", "
|
|||||||
<td id="IP" data-order="<?php echo bin2hex(inet_pton($lease["IP"])); ?>"><?php echo $lease["IP"]; ?></td>
|
<td id="IP" data-order="<?php echo bin2hex(inet_pton($lease["IP"])); ?>"><?php echo $lease["IP"]; ?></td>
|
||||||
<td id="HOST"><?php echo $lease["host"]; ?></td>
|
<td id="HOST"><?php echo $lease["host"]; ?></td>
|
||||||
<td>
|
<td>
|
||||||
|
<button type="button" class="btn btn-danger btn-xs" id="removedynamic">
|
||||||
|
<span class="fas fas fa-trash-alt"></span>
|
||||||
|
</button>
|
||||||
<button type="button" id="button" class="btn btn-warning btn-xs" data-static="alert">
|
<button type="button" id="button" class="btn btn-warning btn-xs" data-static="alert">
|
||||||
<span class="fas fas fa-file-import"></span>
|
<span class="fas fas fa-file-import"></span>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user