]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Use query function to get actions, 2377/head
authorAlexander Moisseev <moiseev@mezonplus.ru>
Fri, 27 Jul 2018 10:18:21 +0000 (13:18 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Fri, 27 Jul 2018 10:18:21 +0000 (13:18 +0300)
get actions from "local" if "All SERVERS" option is selected,
sort conditional operators by action index

interface/js/app/config.js
interface/js/app/rspamd.js

index ab0aa937125882f8b9f776f4b87891d0c993ad97..b0ba4fcc8e7acad6207391e12a55dc995acd2c2b 100644 (file)
@@ -135,29 +135,21 @@ define(["jquery"],
             return JSON.stringify(values);
         }
 
-        function getActions(rspamd) {
-            $.ajax({
-                dataType: "json",
-                type: "GET",
-                url: "actions",
-                jsonp: false,
-                beforeSend: function (xhr) {
-                    xhr.setRequestHeader("Password", rspamd.getPassword());
-                },
-                success: function (data) {
-                // Order of sliders greylist -> probable spam -> rewrite subject -> spam
+        ui.getActions = function getActions(rspamd, checked_server) {
+            rspamd.query("actions",
+                function (data) {
                     $("#actionsBody").empty();
                     $("#actionsForm").empty();
                     var items = [];
-                    $.each(data, function (i, item) {
+                    $.each(data[0].data, function (i, item) {
                         var idx = -1;
                         var label;
-                        if (item.action === "add header") {
-                            label = "Probably Spam";
-                            idx = 1;
-                        } else if (item.action === "greylist") {
+                        if (item.action === "greylist") {
                             label = "Greylist";
                             idx = 0;
+                        } else if (item.action === "add header") {
+                            label = "Probably Spam";
+                            idx = 1;
                         } else if (item.action === "rewrite subject") {
                             label = "Rewrite subject";
                             idx = 2;
@@ -230,8 +222,9 @@ define(["jquery"],
                         saveActions("All SERVERS");
                     });
                 },
-            });
-        }
+                null, "GET", {}, {}, {}, (checked_server === "All SERVERS") ? "local" : checked_server
+            );
+        };
 
         // @upload edited actions
         ui.setup = function (rspamd) {
@@ -278,7 +271,6 @@ define(["jquery"],
             });
         };
 
-        ui.getActions = getActions;
         ui.getMaps = getMaps;
 
         return ui;
index 162717288a86088b0b4fda39bc21ead7a1e1e3f1..909e349007aab008dda70a54926868912011ad98 100644 (file)
@@ -119,7 +119,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
             });
             break;
         case "#configuration_nav":
-            tab_config.getActions(ui);
+            tab_config.getActions(ui, checked_server);
             tab_config.getMaps(ui);
             break;
         case "#symbols_nav":