]> source.dussan.org Git - rspamd.git/commitdiff
[WebUI] Fix history reset for "All SERVERS" (#2346) 2361/head
authorAlexander Moisseev <moiseev@mezonplus.ru>
Sat, 21 Jul 2018 12:00:22 +0000 (15:00 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Sat, 21 Jul 2018 12:00:22 +0000 (15:00 +0300)
interface/js/app/history.js

index b46ffd6559f0397b5d267ff9167464eeaadece2f..e919706637721abdd9949fac0edb82dd0a107d6e 100644 (file)
@@ -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));
             });
         };