From: Alexander Moisseev Date: Sat, 21 Jul 2018 12:00:22 +0000 (+0300) Subject: [WebUI] Fix history reset for "All SERVERS" (#2346) X-Git-Tag: 1.7.9~66^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=58912d8fcac2e5998841a1af017f442fc495d743;p=rspamd.git [WebUI] Fix history reset for "All SERVERS" (#2346) --- diff --git a/interface/js/app/history.js b/interface/js/app/history.js index b46ffd655..e91970663 100644 --- a/interface/js/app/history.js +++ b/interface/js/app/history.js @@ -696,29 +696,21 @@ define(["jquery", "footable", "humanize"], ft.errors.destroy(); delete ft.errors; } - if (checked_server === "All SERVERS") { - rspamd.queryNeighbours("errors", function () { - ui.getHistory(rspamd, tables, neighbours, checked_server); - ui.getErrors(rspamd, tables, neighbours, checked_server); - }); - } else { - $.ajax({ - dataType: "json", - type: "GET", - jsonp: false, - url: neighbours[checked_server].url + "historyreset", - beforeSend: function (xhr) { - xhr.setRequestHeader("Password", rspamd.getPassword()); - }, - success: function () { + + (function (callback) { + callback("historyreset", + function () { ui.getHistory(rspamd, tables, neighbours, checked_server); ui.getErrors(rspamd, tables, neighbours, checked_server); }, - error: function (data) { - rspamd.alertMessage("alert-modal alert-error", data.statusText); - } - }); - } + function (serv, jqXHR, textStatus, errorThrown) { + var serv_name = (typeof serv === "string") ? serv : serv.name; + rspamd.alertMessage("alert-error", + "Cannot reset history log on " + serv_name + ": " + errorThrown); + }, + "GET", {}, {} + ); + }((checked_server === "All SERVERS") ? rspamd.queryNeighbours : rspamd.queryLocal)); }); };