[BS5] poll host stats if tab is active

This commit is contained in:
FreddleSpl0it 2022-08-11 16:11:13 +02:00
parent 5d35af9d69
commit a7a0eef125

View File

@ -43,8 +43,6 @@ $(document).ready(function() {
createNetAndDiskChart(); createNetAndDiskChart();
// check for new version // check for new version
check_update(mailcow_info.version_tag, mailcow_info.project_url); check_update(mailcow_info.version_tag, mailcow_info.project_url);
// update system stats
update_stats();
}); });
jQuery(function($){ jQuery(function($){
if (localStorage.getItem("current_page") === null) { if (localStorage.getItem("current_page") === null) {
@ -1006,6 +1004,9 @@ jQuery(function($){
onVisible("[id^=netfilter_log]", () => draw_netfilter_logs()); onVisible("[id^=netfilter_log]", () => draw_netfilter_logs());
onVisible("[id^=rspamd_history]", () => draw_rspamd_history()); onVisible("[id^=rspamd_history]", () => draw_rspamd_history());
onVisible("[id^=rspamd_donut]", () => rspamd_pie_graph()); onVisible("[id^=rspamd_donut]", () => rspamd_pie_graph());
// start polling stats if tab is active
onVisible("[id^=tab-containers]", () => update_stats());
}); });
@ -1013,7 +1014,6 @@ jQuery(function($){
function update_stats(prev_stats = null){ function update_stats(prev_stats = null){
if (!$('#tab-containers').hasClass('active')) { if (!$('#tab-containers').hasClass('active')) {
// tab not active - dont fetch stats - run again in n seconds // tab not active - dont fetch stats - run again in n seconds
setTimeout(update_stats, 5000);
return; return;
} }