aboutsummaryrefslogtreecommitdiffstats
path: root/interface
diff options
context:
space:
mode:
Diffstat (limited to 'interface')
-rw-r--r--interface/js/app/config.js4
-rw-r--r--interface/js/app/history.js12
-rw-r--r--interface/js/app/rspamd.js7
-rw-r--r--interface/js/app/symbols.js12
-rw-r--r--interface/js/app/upload.js5
5 files changed, 10 insertions, 30 deletions
diff --git a/interface/js/app/config.js b/interface/js/app/config.js
index 5bebca62a..78f27c23d 100644
--- a/interface/js/app/config.js
+++ b/interface/js/app/config.js
@@ -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,
diff --git a/interface/js/app/history.js b/interface/js/app/history.js
index 19bd30623..2807bac41 100644
--- a/interface/js/app/history.js
+++ b/interface/js/app/history.js
@@ -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", {
diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js
index 0a27c14bd..94fbe4857 100644
--- a/interface/js/app/rspamd.js
+++ b/interface/js/app/rspamd.js
@@ -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);
}
});
diff --git a/interface/js/app/symbols.js b/interface/js/app/symbols.js
index 1c5d0408f..04b661d99 100644
--- a/interface/js/app/symbols.js
+++ b/interface/js/app/symbols.js
@@ -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
});
});
diff --git a/interface/js/app/upload.js b/interface/js/app/upload.js
index 064cadc56..bbd109639 100644
--- a/interface/js/app/upload.js
+++ b/interface/js/app/upload.js
@@ -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");