diff options
author | Alexander Moisseev <moiseev@mezonplus.ru> | 2018-08-11 17:52:21 +0300 |
---|---|---|
committer | Alexander Moisseev <moiseev@mezonplus.ru> | 2018-08-11 17:52:21 +0300 |
commit | bcbc713ad977e1b8f74c9958117417bddb5e8e12 (patch) | |
tree | 8037d40e2a8c7275cebcb69a4b2557779ca69688 /interface/js | |
parent | bb7e01011c80eb0e6961041aa390860eef27acac (diff) | |
download | rspamd-bcbc713ad977e1b8f74c9958117417bddb5e8e12.tar.gz rspamd-bcbc713ad977e1b8f74c9958117417bddb5e8e12.zip |
[Minor] Combine saveMap functions
Diffstat (limited to 'interface/js')
-rw-r--r-- | interface/js/app/config.js | 50 |
1 files changed, 11 insertions, 39 deletions
diff --git a/interface/js/app/config.js b/interface/js/app/config.js index 19bc234ec..1e0aa2829 100644 --- a/interface/js/app/config.js +++ b/interface/js/app/config.js @@ -27,36 +27,6 @@ define(["jquery"], "use strict"; var ui = {}; - function save_map_success(rspamd) { - rspamd.alertMessage("alert-modal alert-success", "Map data successfully saved"); - $("#modalDialog").modal("hide"); - } - function save_map_error(rspamd, serv, jqXHR, textStatus, errorThrown) { - var serv_name = (typeof serv === "string") ? serv : serv.name; - rspamd.alertMessage("alert-modal alert-error", "Save map error on " + - serv_name + ": " + errorThrown); - } - // @upload map from modal - function saveMap(rspamd, action, id) { - var data = $("#" + id).find("textarea").val(); - $.ajax({ - data: data, - dataType: "text", - type: "POST", - jsonp: false, - url: action, - beforeSend: function (xhr) { - xhr.setRequestHeader("Password", rspamd.getPassword()); - xhr.setRequestHeader("Map", id); - xhr.setRequestHeader("Debug", true); - }, - error: function (jqXHR) { - save_map_error(rspamd, "local", null, null, jqXHR.statusText); - }, - success: function () { save_map_success(rspamd); }, - }); - } - function loadActionsFromForm() { var values = []; var inputs = $("#actionsForm :input[data-id=\"action\"]"); @@ -240,20 +210,15 @@ define(["jquery"], $("#modalBody form").hide(); }); // @save forms from modal - $("#modalSave").on("click", function () { - var form = $("#modalBody").children().filter(":visible"); - var action = $(form).attr("action"); - var id = $(form).attr("id"); - saveMap(rspamd, action, id); - }); - $("#modalSaveAll").on("click", function () { + function saveMap(server) { var form = $("#modalBody").children().filter(":visible"); var action = $(form).attr("action"); var id = $(form).attr("id"); var data = $("#" + id).find("textarea").val(); rspamd.query(action, { success: function () { - save_map_success(rspamd); + rspamd.alertMessage("alert-success", "Map data successfully saved"); + $("#modalDialog").modal("hide"); }, errorMessage: "Save map error", method: "POST", @@ -263,8 +228,15 @@ define(["jquery"], params:{ data: data, dataType: "text", - } + }, + server: server }); + } + $("#modalSave").on("click", function () { + saveMap(); + }); + $("#modalSaveAll").on("click", function () { + saveMap("All SERVERS"); }); }; |