]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Use query function to get maps 2398/head
authorAlexander Moisseev <moiseev@mezonplus.ru>
Sun, 5 Aug 2018 10:07:59 +0000 (13:07 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Sun, 5 Aug 2018 10:07:59 +0000 (13:07 +0300)
interface/js/app/config.js
interface/js/app/rspamd.js

index b98aed4c30276365b8efd5c4deff07dc4c545650..19bc234ecaadbcb9ba690f121c0008464a34df64 100644 (file)
@@ -57,35 +57,6 @@ define(["jquery"],
             });
         }
 
-        // @get map by id
-        function getMapById(rspamd, item) {
-            return $.ajax({
-                dataType: "text",
-                url: "getmap",
-                jsonp: false,
-                beforeSend: function (xhr) {
-                    xhr.setRequestHeader("Password", rspamd.getPassword());
-                    xhr.setRequestHeader("Map", item.map);
-                },
-                error: function () {
-                    rspamd.alertMessage("alert-error", "Cannot receive maps data");
-                },
-                success: function (text) {
-                    var disabled = "";
-                    if ((item.editable === false || rspamd.read_only)) {
-                        disabled = "disabled=\"disabled\"";
-                    }
-
-                    $("#" + item.map).remove();
-                    $("<form class=\"form-horizontal form-map\" method=\"post\" action=\"savemap\" data-type=\"map\" id=\"" +
-                    item.map + "\" style=\"display:none\">" +
-                    "<textarea class=\"list-textarea\"" + disabled + ">" + text +
-                    "</textarea>" +
-                    "</form").appendTo("#modalBody");
-                }
-            });
-        }
-
         function loadActionsFromForm() {
             var values = [];
             var inputs = $("#actionsForm :input[data-id=\"action\"]");
@@ -225,22 +196,42 @@ define(["jquery"],
         };
 
         // @upload edited actions
-        ui.setup = function (rspamd) {
+        ui.setup = function (rspamd, checked_server) {
         // Modal form for maps
             $(document).on("click", "[data-toggle=\"modal\"]", function () {
                 var item = $(this).data("item");
-                getMapById(rspamd, item).done(function () {
-                    $("#modalTitle").html(item.uri);
-                    $("#" + item.map).first().show();
-                    $("#modalDialog .progress").hide();
-                    $("#modalDialog").modal({backdrop: true, keyboard: "show", show: true});
-                    if (item.editable === false) {
-                        $("#modalSave").hide();
-                        $("#modalSaveAll").hide();
-                    } else {
-                        $("#modalSave").show();
-                        $("#modalSaveAll").show();
-                    }
+                rspamd.query("getmap", {
+                    headers: {
+                        Map: item.map
+                    },
+                    success: function (data) {
+                        var disabled = "";
+                        var text = data[0].data;
+                        if ((item.editable === false || rspamd.read_only)) {
+                            disabled = "disabled=\"disabled\"";
+                        }
+
+                        $("#" + item.map).remove();
+                        $("<form id=\"" + item.map + "\" class=\"form-horizontal form-map\" style=\"display:none\"" +
+                        " data-type=\"map\" action=\"savemap\" method=\"post\">" +
+                        "<textarea class=\"list-textarea\"" + disabled + ">" + text +
+                        "</textarea>" +
+                        "</form>").appendTo("#modalBody");
+
+                        $("#modalTitle").html(item.uri);
+                        $("#" + item.map).first().show();
+                        $("#modalDialog .progress").hide();
+                        $("#modalDialog").modal({backdrop: true, keyboard: "show", show: true});
+                        if (item.editable === false) {
+                            $("#modalSave").hide();
+                            $("#modalSaveAll").hide();
+                        } else {
+                            $("#modalSave").show();
+                            $("#modalSaveAll").show();
+                        }
+                    },
+                    errorMessage: "Cannot receive maps data",
+                    server: (checked_server === "All SERVERS") ? "local" : checked_server
                 });
                 return false;
             });
index 70f6fbfd5a247e3ab11c0c59a321b0a938a9c199..e983e4074335b261cff20be63b91583d7e0af9a6 100644 (file)
@@ -286,7 +286,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
                 tabClick("#status_nav");
             }
         });
-        tab_config.setup(ui);
+        tab_config.setup(ui, checked_server);
         tab_symbols.setup(ui);
         tab_upload.setup(ui);
         selData = tab_graph.setup();