diff options
author | Alexander Moisseev <moiseev@mezonplus.ru> | 2018-07-28 10:24:30 +0300 |
---|---|---|
committer | Alexander Moisseev <moiseev@mezonplus.ru> | 2018-07-28 10:24:30 +0300 |
commit | 0084098849fbd39806e190a1589f91cacee8167a (patch) | |
tree | eb1402edbf98e3e036b0b1e24b321723634e36f3 /interface/js/app/symbols.js | |
parent | 056d73ba80b03a83e3214749ec846629bc4893c8 (diff) | |
download | rspamd-0084098849fbd39806e190a1589f91cacee8167a.tar.gz rspamd-0084098849fbd39806e190a1589f91cacee8167a.zip |
[Minor] Use query function to get and update symbols
Diffstat (limited to 'interface/js/app/symbols.js')
-rw-r--r-- | interface/js/app/symbols.js | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/interface/js/app/symbols.js b/interface/js/app/symbols.js index 90ae71cf0..ca5bb3c12 100644 --- a/interface/js/app/symbols.js +++ b/interface/js/app/symbols.js @@ -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 + ); }); }; |