]> source.dussan.org Git - rspamd.git/commitdiff
[WebUI] Add Throughput graph autorefreshing (#820) 1296/head
authorAlexander Moisseev <moiseev@mezonplus.ru>
Sun, 1 Jan 2017 15:13:22 +0000 (18:13 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Sun, 1 Jan 2017 15:13:22 +0000 (18:13 +0300)
interface/js/rspamd.js

index 2ea7eeca761d29023f8cbed5738d7dd300b5fcf0..6c0af1dc647cf16d1c6fc8c8376daee376f4dbba 100644 (file)
         var graph;
         var symbols;
         var read_only = false;
-        var stat_timeout;
 
+        var timer_id = [];
         var selected = []; // Keep graph selectors state
 
         // Bind event handlers to selectors
         $("#selData").change(function () {
             selected.selData = this.value;
-            getGraphData(this.value);
+            tabClick("#throughput_nav");
         });
         $("#selConvert").change(function () {
             graph.convert(this.value);
             graph.interpolate(this.value);
         });
 
+        function stopTimers() {
+            for (var key in timer_id) {
+                Visibility.stop(timer_id[key]);
+            }
+        }
+
         function disconnect() {
             if (pie) {
                 pie.destroy();
@@ -69,7 +75,7 @@
                 symbols.destroy();
                 symbols = null;
             }
-            Visibility.stop(stat_timeout);
+            stopTimers();
             cleanCredentials();
             connectRSPAMD();
             // window.location.reload();
@@ -80,7 +86,7 @@
             if ($(tab_id).attr('disabled')) return;
             $(tab_id).attr('disabled', true);
 
-            Visibility.stop(stat_timeout);
+            stopTimers();
 
             if (tab_id === "#refresh") {
                 tab_id = "#" + $('.navbar-nav .active > a' ).attr('id');
             switch (tab_id) {
                 case "#status_nav":
                     statWidgets();
-                    stat_timeout = Visibility.every(10000, function () {
+                    timer_id.status = Visibility.every(10000, function () {
                         statWidgets();
                     });
                     getChart();
                     break;
                 case "#throughput_nav":
                     getGraphData(selected.selData);
+                    const autoRefresh = {
+                        hourly: 60000,
+                        daily: 300000
+                    };
+                    timer_id.throughput = Visibility.every(autoRefresh[selected.selData] || 3600000, function () {
+                        getGraphData(selected.selData);
+                    });
                     break;
                 case "#configuration_nav":
                     getActions();