]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Add "errorMessage" parameter to query function
authorAlexander Moisseev <moiseev@mezonplus.ru>
Mon, 30 Jul 2018 08:06:46 +0000 (11:06 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Mon, 30 Jul 2018 08:06:46 +0000 (11:06 +0300)
interface/js/app/config.js
interface/js/app/history.js
interface/js/app/rspamd.js
interface/js/app/symbols.js
interface/js/app/upload.js

index 5bebca62a0bfb849eec89b90554bc57fb1e415b8..78f27c23d8270637922f3802e7ef4deef35d6b15 100644 (file)
@@ -271,9 +271,7 @@ define(["jquery"],
                     success: function () {
                         save_map_success(rspamd);
                     },
-                    error: function (serv, jqXHR, textStatus, errorThrown) {
-                        save_map_error(rspamd, serv, jqXHR, textStatus, errorThrown);
-                    },
+                    errorMessage: "Save map error",
                     method: "POST",
                     headers: {
                         Map: id,
index 19bd30623d9797b07665a85456c1b047ecf3e725..2807bac41c4144d12ac7093556b4f3bfbd413f66 100644 (file)
@@ -704,11 +704,7 @@ define(["jquery", "footable", "humanize"],
                         ui.getHistory(rspamd, tables, neighbours, checked_server);
                         ui.getErrors(rspamd, tables, neighbours, checked_server);
                     },
-                    error: 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);
-                    }
+                    errorMessage: "Cannot reset history log"
                 });
             });
         };
@@ -757,12 +753,10 @@ define(["jquery", "footable", "humanize"],
                     beforeSend: function (xhr) {
                         xhr.setRequestHeader("Password", rspamd.getPassword());
                     },
-                    error: function () {
-                        rspamd.alertMessage("alert-error", "Cannot receive errors");
-                    },
                     success: function (data) {
                         drawErrorsTable(data);
-                    }
+                    },
+                    errorMessage: "Cannot receive errors"
                 });
             } else {
                 rspamd.query("errors", {
index 0a27c14bdb42d3e1b95df1abf223b0fc886dbca4..94fbe485765e253bc5d51471e03b8d4b4aaed9a8 100644 (file)
@@ -211,8 +211,8 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
                     o.error(neighbours_status[ind],
                         jqXHR, textStatus, errorThrown);
                 } else {
-                    alertMessage("alert-error", "Cannot receive data from " +
-                           neighbours_status[ind].host + ": " + errorThrown);
+                    alertMessage("alert-error", neighbours_status[ind].name + " > " +
+                        ((o.errorMessage) ? o.errorMessage : "Request failed") + ": " + errorThrown);
                 }
             },
             complete: function () {
@@ -459,6 +459,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
      *
      * @param {Object|string|Array} [options.data] - Data to be sent to the server.
      * @param {Function} [options.error] - A function to be called if the request fails.
+     * @param {string} [options.errorMessage] - Text to display in the alert message if the request fails.
      * @param {Object} [options.headers] - An object of additional header key/value pairs to send along with requests
      *     using the XMLHttpRequest transport.
      * @param {string} [options.method] - The HTTP method to use for the request.
@@ -472,7 +473,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
         // Force options to be an object
         var o = options || {};
         Object.keys(o).forEach(function (option) {
-            if (["data", "error", "headers", "method", "params", "server", "success"].indexOf(option) < 0) {
+            if (["data", "error", "errorMessage", "headers", "method", "params", "server", "success"].indexOf(option) < 0) {
                 throw new Error("Unknown option: " + option);
             }
         });
index 1c5d0408ff4e1951ba62035a842f90997fc57ada..04b661d994e95bc26038376f83dbe5b60371c3b2 100644 (file)
@@ -50,11 +50,7 @@ define(["jquery", "footable"],
                 success: function () {
                     rspamd.alertMessage("alert-modal alert-success", "Symbols successfully saved");
                 },
-                error: function (serv, jqXHR, textStatus, errorThrown) {
-                    var serv_name = (typeof serv === "string") ? serv : serv.name;
-                    rspamd.alertMessage("alert-modal alert-error",
-                        "Save symbols error on " + serv_name + ": " + errorThrown);
-                },
+                errorMessage: "Save symbols error",
                 method: "POST",
                 params: {
                     data: JSON.stringify(values),
@@ -237,9 +233,6 @@ define(["jquery", "footable"],
                         }
                     });
                 },
-                error: function (data) {
-                    rspamd.alertMessage("alert-modal alert-error", data.statusText);
-                },
                 server: (checked_server === "All SERVERS") ? "local" : checked_server
             });
             $("#symbolsTable")
@@ -260,9 +253,6 @@ define(["jquery", "footable"],
                         var items = process_symbols_data(data[0].data)[0];
                         ft.symbols.rows.load(items);
                     },
-                    error: function (data) {
-                        rspamd.alertMessage("alert-modal alert-error", data.statusText);
-                    },
                     server: (checked_server === "All SERVERS") ? "local" : checked_server
                 });
             });
index 064cadc565ed1ece6897d0e78ecd789cc582a0ab..bbd10963948d8d1e03117101c6e38a56b078104a 100644 (file)
@@ -148,10 +148,7 @@ define(["jquery"],
                         rspamd.alertMessage("alert-error", "Cannot scan data");
                     }
                 },
-                error: function (jqXHR, textStatus, errorThrown) {
-                    rspamd.alertMessage("alert-error", "Cannot upload data: " +
-                    textStatus + ", " + errorThrown);
-                },
+                errorMessage: "Cannot upload data",
                 statusCode: {
                     404: function () {
                         rspamd.alertMessage("alert-error", "Cannot upload data, no server found");