diff options
author | moisseev <moiseev@mezonplus.ru> | 2020-07-10 20:12:40 +0300 |
---|---|---|
committer | moisseev <moiseev@mezonplus.ru> | 2020-07-10 20:12:40 +0300 |
commit | f8d9c24ab8d506f2d70cf994cd3dc5a489eaa127 (patch) | |
tree | ec1620afdf7071868330edc5a0e1cddd147cceb5 /interface/js | |
parent | 9924aec4b944ef7a880f5cbd9979e63570883f5c (diff) | |
download | rspamd-f8d9c24ab8d506f2d70cf994cd3dc5a489eaa127.tar.gz rspamd-f8d9c24ab8d506f2d70cf994cd3dc5a489eaa127.zip |
[WebUI] Rework maps modal
Diffstat (limited to 'interface/js')
-rw-r--r-- | interface/js/app/config.js | 50 |
1 files changed, 19 insertions, 31 deletions
diff --git a/interface/js/app/config.js b/interface/js/app/config.js index 431d9bb92..36cdafeea 100644 --- a/interface/js/app/config.js +++ b/interface/js/app/config.js @@ -162,9 +162,8 @@ define(["jquery"], }); }; - // @upload edited actions ui.setup = function (rspamd) { - // Modal form for maps + // Modal form for maps $(document).on("click", "[data-toggle=\"modal\"]", function () { var checked_server = rspamd.getSelector("selSrv"); var item = $(this).data("item"); @@ -173,46 +172,35 @@ define(["jquery"], Map: item.map }, success: function (data) { - var disabled = ""; + var readonly = ""; + var icon = "fa-edit"; var text = data[0].data; if (item.editable === false || rspamd.read_only) { - disabled = "disabled=\"disabled\""; - } - - $("#" + item.map).remove(); - $("<form id=\"" + item.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").modal({backdrop:true, keyboard:"show", show:true}); - if (item.editable === false) { - $("#modalSave").hide(); - $("#modalSaveAll").hide(); + readonly = " readonly"; + icon = "fa-eye"; + $("#modalSaveGroup").hide(); } else { - $("#modalSave").show(); - $("#modalSaveAll").show(); + $("#modalSaveGroup").show(); } + $("#modalDialog .modal-header").find("[data-fa-i2svg]").addClass(icon); + $("#modalTitle").html(item.uri); + $('<textarea id="map-textarea" class="form-control"' + readonly + + ' data-id="' + item.map + '">' + + text + + "</textarea>").appendTo("#modalBody"); + $("#modalDialog").modal("show"); }, errorMessage: "Cannot receive maps data", server: (checked_server === "All SERVERS") ? "local" : checked_server }); return false; }); - // close modal without saving $("#modalDialog").on("hidden.bs.modal", function () { - $("#modalBody form").remove(); + $("#map-textarea").remove(); }); - // @save forms from modal + 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, { + rspamd.query("savemap", { success: function () { rspamd.alertMessage("alert-success", "Map data successfully saved"); $("#modalDialog").modal("hide"); @@ -220,10 +208,10 @@ define(["jquery"], errorMessage: "Save map error", method: "POST", headers: { - Map: id, + Map: $("#map-textarea").data("id"), }, params: { - data: data, + data: $("#map-textarea").val(), dataType: "text", }, server: server |