From 58912d8fcac2e5998841a1af017f442fc495d743 Mon Sep 17 00:00:00 2001 From: Alexander Moisseev Date: Sat, 21 Jul 2018 15:00:22 +0300 Subject: [PATCH] [WebUI] Fix history reset for "All SERVERS" (#2346) --- interface/js/app/history.js | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) 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)); }); }; -- 2.39.5