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 | |
parent | 056d73ba80b03a83e3214749ec846629bc4893c8 (diff) | |
download | rspamd-0084098849fbd39806e190a1589f91cacee8167a.tar.gz rspamd-0084098849fbd39806e190a1589f91cacee8167a.zip |
[Minor] Use query function to get and update symbols
Diffstat (limited to 'interface')
-rw-r--r-- | interface/js/app/rspamd.js | 4 | ||||
-rw-r--r-- | interface/js/app/symbols.js | 48 |
2 files changed, 23 insertions, 29 deletions
diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js index 909e34900..b092d537c 100644 --- a/interface/js/app/rspamd.js +++ b/interface/js/app/rspamd.js @@ -123,7 +123,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, tab_config.getMaps(ui); break; case "#symbols_nav": - tab_symbols.getSymbols(ui, tables, checked_server); + tab_symbols.getSymbols(ui, checked_server); break; case "#history_nav": tab_history.getHistory(ui, tables, neighbours, checked_server); @@ -278,7 +278,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, } }); tab_config.setup(ui); - tab_symbols.setup(ui, tables); + tab_symbols.setup(ui); tab_upload.setup(ui); selData = tab_graph.setup(); }; 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 + ); }); }; |