]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Use query function to get and update symbols
authorAlexander Moisseev <moiseev@mezonplus.ru>
Sat, 28 Jul 2018 07:24:30 +0000 (10:24 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Sat, 28 Jul 2018 07:24:30 +0000 (10:24 +0300)
interface/js/app/rspamd.js
interface/js/app/symbols.js

index 909e349007aab008dda70a54926868912011ad98..b092d537c2dcabd69a863b84d3c94eb4d49e51b9 100644 (file)
@@ -123,7 +123,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
             tab_config.getMaps(ui);
             break;
         case "#symbols_nav":
-            tab_symbols.getSymbols(ui, tables, checked_server);
+            tab_symbols.getSymbols(ui, checked_server);
             break;
         case "#history_nav":
             tab_history.getHistory(ui, tables, neighbours, checked_server);
@@ -278,7 +278,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
             }
         });
         tab_config.setup(ui);
-        tab_symbols.setup(ui, tables);
+        tab_symbols.setup(ui);
         tab_upload.setup(ui);
         selData = tab_graph.setup();
     };
index 90ae71cf03cddfe8f72d45c3d355a499e55d5939..ca5bb3c12ec0b73e1097853258eba23c75676a8c 100644 (file)
@@ -135,17 +135,10 @@ define(["jquery", "footable"],
             return [items, distinct_groups];
         }
         // @get symbols into modal form
-        ui.getSymbols = function (rspamd) {
-
-            $.ajax({
-                dataType: "json",
-                type: "GET",
-                url: "symbols",
-                jsonp: false,
-                beforeSend: function (xhr) {
-                    xhr.setRequestHeader("Password", rspamd.getPassword());
-                },
-                success: function (data) {
+        ui.getSymbols = function (rspamd, checked_server) {
+            rspamd.query("symbols",
+                function (json) {
+                    var data = json[0].data;
                     var items = process_symbols_data(data);
                     FooTable.groupFilter = FooTable.Filtering.extend({
                         construct : function (instance) {
@@ -231,10 +224,11 @@ define(["jquery", "footable"],
                         }
                     });
                 },
-                error: function (data) {
+                function (data) {
                     rspamd.alertMessage("alert-modal alert-error", data.statusText);
-                }
-            });
+                },
+                "GET", {}, {}, {}, (checked_server === "All SERVERS") ? "local" : checked_server
+            );
             $("#symbolsTable")
                 .off("click", ":button")
                 .on("click", ":button", function () {
@@ -245,24 +239,24 @@ define(["jquery", "footable"],
         };
 
         ui.setup = function (rspamd) {
+            function getSelector(id) {
+                var e = document.getElementById(id);
+                return e.options[e.selectedIndex].value;
+            }
+
             $("#updateSymbols").on("click", function (e) {
                 e.preventDefault();
-                $.ajax({
-                    dataType: "json",
-                    type: "GET",
-                    jsonp: false,
-                    url: "symbols",
-                    beforeSend: function (xhr) {
-                        xhr.setRequestHeader("Password", rspamd.getPassword());
-                    },
-                    success: function (data) {
-                        var items = process_symbols_data(data)[0];
+                var checked_server = getSelector("selSrv");
+                rspamd.query("symbols",
+                    function (data) {
+                        var items = process_symbols_data(data[0].data)[0];
                         ft.symbols.rows.load(items);
                     },
-                    error: function (data) {
+                    function (data) {
                         rspamd.alertMessage("alert-modal alert-error", data.statusText);
-                    }
-                });
+                    },
+                    "GET", {}, {}, {}, (checked_server === "All SERVERS") ? "local" : checked_server
+                );
             });
         };