commit 94744ca: [WebUI] Disable Refresh until ongoing requests

moisseev moiseev at mezonplus.ru
Fri Nov 20 11:07:09 UTC 2020


Author: moisseev
Date: 2020-11-20 13:14:54 +0300
URL: https://github.com/rspamd/rspamd/commit/94744ca826eec8bb8d755af28bca63a350104f60 (refs/pull/3555/head)

[WebUI] Disable Refresh until ongoing requests
are finished

---
 interface/js/app/graph.js   | 1 +
 interface/js/app/history.js | 1 +
 interface/js/app/rspamd.js  | 7 ++++++-
 interface/js/app/stats.js   | 1 +
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/interface/js/app/graph.js b/interface/js/app/graph.js
index d2e3c5ac6..54daf79c1 100644
--- a/interface/js/app/graph.js
+++ b/interface/js/app/graph.js
@@ -285,6 +285,7 @@ define(["jquery", "d3evolution", "footable"],
                     }
                     updateWidgets(data);
                 },
+                complete: function () { $("#refresh").removeAttr("disabled").removeClass("disabled"); },
                 errorMessage: "Cannot receive throughput data",
                 errorOnceId: "alerted_graph_",
                 data: {type:type}
diff --git a/interface/js/app/history.js b/interface/js/app/history.js
index e9642d26a..edf9e19cf 100644
--- a/interface/js/app/history.js
+++ b/interface/js/app/history.js
@@ -370,6 +370,7 @@ define(["jquery", "footable"],
                         rspamd.destroyTable("history");
                     }
                 },
+                complete: function () { $("#refresh").removeAttr("disabled").removeClass("disabled"); },
                 errorMessage: "Cannot receive history",
             });
         };
diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js
index 3da8a82ed..7fb985347 100644
--- a/interface/js/app/rspamd.js
+++ b/interface/js/app/rspamd.js
@@ -91,7 +91,7 @@ function ($, D3pie, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_
         var tab_id = id;
         if ($(id).attr("disabled")) return;
         var navBarControls = $("#selSrv, #navBar li, #navBar a, #navBar button");
-        navBarControls.attr("disabled", true).addClass("disabled", true);
+        if (id !== "#autoRefresh") navBarControls.attr("disabled", true).addClass("disabled", true);
 
         stopTimers();
 
@@ -126,6 +126,8 @@ function ($, D3pie, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_
             if (!refreshInterval) return;
             timer_id[timer] = Visibility.every(refreshInterval, function () {
                 countdown(refreshInterval);
+                if ($("#refresh").attr("disabled")) return;
+                $("#refresh").attr("disabled", true).addClass("disabled", true);
                 callback();
             });
         }
@@ -200,6 +202,9 @@ function ($, D3pie, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_
         }
 
         setTimeout(function () {
+            // Do not enable Refresh button until AJAX requests to all neighbours are finished
+            if (tab_id === "#history_nav") navBarControls = $(navBarControls).not("#refresh");
+
             navBarControls.removeAttr("disabled").removeClass("disabled");
         }, (id === "#autoRefresh") ? 0 : 1000);
     }
diff --git a/interface/js/app/stats.js b/interface/js/app/stats.js
index 582c5017f..b674d25c3 100644
--- a/interface/js/app/stats.js
+++ b/interface/js/app/stats.js
@@ -367,6 +367,7 @@ define(["jquery", "d3pie"],
                             });
                         }, promises.length ? 100 : 0);
                     },
+                    complete: function () { $("#refresh").removeAttr("disabled").removeClass("disabled"); },
                     errorMessage: "Cannot receive stats data",
                     errorOnceId: "alerted_stats_",
                     server: "All SERVERS"


More information about the Commits mailing list