From: Alexander Moisseev Date: Sat, 28 Jul 2018 07:24:30 +0000 (+0300) Subject: [Minor] Use query function to get and update symbols X-Git-Tag: 1.7.9~29^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0084098849fbd39806e190a1589f91cacee8167a;p=rspamd.git [Minor] Use query function to get and update symbols --- 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 + ); }); };