Browse Source

[BS5] poll host stats if tab is active

FreddleSpl0it 3 years ago
parent
commit
a7a0eef125
1 changed files with 3 additions and 3 deletions
  1. 3 3
      data/web/js/site/debug.js

+ 3 - 3
data/web/js/site/debug.js

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