[Web] load public ip on click and add curl timeout
This commit is contained in:
parent
3f1a5af88b
commit
9727e4084f
@ -51,7 +51,40 @@ $(document).ready(function() {
|
||||
showVersionModal("Version " + mailcow_info.version_tag, mailcow_info.version_tag);
|
||||
})
|
||||
// get public ips
|
||||
get_public_ips();
|
||||
$("#host_show_ip").click(function(){
|
||||
$("#host_show_ip").find(".text").addClass("d-none");
|
||||
$("#host_show_ip").find(".spinner-border").removeClass("d-none");
|
||||
|
||||
window.fetch("/api/v1/get/status/host/ip", { method:'GET', cache:'no-cache' }).then(function(response) {
|
||||
return response.json();
|
||||
}).then(function(data) {
|
||||
console.log(data);
|
||||
|
||||
// display host ips
|
||||
if (data.ipv4)
|
||||
$("#host_ipv4").text(data.ipv4);
|
||||
if (data.ipv6)
|
||||
$("#host_ipv6").text(data.ipv6);
|
||||
|
||||
$("#host_show_ip").addClass("d-none");
|
||||
$("#host_show_ip").find(".text").removeClass("d-none");
|
||||
$("#host_show_ip").find(".spinner-border").addClass("d-none");
|
||||
$("#host_ipv4").removeClass("d-none");
|
||||
$("#host_ipv6").removeClass("d-none");
|
||||
$("#host_ipv6").removeClass("text-danger");
|
||||
$("#host_ipv4").addClass("d-block");
|
||||
$("#host_ipv6").addClass("d-block");
|
||||
}).catch(function(error){
|
||||
console.log(error);
|
||||
|
||||
$("#host_ipv6").removeClass("d-none");
|
||||
$("#host_ipv6").addClass("d-block");
|
||||
$("#host_ipv6").addClass("text-danger");
|
||||
$("#host_ipv6").text(lang_debug.error_show_ip);
|
||||
$("#host_show_ip").find(".text").removeClass("d-none");
|
||||
$("#host_show_ip").find(".spinner-border").addClass("d-none");
|
||||
});
|
||||
});
|
||||
update_container_stats();
|
||||
});
|
||||
jQuery(function($){
|
||||
@ -1224,20 +1257,6 @@ function update_container_stats(timeout=5){
|
||||
// run again in n seconds
|
||||
setTimeout(update_container_stats, timeout * 1000);
|
||||
}
|
||||
// get public ips
|
||||
function get_public_ips(){
|
||||
window.fetch("/api/v1/get/status/host/ip", {method:'GET',cache:'no-cache'}).then(function(response) {
|
||||
return response.json();
|
||||
}).then(function(data) {
|
||||
console.log(data);
|
||||
|
||||
// display host ips
|
||||
if (data.ipv4)
|
||||
$("#host_ipv4").text(data.ipv4);
|
||||
if (data.ipv6)
|
||||
$("#host_ipv6").text(data.ipv6);
|
||||
});
|
||||
}
|
||||
// format hosts uptime seconds to readable string
|
||||
function formatUptime(seconds){
|
||||
seconds = Number(seconds);
|
||||
|
@ -1548,10 +1548,14 @@ if (isset($_GET['query'])) {
|
||||
curl_setopt($curl, CURLOPT_URL, 'http://ipv4.mailcow.email');
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curl, CURLOPT_POST, 0);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
$ipv4 = curl_exec($curl);
|
||||
curl_setopt($curl, CURLOPT_URL, 'http://ipv6.mailcow.email');
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curl, CURLOPT_POST, 0);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
$ipv6 = curl_exec($curl);
|
||||
$ips = array(
|
||||
"ipv4" => $ipv4,
|
||||
|
@ -494,6 +494,7 @@
|
||||
"current_time": "Systemzeit",
|
||||
"disk_usage": "Festplattennutzung",
|
||||
"docs": "Dokumente",
|
||||
"error_show_ip": "konnte die öffentlichen IP Adressen nicht auflösen",
|
||||
"external_logs": "Externe Logs",
|
||||
"history_all_servers": "History (alle Server)",
|
||||
"in_memory_logs": "In-memory Logs",
|
||||
@ -506,6 +507,7 @@
|
||||
"online_users": "Benutzer online",
|
||||
"restart_container": "Neustart",
|
||||
"service": "Dienst",
|
||||
"show_ip": "Zeige öffentliche IP",
|
||||
"size": "Größe",
|
||||
"solr_dead": "Solr startet, ist deaktiviert oder temporär nicht erreichbar.",
|
||||
"solr_status": "Solr Status",
|
||||
|
@ -497,6 +497,7 @@
|
||||
"current_time": "System Time",
|
||||
"disk_usage": "Disk usage",
|
||||
"docs": "Docs",
|
||||
"error_show_ip": "Could not resolve the public IP addresses",
|
||||
"external_logs": "External logs",
|
||||
"history_all_servers": "History (all servers)",
|
||||
"in_memory_logs": "In-memory logs",
|
||||
@ -509,6 +510,7 @@
|
||||
"online_users": "Users online",
|
||||
"restart_container": "Restart",
|
||||
"service": "Service",
|
||||
"show_ip": "Show public IP",
|
||||
"size": "Size",
|
||||
"solr_dead": "Solr is starting, disabled or died.",
|
||||
"solr_status": "Solr status",
|
||||
|
@ -52,8 +52,14 @@
|
||||
<tr>
|
||||
<td>IPs</td>
|
||||
<td class="text-break">
|
||||
<span class="d-block" id="host_ipv4">-</span>
|
||||
<span class="d-block" id="host_ipv6">-</span>
|
||||
<span class="d-none" id="host_ipv4">-</span>
|
||||
<span class="d-none mb-2" id="host_ipv6">-</span>
|
||||
<button class="d-block btn btn-primary btn-sm" id="host_show_ip">
|
||||
<span class="text">{{ lang.debug.show_ip }}</span>
|
||||
<div class="spinner-border spinner-border-sm d-none" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
Loading…
Reference in New Issue
Block a user