]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] WebUI: Use public getSelector() function 3010/head
authormoisseev <moiseev@mezonplus.ru>
Tue, 20 Aug 2019 16:38:25 +0000 (19:38 +0300)
committermoisseev <moiseev@mezonplus.ru>
Tue, 20 Aug 2019 16:38:25 +0000 (19:38 +0300)
interface/js/app/config.js
interface/js/app/graph.js
interface/js/app/rspamd.js
interface/js/app/symbols.js

index e679780f4f9e4e8f93157608d5b22931a35ab0ec..701640f9155369c98f4797150c7d0cbe0d09af18 100644 (file)
@@ -166,11 +166,7 @@ define(["jquery"],
         ui.setup = function (rspamd) {
         // Modal form for maps
             $(document).on("click", "[data-toggle=\"modal\"]", function () {
-                function getSelector(id) {
-                    var e = document.getElementById(id);
-                    return e.options[e.selectedIndex].value;
-                }
-                var checked_server = getSelector("selSrv");
+                var checked_server = rspamd.getSelector("selSrv");
                 var item = $(this).data("item");
                 rspamd.query("getmap", {
                     headers: {
index 2fd66b5553f32ddd1b5f7b2bff9aea738a148abd..624566a8aafc79d711a1c0a8ec70ceac9f12dab0 100644 (file)
@@ -86,18 +86,12 @@ define(["jquery", "d3evolution", "footable"],
             }
         };
 
-        // Get selectors' current state
-        function getSelector(id) {
-            var e = document.getElementById(id);
-            return e.options[e.selectedIndex].value;
-        }
-
-        function initGraph() {
+        function initGraph(rspamd) {
             var graph = new D3Evolution("graph", $.extend({}, graph_options, {
-                yScale: getSelector("selYScale"),
-                type: getSelector("selType"),
-                interpolate: getSelector("selInterpolate"),
-                convert: getSelector("selConvert"),
+                yScale: rspamd.getSelector("selYScale"),
+                type: rspamd.getSelector("selType"),
+                interpolate: rspamd.getSelector("selInterpolate"),
+                convert: rspamd.getSelector("selConvert"),
             }));
             $("#selYScale").change(function () {
                 graph.yScale(this.value);
@@ -251,7 +245,7 @@ define(["jquery", "d3evolution", "footable"],
             }
 
             if (!graphs.graph) {
-                graphs.graph = initGraph();
+                graphs.graph = initGraph(rspamd);
             }
 
             rspamd.query("graph", {
@@ -297,7 +291,7 @@ define(["jquery", "d3evolution", "footable"],
             });
         };
 
-        ui.setup = function () {
+        ui.setup = function (rspamd) {
             // Handling mouse events on overlapping elements
             $("#rrd-pie").mouseover(function () {
                 $("#rrd-pie").css("z-index", "200");
@@ -308,7 +302,7 @@ define(["jquery", "d3evolution", "footable"],
                 $("#rrd-table_toggle").css("z-index", "0");
             });
 
-            return getSelector("selData");
+            return rspamd.getSelector("selData");
         };
 
         return ui;
index da22495c54738589b6c0d48b0846196172d87750..155a544e1fc42ccc008526cf72440ba6568240a3 100644 (file)
@@ -150,6 +150,7 @@ function ($, D3pie, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_
         return sessionStorage.getItem("Password");
     }
 
+    // Get selectors' current state
     function getSelector(id) {
         var e = document.getElementById(id);
         return e.options[e.selectedIndex].value;
@@ -375,7 +376,7 @@ function ($, D3pie, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_
         tab_history.setup(ui, tables);
         tab_symbols.setup(ui, tables);
         tab_upload.setup(ui, tables);
-        selData = tab_graph.setup();
+        selData = tab_graph.setup(ui);
     };
 
     ui.connect = function () {
index ed0a675838db8bb8dd327e468d8d3e4bfaba1494..a64c7c931ace519523feb0e0eb44e3ba0cac65c7 100644 (file)
@@ -29,11 +29,6 @@ define(["jquery", "footable"],
         "use strict";
         var ui = {};
 
-        function getSelector(id) {
-            var e = document.getElementById(id);
-            return e.options[e.selectedIndex].value;
-        }
-
         function saveSymbols(rspamd, action, id, server) {
             var inputs = $("#" + id + " :input[data-role=\"numerictextbox\"]");
             var url = action;
@@ -62,12 +57,12 @@ define(["jquery", "footable"],
             var digits = Number(number).toFixed(20).replace(/^-?\d*\.?|0+$/g, "").length;
             return (digits === 0 || digits > 4) ? 0.1 : 1.0 / Math.pow(10, digits);
         }
-        function process_symbols_data(data) {
+        function process_symbols_data(rspamd, data) {
             var items = [];
             var lookup = {};
             var freqs = [];
             var distinct_groups = [];
-            var selected_server = getSelector("selSrv");
+            var selected_server = rspamd.getSelector("selSrv");
 
             data.forEach(function (group) {
                 group.rules.forEach(function (item) {
@@ -147,7 +142,7 @@ define(["jquery", "footable"],
             rspamd.query("symbols", {
                 success: function (json) {
                     var data = json[0].data;
-                    var items = process_symbols_data(data);
+                    var items = process_symbols_data(rspamd, data);
 
                     /* eslint-disable consistent-this, no-underscore-dangle, one-var-declaration-per-line */
                     FooTable.groupFilter = FooTable.Filtering.extend({
@@ -250,10 +245,10 @@ define(["jquery", "footable"],
         ui.setup = function (rspamd, tables) {
             $("#updateSymbols").on("click", function (e) {
                 e.preventDefault();
-                var checked_server = getSelector("selSrv");
+                var checked_server = rspamd.getSelector("selSrv");
                 rspamd.query("symbols", {
                     success: function (data) {
-                        var items = process_symbols_data(data[0].data)[0];
+                        var items = process_symbols_data(rspamd, data[0].data)[0];
                         tables.symbols.rows.load(items);
                     },
                     server: (checked_server === "All SERVERS") ? "local" : checked_server