]> source.dussan.org Git - rspamd.git/commitdiff
[WebUI] Add History tab autorefreshing
authormoisseev <moiseev@mezonplus.ru>
Thu, 19 Nov 2020 08:06:54 +0000 (11:06 +0300)
committermoisseev <moiseev@mezonplus.ru>
Thu, 19 Nov 2020 08:06:54 +0000 (11:06 +0300)
Issue: #820

interface/index.html
interface/js/app/rspamd.js

index a3810804bbe95b6312090e83e48761ae5a4c6b06..ea118dcfc5eca8d39d3601dccd99a89ae1e210a5 100644 (file)
                                <div class="dropdown-divider preset" role="separator"></div>
                                <a class="dropdown-item preset" href="#" data-value="3600000">1 hour</a>
 
+                               <a class="dropdown-item history active" href="#" data-value=null>Disable</a>
+                               <div class="dropdown-divider history" role="separator"></div>
+                               <a class="dropdown-item history" href="#" data-value="10000">10 seconds</a>
+                               <a class="dropdown-item history" href="#" data-value="30000">30 seconds</a>
+                               <div class="dropdown-divider history" role="separator"></div>
+                               <a class="dropdown-item history" href="#" data-value="60000">1 minute</a>
+                               <a class="dropdown-item history" href="#" data-value="600000">10 minutes</a>
+                               <a class="dropdown-item history" href="#" data-value="1800000">30 minutes</a>
+                               <div class="dropdown-divider history" role="separator"></div>
+                               <a class="dropdown-item history" href="#" data-value="3600000">1 hour</a>
+
                                <a class="dropdown-item dynamic" href="#" data-value=null>Disable</a>
                                <div class="dropdown-divider dynamic" role="separator"></div>
                                <a class="dropdown-item dynamic active" href="#" id="dynamic-item" data-value="3600000">1 hour</a>
index 360ba603e1d778a387380da3eeffbec6df092e42..5312efa5185f4dde30eaad8b8f69e6856c24bf56 100644 (file)
@@ -145,6 +145,7 @@ function ($, D3pie, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_
                     if (id !== "#autoRefresh") tab_stat.statWidgets(ui, graphs, checked_server);
 
                     $(".preset").show();
+                    $(".history").hide();
                     $(".dynamic").hide();
                 }());
                 break;
@@ -165,6 +166,7 @@ function ($, D3pie, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_
                     if (id !== "#autoRefresh") tab_graph.draw(ui, graphs, tables, neighbours, checked_server, selData);
 
                     $(".preset").hide();
+                    $(".history").hide();
                     $(".dynamic").show();
                 }());
                 break;
@@ -176,8 +178,20 @@ function ($, D3pie, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_
                 tab_symbols.getSymbols(ui, tables, checked_server);
                 break;
             case "#history_nav":
-                tab_history.getHistory(ui, tables);
-                tab_history.getErrors(ui, tables);
+                (function () {
+                    function getHistoryAndErrors() {
+                        tab_history.getHistory(ui, tables);
+                        tab_history.getErrors(ui, tables);
+                    }
+                    var refreshInterval = $(".dropdown-menu a.active.history").data("value");
+                    setAutoRefresh(refreshInterval, "history",
+                        function () { return getHistoryAndErrors(); });
+                    if (id !== "#autoRefresh") getHistoryAndErrors();
+
+                    $(".preset").hide();
+                    $(".history").show();
+                    $(".dynamic").hide();
+                }());
                 break;
             case "#disconnect":
                 disconnect();
@@ -414,7 +428,7 @@ function ($, D3pie, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_
         $(".dropdown-menu a").click(function (e) {
             e.preventDefault();
             var classList = $(this).attr("class");
-            var menuClass = (/\b(?:dynamic|preset)\b/).exec(classList)[0];
+            var menuClass = (/\b(?:dynamic|history|preset)\b/).exec(classList)[0];
             $(".dropdown-menu a.active." + menuClass).removeClass("active");
             $(this).addClass("active");
             tabClick("#autoRefresh");