mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
replace external IP check AJAX #1124
This commit is contained in:
@@ -100,7 +100,7 @@ echo '<div class="box box-solid">
|
|||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-3 sysinfo_network_a">' . lang('Systeminfo_Network_IP') . '</div>
|
<div class="col-sm-3 sysinfo_network_a">' . lang('Systeminfo_Network_IP') . '</div>
|
||||||
<div class="col-sm-9 sysinfo_network_b">' . shell_exec("curl https://ifconfig.co") . '</div>
|
<div class="col-sm-9 sysinfo_network_b" id="external-ip">Loading...</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-3 sysinfo_network_a">' . lang('Systeminfo_Network_IP_Connection') . '</div>
|
<div class="col-sm-3 sysinfo_network_a">' . lang('Systeminfo_Network_IP_Connection') . '</div>
|
||||||
@@ -274,19 +274,35 @@ function renderAvailableIpsTable(allIps, usedIps) {
|
|||||||
|
|
||||||
// INIT
|
// INIT
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
// available IPs
|
||||||
fetchUsedIps(usedIps => {
|
fetchUsedIps(usedIps => {
|
||||||
const allIps = inferNetworkRange(usedIps);
|
const allIps = inferNetworkRange(usedIps);
|
||||||
renderAvailableIpsTable(allIps, usedIps);
|
renderAvailableIpsTable(allIps, usedIps);
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
// Available IPs datatable
|
||||||
$('#networkTable').DataTable({
|
$('#networkTable').DataTable({
|
||||||
searching: true,
|
searching: true,
|
||||||
order: [[0, "desc"]],
|
order: [[0, "desc"]],
|
||||||
initComplete: function(settings, json) {
|
initComplete: function(settings, json) {
|
||||||
hideSpinner(); // Called after the DataTable is fully initialized
|
hideSpinner(); // Called after the DataTable is fully initialized
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// external IP
|
||||||
|
$.ajax({
|
||||||
|
url: 'https://api64.ipify.org?format=json',
|
||||||
|
method: 'GET',
|
||||||
|
timeout: 10000, // 10 seconds timeout
|
||||||
|
success: function (response) {
|
||||||
|
$('#external-ip').text(response.ip);
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
$('#external-ip').text('ERROR');
|
||||||
|
}
|
||||||
|
});
|
||||||
}, 200);
|
}, 200);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user