diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-01 15:56:33 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-01 15:56:33 +0000 |
commit | ab114be5a27a674306f0584df00457370d082520 (patch) | |
tree | 4b5103b7d20b4d59644f8ddf3b3012fd0a758c6f | |
parent | c7a1f12cf15d6141f1fa63ac8610d9ba175ea62d (diff) | |
parent | 0d65bb8602a7d2398caec8dd97501e8391b71fe4 (diff) | |
download | rspamd-ab114be5a27a674306f0584df00457370d082520.tar.gz rspamd-ab114be5a27a674306f0584df00457370d082520.zip |
Merge pull request #1296 from moisseev/visibility
[WebUI] Add Throughput graph autorefreshing (#820)
-rw-r--r-- | interface/js/rspamd.js | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/interface/js/rspamd.js b/interface/js/rspamd.js index 2ea7eeca7..6c0af1dc6 100644 --- a/interface/js/rspamd.js +++ b/interface/js/rspamd.js @@ -32,14 +32,14 @@ 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); @@ -51,6 +51,12 @@ 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'); @@ -89,13 +95,20 @@ 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(); |