From 85719f70c71fb5239f1c890bc20984170ada900b Mon Sep 17 00:00:00 2001 From: Alexander Moisseev Date: Tue, 21 Feb 2017 11:51:48 +0300 Subject: [PATCH] [WebUI] Fix graph dataset selector initialization --- interface/js/app/graph.js | 43 ++++++++++++++++++-------------------- interface/js/app/rspamd.js | 4 ++-- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/interface/js/app/graph.js b/interface/js/app/graph.js index 86f7ca352..70a510bc3 100644 --- a/interface/js/app/graph.js +++ b/interface/js/app/graph.js @@ -82,12 +82,13 @@ function($, D3Evolution, unused) { } }; + // Get selectors' current state + function getSelector(id) { + var e = document.getElementById(id); + return e.options[e.selectedIndex].value; + } + function initGraph() { - // Get selectors' current state - function getSelector(id) { - var e = document.getElementById(id); - return e.options[e.selectedIndex].value; - } var graph = new D3Evolution("graph", $.extend({}, graph_options, { type: getSelector("selType"), interpolate: getSelector("selInterpolate"), @@ -148,16 +149,6 @@ function($, D3Evolution, unused) { }); } - // Handling mouse events on overlapping elements - $("#rrd-pie").mouseover(function () { - $("#rrd-pie").css("z-index", "200"); - $("#rrd-table_toggle").css("z-index", "300"); - }); - $("#rrd-table_toggle").mouseover(function () { - $("#rrd-pie").css("z-index", "0"); - $("#rrd-table_toggle").css("z-index", "0"); - }); - var interface = {}; interface.draw = function(rspamd, graphs, neighbours, checked_server, type) { @@ -180,14 +171,6 @@ function($, D3Evolution, unused) { graphs.graph = initGraph(); } - if (type === undefined) { - function getSelector(id) { - var e = document.getElementById(id); - return e.options[e.selectedIndex].value; - } - type = getSelector("selData"); - } - if (checked_server === "All SERVERS") { rspamd.queryNeighbours("graph", function (req_data) { var neighbours_data = req_data @@ -257,5 +240,19 @@ function($, D3Evolution, unused) { }); }; + interface.setup = function() { + // Handling mouse events on overlapping elements + $("#rrd-pie").mouseover(function () { + $("#rrd-pie").css("z-index", "200"); + $("#rrd-table_toggle").css("z-index", "300"); + }); + $("#rrd-table_toggle").mouseover(function () { + $("#rrd-pie").css("z-index", "0"); + $("#rrd-table_toggle").css("z-index", "0"); + }); + + return getSelector("selData"); + }; + return interface; }); diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js index 13ffaba49..598112e9b 100644 --- a/interface/js/app/rspamd.js +++ b/interface/js/app/rspamd.js @@ -181,7 +181,6 @@ define(['jquery', 'd3pie', 'visibility', 'app/stats', 'app/graph', 'app/config', // Public functions interface.alertMessage = alertMessage; interface.setup = function() { - // Bind event handlers to selectors $("#selData").change(function () { selData = this.value; tabClick("#throughput_nav"); @@ -221,7 +220,8 @@ define(['jquery', 'd3pie', 'visibility', 'app/stats', 'app/graph', 'app/config', tab_config.setup(interface); tab_symbols.setup(interface, tables); tab_history.setup(interface, tables); - tab_upload.setup(interface) + tab_upload.setup(interface); + selData = tab_graph.setup(); }; interface.connect = function() { -- 2.39.5