]> source.dussan.org Git - rspamd.git/commitdiff
[WebUI] Do not execute `on_success` callback 2363/head
authorAlexander Moisseev <moiseev@mezonplus.ru>
Sun, 22 Jul 2018 12:13:19 +0000 (15:13 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Sun, 22 Jul 2018 12:13:19 +0000 (15:13 +0300)
if all requests to neighbours failed

interface/js/app/rspamd.js

index 5d2fd682aadb326dcdd85034f58451e153ac89d3..2d82a99c78f86937b1bb5ad7e636d688e6c94ade 100644 (file)
@@ -402,16 +402,9 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
                             if (jQuery.isEmptyObject(json)) {
                                 neighbours_status[ind].status = false; // serv does not work
                             } else {
-                                neighbours_status[ind].status = true; // serv does not work
+                                neighbours_status[ind].status = true; // serv works
                                 neighbours_status[ind].data = json;
                             }
-                            if (neighbours_status.every(function (elt) { return elt.checked; })) {
-                                if (on_success) {
-                                    on_success(neighbours_status);
-                                } else {
-                                    alertMessage("alert-success", "Request completed");
-                                }
-                            }
                         },
                         error: function (jqXHR, textStatus, errorThrown) {
                             neighbours_status[ind].status = false;
@@ -423,16 +416,20 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
                                 alertMessage("alert-error", "Cannot receive data from " +
                                        neighbours_status[ind].host + ": " + errorThrown);
                             }
-                            if (neighbours_status.every(
-                                function (elt) { return elt.checked; })) {
-                                if (on_success) {
-                                    on_success(neighbours_status);
+                        },
+                        complete: function () {
+                            if (neighbours_status.every(function (elt) { return elt.checked; })) {
+                                if (neighbours_status.some(function (elt) { return elt.status; })) {
+                                    if (on_success) {
+                                        on_success(neighbours_status);
+                                    } else {
+                                        alertMessage("alert-success", "Request completed");
+                                    }
                                 } else {
-                                    alertMessage("alert-success", "Request completed");
+                                    alertMessage("alert-error", "Request failed");
                                 }
                             }
                         }
-                        // error display
                     };
                     if (params) {
                         $.each(params, function (k, v) {