updateWidgets(neighbours_data[0]);
}
},
- error: function (serv, jqXHR, textStatus, errorThrown) {
- var serv_name = (typeof serv === "string") ? serv : serv.name;
- var alert_status = "alerted_graph_" + serv_name;
-
- if (!(alert_status in sessionStorage)) {
- sessionStorage.setItem(alert_status, true);
- rspamd.alertMessage("alert-error", "Cannot receive throughput data from " +
- serv_name + ", error: " + errorThrown);
- }
- },
+ errorMessage: "Cannot receive throughput data",
+ errorOnceId: "alerted_graph_",
data: {type: type}
});
};
error: function (jqXHR, textStatus, errorThrown) {
neighbours_status[ind].status = false;
neighbours_status[ind].checked = true;
+ function errorMessage() {
+ alertMessage("alert-error", neighbours_status[ind].name + " > " +
+ ((o.errorMessage) ? o.errorMessage : "Request failed") + ": " + errorThrown);
+ }
if (o.error) {
o.error(neighbours_status[ind],
jqXHR, textStatus, errorThrown);
+ } else if (o.errorOnceId) {
+ var alert_status = o.errorOnceId + neighbours_status[ind].name;
+ if (!(alert_status in sessionStorage)) {
+ sessionStorage.setItem(alert_status, true);
+ errorMessage();
+ }
} else {
- alertMessage("alert-error", neighbours_status[ind].name + " > " +
- ((o.errorMessage) ? o.errorMessage : "Request failed") + ": " + errorThrown);
+ errorMessage();
}
},
complete: function () {
* @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 {string} [options.errorOnceId] - A prefix of the alert ID to be added to the session storage. If the
+ * parameter is set, the error for each server will be displayed only once per session.
* @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.
// Force options to be an object
var o = options || {};
Object.keys(o).forEach(function (option) {
- if (["data", "error", "errorMessage", "headers", "method", "params", "server", "success"].indexOf(option) < 0) {
+ if (["data", "error", "errorMessage", "errorOnceId", "headers", "method", "params", "server", "success"]
+ .indexOf(option) < 0) {
throw new Error("Unknown option: " + option);
}
});
displayStatWidgets(checked_server);
graphs.chart = getChart(rspamd, graphs.chart, checked_server);
},
- error: function (serv, jqXHR, textStatus, errorThrown) {
- var alert_status = "alerted_stats_" + serv.name;
-
- if (!(alert_status in sessionStorage)) {
- sessionStorage.setItem(alert_status, true);
- rspamd.alertMessage("alert-error", "Cannot receive stats data from: " +
- serv.name + ", error: " + errorThrown);
- }
- },
+ errorMessage: "Cannot receive stats data",
+ errorOnceId: "alerted_stats_",
server: "All SERVERS"
});
},