diff options
author | Alexander Moisseev <moiseev@mezonplus.ru> | 2017-01-09 19:10:38 +0300 |
---|---|---|
committer | Alexander Moisseev <moiseev@mezonplus.ru> | 2017-01-09 19:10:38 +0300 |
commit | 4755206cf264042a1db7b38001df6d8b834e0ed4 (patch) | |
tree | b4b721ee940048a1bb8a0e85f52a2faa74dd4e2f | |
parent | c01f7bf658d8412d8885275a30abea0b6ea3909f (diff) | |
download | rspamd-4755206cf264042a1db7b38001df6d8b834e0ed4.tar.gz rspamd-4755206cf264042a1db7b38001df6d8b834e0ed4.zip |
[WebUI] Fix graph selectors state resetting
on reconnect / reload
Reported by: @denhli
-rw-r--r-- | interface/js/rspamd.js | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/interface/js/rspamd.js b/interface/js/rspamd.js index be757ce4d..9ce9c76cb 100644 --- a/interface/js/rspamd.js +++ b/interface/js/rspamd.js @@ -37,11 +37,11 @@ var checked_server = "All SERVERS"; var timer_id = []; - var selected = []; // Keep graph selectors state + var selData; // Graph's dataset selector state // Bind event handlers to selectors $("#selData").change(function () { - selected.selData = this.value; + selData = this.value; tabClick("#throughput_nav"); }); $("#selConvert").change(function () { @@ -107,13 +107,13 @@ getChart(); break; case "#throughput_nav": - getGraphData(selected.selData); + getGraphData(selData); const autoRefresh = { hourly: 60000, daily: 300000 }; - timer_id.throughput = Visibility.every(autoRefresh[selected.selData] || 3600000, function () { - getGraphData(selected.selData); + timer_id.throughput = Visibility.every(autoRefresh[selData] || 3600000, function () { + getGraphData(selData); }); break; case "#configuration_nav": @@ -654,10 +654,6 @@ height: 370, yAxisLabel: "Message rate, msg/s", - type: selected.selType, - interpolate: selected.selInterpolate, - convert: selected.selConvert, - legend: { space: 140, entries: [{ @@ -684,13 +680,18 @@ function initGraph() { // Get selectors' current state - var selIds = ["selData", "selConvert", "selType", "selInterpolate"]; - selIds.forEach(function (id) { + function getSelector(id) { var e = document.getElementById(id); - selected[id] = e.options[e.selectedIndex].value; - }); + return e.options[e.selectedIndex].value; + } + + selData = getSelector("selData"); - graph = new D3Evolution("graph", graph_options); + graph = new D3Evolution("graph", $.extend({}, graph_options, { + type: getSelector("selType"), + interpolate: getSelector("selInterpolate"), + convert: getSelector("selConvert"), + })); } function getRrdSummary(json) { |