"no-ternary": "off",
"object-shorthand": "off",
"one-var": ["error", { "initialized": "never" }],
- "prefer-arrow-callback": "off",
"prefer-named-capture-group": "off",
"prefer-object-has-own": "off",
"prefer-spread": "off",
/* global require */
define(["jquery", "app/rspamd"],
- function ($, rspamd) {
+ ($, rspamd) => {
"use strict";
const ui = {};
success: function (data) {
$("#actionsFormField").empty();
const items = [];
- $.each(data[0].data, function (i, item) {
+ $.each(data[0].data, (i, item) => {
const actionsOrder = ["greylist", "add header", "rewrite subject", "reject"];
const idx = actionsOrder.indexOf(item.action);
if (idx >= 0) {
}
});
- items.sort(function (a, b) {
- return a.idx - b.idx;
- });
+ items.sort((a, b) => a.idx - b.idx);
$("#actionsFormField").html(
- items.map(function (e) {
- return e.html;
- }).join(""));
+ items.map((e) => e.html).join(""));
},
server: (checked_server === "All SERVERS") ? "local" : checked_server
});
ui.saveActions = function (server) {
function descending(arr) {
let desc = true;
- const filtered = arr.filter(function (el) {
- return el !== null;
- });
+ const filtered = arr.filter((el) => el !== null);
for (let i = 0; i < filtered.length - 1; i++) {
if (filtered[i + 1] >= filtered[i]) {
desc = false;
$("#modalBody").empty();
const $tbody = $("<tbody>");
- $.each(data, function (i, item) {
+ $.each(data, (i, item) => {
let $td = '<td><span class="badge text-bg-secondary">Read</span></td>';
if (!(item.editable === false || rspamd.read_only)) {
$td = $($td).append(' <span class="badge text-bg-success">Write</span>');
'"></' + editor[mode].elt + ">").appendTo("#modalBody");
if (editor[mode].codejar) {
- require(["codejar", "linenumbers", "prism"], function (CodeJar, withLineNumbers, Prism) {
+ require(["codejar", "linenumbers", "prism"], (CodeJar, withLineNumbers, Prism) => {
jar = new CodeJar(
document.querySelector("#editor"),
withLineNumbers((el) => Prism.highlightElement(el))
});
return false;
});
- $("#modalDialog").on("hidden.bs.modal", function () {
+ $("#modalDialog").on("hidden.bs.modal", () => {
if (editor[mode].codejar) {
jar.destroy();
$(".codejar-wrap").remove();
}
});
- $("#saveActionsBtn").on("click", function () {
+ $("#saveActionsBtn").on("click", () => {
ui.saveActions();
});
- $("#saveActionsClusterBtn").on("click", function () {
+ $("#saveActionsClusterBtn").on("click", () => {
ui.saveActions("All SERVERS");
});
server: server
});
}
- $("#modalSave").on("click", function () {
+ $("#modalSave").on("click", () => {
saveMap();
});
- $("#modalSaveAll").on("click", function () {
+ $("#modalSaveAll").on("click", () => {
saveMap("All SERVERS");
});
/* global FooTable */
define(["jquery", "app/rspamd", "d3evolution", "d3pie", "d3", "footable"],
- function ($, rspamd, D3Evolution, D3Pie, d3) {
+ ($, rspamd, D3Evolution, D3Pie, d3) => {
"use strict";
const rrd_pie_config = {
}
function getRrdSummary(json, scaleFactor) {
- const xExtents = d3.extent(d3.merge(json), function (d) { return d.x; });
+ const xExtents = d3.extent(d3.merge(json), (d) => d.x);
const timeInterval = xExtents[1] - xExtents[0];
let total = 0;
- const rows = json.map(function (curr, i) {
+ const rows = json.map((curr, i) => {
// Time intervals that don't have data are excluded from average calculation as d3.mean()ignores nulls
- const avg = d3.mean(curr, function (d) { return d.y; });
+ const avg = d3.mean(curr, (d) => d.y);
// To find an integral on the whole time interval we need to convert nulls to zeroes
// eslint-disable-next-line no-bitwise
- const value = d3.mean(curr, function (d) { return Number(d.y); }) * timeInterval / scaleFactor ^ 0;
- const yExtents = d3.extent(curr, function (d) { return d.y; });
+ const value = d3.mean(curr, (d) => Number(d.y)) * timeInterval / scaleFactor ^ 0;
+ const yExtents = d3.extent(curr, (d) => d.y);
total += value;
return {
{name: "max", title: "Maximum, <span class=\"unit\">" + unit + "</span>", defaultContent: ""},
{name: "last", title: "Last, " + unit},
],
- rows: rows.map(function (curr, i) {
- return {
- options: {
- style: {
- color: graph_options.legend.entries[i].color
- }
- },
- value: curr
- };
- }, [])
+ rows: rows.map((curr, i) => ({
+ options: {
+ style: {
+ color: graph_options.legend.entries[i].color
+ }
+ },
+ value: curr
+ }), [])
});
}
function drawRrdTable(rows, unit) {
if (Object.prototype.hasOwnProperty.call(rspamd.tables, "rrd_summary")) {
- $.each(rspamd.tables.rrd_summary.rows.all, function (i, row) {
+ $.each(rspamd.tables.rrd_summary.rows.all, (i, row) => {
row.val(rows[i], false, true);
});
} else {
if (data) {
// Autoranging
let scaleFactor = 1;
- const yMax = d3.max(d3.merge(data), function (d) { return d.y; });
+ const yMax = d3.max(d3.merge(data), (d) => d.y);
if (yMax < 1) {
scaleFactor = 60;
unit = "msg/min";
- data.forEach(function (s) {
- s.forEach(function (d) {
+ data.forEach((s) => {
+ s.forEach((d) => {
if (d.y !== null) { d.y *= scaleFactor; }
});
});
success: function (req_data) {
let data = null;
const neighbours_data = req_data
- .filter(function (d) { return d.status; }) // filter out unavailable neighbours
- .map(function (d) { return d.data; });
+ .filter((d) => d.status) // filter out unavailable neighbours
+ .map((d) => d.data);
if (neighbours_data.length === 1) {
[data] = neighbours_data;
} else {
let time_match = true;
- neighbours_data.reduce(function (res, curr, _, arr) {
+ neighbours_data.reduce((res, curr, _, arr) => {
if ((curr[0][0].x !== res[0][0].x) ||
(curr[0][curr[0].length - 1].x !== res[0][res[0].length - 1].x)) {
time_match = false;
});
if (time_match) {
- data = neighbours_data.reduce(function (res, curr) {
- return curr.map(function (action, j) {
- return action.map(function (d, i) {
- return {
- x: d.x,
- y: (res[j][i].y === null) ? d.y : res[j][i].y + d.y
- };
- });
- });
- });
+ data = neighbours_data.reduce((res, curr) => curr.map((action, j) => action.map((d, i) => ({
+ x: d.x,
+ y: (res[j][i].y === null) ? d.y : res[j][i].y + d.y
+ }))));
}
}
updateWidgets(data);
// Handling mouse events on overlapping elements
- $("#rrd-pie").mouseover(function () {
+ $("#rrd-pie").mouseover(() => {
$("#rrd-pie,#rrd-pie-tooltip").css("z-index", "200");
$("#rrd-table_toggle").css("z-index", "300");
});
- $("#rrd-table_toggle").mouseover(function () {
+ $("#rrd-table_toggle").mouseover(() => {
$("#rrd-pie,#rrd-pie-tooltip").css("z-index", "0");
$("#rrd-table_toggle").css("z-index", "0");
});
/* global FooTable */
define(["jquery", "app/rspamd", "d3", "footable"],
- function ($, rspamd, d3) {
+ ($, rspamd, d3) => {
"use strict";
const ui = {};
let prevVersion = null;
$("#selSymOrder_history, label[for='selSymOrder_history']").hide();
- $.each(data, function (i, item) {
+ $.each(data, (i, item) => {
item.time = rspamd.unix_time_format(item.unix_time);
rspamd.preprocess_item(item);
item.symbols = Object.keys(item.symbols)
- .map(function (key) {
- return item.symbols[key];
- })
+ .map((key) => item.symbols[key])
.sort(compare)
- .map(function (e) { return e.name; })
+ .map((e) => e.name)
.join(", ");
item.time = {
value: rspamd.unix_time_format(item.unix_time),
rspamd.query("history", {
success: function (req_data) {
function differentVersions(neighbours_data) {
- const dv = neighbours_data.some(function (e) {
- return e.version !== neighbours_data[0].version;
- });
+ const dv = neighbours_data.some((e) => e.version !== neighbours_data[0].version);
if (dv) {
rspamd.alertMessage("alert-error",
"Neighbours history backend versions do not match. Cannot display history.");
}
const neighbours_data = req_data
- .filter(function (d) { return d.status; }) // filter out unavailable neighbours
- .map(function (d) { return d.data; });
+ .filter((d) => d.status) // filter out unavailable neighbours
+ .map((d) => d.data);
if (neighbours_data.length && !differentVersions(neighbours_data)) {
let data = {};
const [{version}] = neighbours_data;
if (version) {
data.rows = [].concat.apply([], neighbours_data
- .map(function (e) {
- return e.rows;
- }));
+ .map((e) => e.rows));
data.version = version;
$("#legacy-history-badge").hide();
} else {
} else {
rspamd.destroyTable("history");
// Is there a way to get an event when the table is destroyed?
- setTimeout(function () {
+ setTimeout(() => {
rspamd.initHistoryTable(data, items, "history", get_history_columns(data), false);
}, 200);
}
rspamd.query("errors", {
success: function (data) {
const neighbours_data = data
- .filter(function (d) {
- return d.status;
- }) // filter out unavailable neighbours
- .map(function (d) {
- return d.data;
- });
+ .filter((d) => d.status) // filter out unavailable neighbours
+ .map((d) => d.data);
const rows = [].concat.apply([], neighbours_data);
- $.each(rows, function (i, item) {
+ $.each(rows, (i, item) => {
item.ts = {
value: rspamd.unix_time_format(item.ts),
options: {
});
$("#updateErrors").off("click");
- $("#updateErrors").on("click", function (e) {
+ $("#updateErrors").on("click", (e) => {
e.preventDefault();
ui.getErrors();
});
rspamd.bindHistoryTableEventHandlers("history", 8);
$("#updateHistory").off("click");
- $("#updateHistory").on("click", function (e) {
+ $("#updateHistory").on("click", (e) => {
e.preventDefault();
ui.getHistory();
});
// @reset history log
$("#resetHistory").off("click");
- $("#resetHistory").on("click", function (e) {
+ $("#resetHistory").on("click", (e) => {
e.preventDefault();
if (!confirm("Are you sure you want to reset history log?")) { // eslint-disable-line no-alert
return;
define(["jquery", "nprogress", "stickytabs", "visibility",
"bootstrap", "fontawesome"],
-function ($, NProgress) {
+($, NProgress) => {
"use strict";
const ui = {
chartLegend: [
}
function disconnect() {
- [graphs, tables].forEach(function (o) {
- Object.keys(o).forEach(function (key) {
+ [graphs, tables].forEach((o) => {
+ Object.keys(o).forEach((key) => {
o[key].destroy();
delete o[key];
});
let timeLeft = interval;
$("#countdown").text("00:00");
- timer_id.countdown = Visibility.every(1000, 1000, function () {
+ timer_id.countdown = Visibility.every(1000, 1000, () => {
timeLeft -= 1000;
$("#countdown").text(new Date(timeLeft).toISOString().substr(14, 5));
if (timeLeft <= 0) Visibility.stop(timer_id.countdown);
countdown(refreshInterval);
if (!refreshInterval) return;
- timer_id[timer] = Visibility.every(refreshInterval, function () {
+ timer_id[timer] = Visibility.every(refreshInterval, () => {
countdown(refreshInterval);
if ($("#refresh").attr("disabled")) return;
$("#refresh").attr("disabled", true).addClass("disabled", true);
require(["app/stats"], (module) => {
const refreshInterval = $(".dropdown-menu a.active.preset").data("value");
setAutoRefresh(refreshInterval, "status",
- function () { return module.statWidgets(graphs, checked_server); });
+ () => module.statWidgets(graphs, checked_server));
if (id !== "#autoRefresh") module.statWidgets(graphs, checked_server);
$(".preset").show();
refreshInterval = null;
}
setAutoRefresh(refreshInterval, "throughput",
- function () { return module.draw(graphs, neighbours, checked_server, selData); });
+ () => module.draw(graphs, neighbours, checked_server, selData));
if (id !== "#autoRefresh") module.draw(graphs, neighbours, checked_server, selData);
$(".preset").hide();
}
const refreshInterval = $(".dropdown-menu a.active.history").data("value");
setAutoRefresh(refreshInterval, "history",
- function () { return getHistoryAndErrors(); });
+ () => getHistoryAndErrors());
if (id !== "#autoRefresh") getHistoryAndErrors();
$(".preset").hide();
default:
}
- setTimeout(function () {
+ setTimeout(() => {
// Do not enable Refresh button until AJAX requests to all neighbours are finished
if (tab_id === "#history_nav") navBarControls = $(navBarControls).not("#refresh");
function sort_symbols(o, compare_function) {
return Object.keys(o)
- .map(function (key) {
- return o[key];
- })
+ .map((key) => o[key])
.sort(compare_function)
- .map(function (e) { return e.str; })
+ .map((e) => e.str)
.join("<br>\n");
}
success: function (neighbours_status) {
$("#selSrv").empty();
$("#selSrv").append($('<option value="All SERVERS">All SERVERS</option>'));
- neighbours_status.forEach(function (e) {
+ neighbours_status.forEach((e) => {
$("#selSrv").append($('<option value="' + e.name + '">' + e.name + "</option>"));
if (checked_server === e.name) {
$('#selSrv [value="' + e.name + '"]').prop("selected", true);
"<strong>" + alertText + "</strong>");
$(".notification-area").append(a);
- setTimeout(function () {
+ setTimeout(() => {
$(a).fadeTo(500, 0).slideUp(500, function () {
$(this).alert("close");
});
const xhr = $.ajaxSettings.xhr();
// Download progress
if (req_url !== "neighbours") {
- xhr.addEventListener("progress", function (e) {
+ xhr.addEventListener("progress", (e) => {
if (e.lengthComputable) {
neighbours_status[ind].percentComplete = e.loaded / e.total;
- const percentComplete = neighbours_status.reduce(function (prev, curr) {
- return curr.percentComplete ? curr.percentComplete + prev : prev;
- }, 0);
+ const percentComplete = neighbours_status
+ .reduce((prev, curr) => (curr.percentComplete ? curr.percentComplete + prev : prev), 0);
NProgress.set(percentComplete / neighbours_status.length);
}
}, false);
}
},
complete: function (jqXHR) {
- if (neighbours_status.every(function (elt) { return elt.checked; })) {
- if (neighbours_status.some(function (elt) { return elt.status; })) {
+ if (neighbours_status.every((elt) => elt.checked)) {
+ if (neighbours_status.some((elt) => elt.status)) {
if (o.success) {
o.success(neighbours_status, jqXHR);
} else {
req_params.method = o.method;
}
if (o.params) {
- $.each(o.params, function (k, v) {
+ $.each(o.params, (k, v) => {
req_params[k] = v;
});
}
})
.modal("show");
- $("#connectForm").off("submit").on("submit", function (e) {
+ $("#connectForm").off("submit").on("submit", (e) => {
e.preventDefault();
const password = $("#connectPassword").val();
ui.query = function (url, options) {
// Force options to be an object
const o = options || {};
- Object.keys(o).forEach(function (option) {
+ Object.keys(o).forEach((option) => {
if (["complete", "data", "error", "errorMessage", "errorOnceId", "headers", "method", "params", "server",
"statusCode", "success"]
.indexOf(option) < 0) {
neighbours = data;
}
neighbours_status = [];
- $.each(neighbours, function (ind) {
+ $.each(neighbours, (ind) => {
neighbours_status.push({
name: ind,
host: neighbours[ind].host,
url: neighbours[ind].url,
});
});
- $.each(neighbours_status, function (ind) {
+ $.each(neighbours_status, (ind) => {
queryServer(neighbours_status, ind, url, o);
});
},
function change_symbols_order(order) {
$(".btn-sym-" + table + "-" + order).addClass("active").siblings().removeClass("active");
const compare_function = get_compare_function(table);
- $.each(tables[table].rows.all, function (i, row) {
+ $.each(tables[table].rows.all, (i, row) => {
const cell_val = sort_symbols(ui.symbols[table][i], compare_function);
row.cells[symbolsCol].val(cell_val, false, true);
});
text: self.def
})).appendTo($form_grp);
- $.each(self.actions, function (i, action) {
+ $.each(self.actions, (i, action) => {
self.$action.append($("<option/>").text(action));
});
},
},
on: {
"expand.ft.row": function (e, ft, row) {
- setTimeout(function () {
+ setTimeout(() => {
const detail_row = row.$el.next();
const order = getSelector("selSymOrder_" + table);
detail_row.find(".btn-sym-" + table + "-" + order)
"`": "`",
"=": "="
};
- return String(string).replace(htmlEscaper, function (match) {
- return htmlEscapes[match];
- });
+ return String(string).replace(htmlEscaper, (match) => htmlEscapes[match]);
};
ui.preprocess_item = function (item) {
function escape_HTML_array(arr) {
- arr.forEach(function (d, i) { arr[i] = ui.escapeHTML(d); });
+ arr.forEach((d, i) => { arr[i] = ui.escapeHTML(d); });
}
for (const prop in item) {
escape_HTML_array(item[prop]);
break;
case "symbols":
- Object.keys(item.symbols).forEach(function (key) {
+ Object.keys(item.symbols).forEach((key) => {
const sym = item.symbols[key];
if (!sym.name) {
sym.name = key;
$("#selSymOrder_" + table + ", label[for='selSymOrder_" + table + "']").show();
$.each(data.rows,
- function (i, item) {
+ (i, item) => {
function more(p) {
const l = item[p].length;
return (l > rcpt_lim) ? " … (" + l + ")" : "";
}
ui.preprocess_item(item);
- Object.values(item.symbols).forEach(function (sym) {
+ Object.values(item.symbols).forEach((sym) => {
sym.str = '<span class="symbol-default ' + get_symbol_class(sym.name, sym.score) + '"><strong>';
if (sym.description) {
num_rows === rows_total) {
return callback();
} else if (--i) {
- setTimeout(function () {
+ setTimeout(() => {
ui.waitForRowsDisplayed(table, rows_total, callback, i);
}, 500);
}
}).attr("title", function () {
return $(this).attr("data-original-title");
});
- $("#settings").on("click", function (e) {
+ $("#settings").on("click", (e) => {
e.preventDefault();
});
- $("#settings").on("inserted.bs.popover", function () {
+ $("#settings").on("inserted.bs.popover", () => {
selected_locale = localStorage.getItem("selected_locale") || "browser";
custom_locale = localStorage.getItem("custom_locale") || "";
validateLocale();
localStorage.setItem("selected_locale", selected_locale);
validateLocale();
});
- $(document).on("input", localeTextbox, function () {
+ $(document).on("input", localeTextbox, () => {
custom_locale = $(localeTextbox).val();
validateLocale(true);
});
- $(document).on("input", ajaxTimeoutBox, function () {
+ $(document).on("input", ajaxTimeoutBox, () => {
ajaxSetup($(ajaxTimeoutBox).val(), false, true);
});
- $(document).on("click", ".popover #settings-popover #ajax-timeout-restore", function () {
+ $(document).on("click", ".popover #settings-popover #ajax-timeout-restore", () => {
ajaxSetup(null, true, true);
});
// Dismiss Bootstrap popover by clicking outside
- $("body").on("click", function (e) {
+ $("body").on("click", (e) => {
$(".popover").each(function () {
if (
// Popover's descendant
});
}());
- $("#selData").change(function () {
+ $("#selData").change(() => {
tabClick("#throughput_nav");
});
- $(document).ajaxStart(function () {
+ $(document).ajaxStart(() => {
$("#refresh > svg").addClass("fa-spin");
});
- $(document).ajaxComplete(function () {
- setTimeout(function () {
+ $(document).ajaxComplete(() => {
+ setTimeout(() => {
$("#refresh > svg").removeClass("fa-spin");
}, 1000);
});
define(["jquery", "app/rspamd"],
- function ($, rspamd) {
+ ($, rspamd) => {
"use strict";
const ui = {};
function buildLists() {
function build_table_from_json(json, table_id) {
- Object.keys(json).forEach(function (key) {
+ Object.keys(json).forEach((key) => {
const td = $("<td/>");
const tr = $("<tr/>")
.append(td.clone().html("<code>" + key + "</code>"))
$("#content").removeClass("col-lg-12 col-lg-9 col-lg-6")
.addClass(contentClass);
}
- $("#sidebar-tab-left>a").click(function () {
+ $("#sidebar-tab-left>a").click(() => {
toggleSidebar("left");
return false;
});
- $("#sidebar-tab-right>a").click(function () {
+ $("#sidebar-tab-right>a").click(() => {
toggleSidebar("right");
return false;
});
- $("#selectorsMsgClean").on("click", function () {
+ $("#selectorsMsgClean").on("click", () => {
$("#selectorsChkMsgBtn").attr("disabled", true);
$("#selectorsMsgArea").val("");
return false;
});
- $("#selectorsClean").on("click", function () {
+ $("#selectorsClean").on("click", () => {
$("#selectorsSelArea").val("");
checkSelectors();
return false;
});
- $("#selectorsChkMsgBtn").on("click", function () {
+ $("#selectorsChkMsgBtn").on("click", () => {
$("#selectorsResArea").val("");
checkMsg($("#selectorsMsgArea").val());
return false;
});
- $("#selectorsMsgArea").on("input", function () {
+ $("#selectorsMsgArea").on("input", () => {
enable_disable_check_btn();
});
- $("#selectorsSelArea").on("input", function () {
+ $("#selectorsSelArea").on("input", () => {
checkSelectors();
});
*/
define(["jquery", "app/rspamd", "d3pie", "d3"],
- function ($, rspamd, D3Pie, d3) {
+ ($, rspamd, D3Pie, d3) => {
"use strict";
// @ ms to date
function msToTime(seconds) {
const stat_w = [];
$("#statWidgets").empty().hide();
- $.each(data, function (i, item) {
+ $.each(data, (i, item) => {
const widgetsOrder = ["scanned", "no action", "greylist", "add header", "rewrite subject", "reject", "learned"];
function widget(k, v, cls) {
val + "</strong>" + i + "</div>")
.appendTo("#statWidgets");
} else if (i === "actions") {
- $.each(item, function (action, count) {
+ $.each(item, (action, count) => {
stat_w[widgetsOrder.indexOf(action)] = widget(action, count);
});
} else {
stat_w[widgetsOrder.indexOf(i)] = widget(i, item, " text-capitalize");
}
});
- $.each(stat_w, function (i, item) {
+ $.each(stat_w, (i, item) => {
$(item).appendTo("#statWidgets");
});
$("#statWidgets > div:not(.stat-box)")
$("#clusterTable tbody").empty();
$("#selSrv").empty();
- $.each(servers, function (key, val) {
+ $.each(servers, (key, val) => {
let row_class = "danger";
let glyph_status = "fas fa-times";
let version = "???";
});
function addStatfiles(server, statfiles) {
- $.each(statfiles, function (i, statfile) {
+ $.each(statfiles, (i, statfile) => {
let cls = "";
switch (statfile.symbol) {
case "BAYES_SPAM":
function addFuzzyStorage(server, storages) {
let i = 0;
- $.each(storages, function (storage, hashes) {
+ $.each(storages, (storage, hashes) => {
$("#fuzzyTable tbody").append("<tr>" +
(i === 0 ? '<td rowspan="' + Object.keys(storages).length + '">' + server + "</td>" : "") +
"<td>" + storage + "</td>" +
$("#bayesTable tbody, #fuzzyTable tbody").empty();
if (checked_server === "All SERVERS") {
- $.each(servers, function (server, val) {
+ $.each(servers, (server, val) => {
if (server !== "All SERVERS") {
addStatfiles(server, val.data.statfiles);
addFuzzyStorage(server, val.data.fuzzy_hashes);
const {actions} = creds[checked_server].data;
["no action", "soft reject", "add header", "rewrite subject", "greylist", "reject"]
- .forEach(function (action) {
+ .forEach((action) => {
data.push({
- color: rspamd.chartLegend.find(function (item) { return item.label === action; }).color,
+ color: rspamd.chartLegend.find((item) => item.label === action).color,
label: action,
value: actions[action]
});
}
}
}
- ["learned", "scanned", "uptime"].forEach(function (p) {
+ ["learned", "scanned", "uptime"].forEach((p) => {
neighbours_sum[p] += data[p];
});
status_count++;
headers: {Password: rspamd.getPassword()},
success: function (data) {
sessionStorage.removeItem(alerted);
- ["config_id", "version", "uptime"].forEach(function (p) {
+ ["config_id", "version", "uptime"].forEach((p) => {
neighbours_status[e].data[p] = data[p];
});
process_node_stat(e);
}
}
}
- setTimeout(function () {
- $.when.apply($, promises).always(function () {
+ setTimeout(() => {
+ $.when.apply($, promises).always(() => {
neighbours_sum.uptime = Math.floor(neighbours_sum.uptime / status_count);
to_Credentials["All SERVERS"].data = neighbours_sum;
sessionStorage.setItem("Credentials", JSON.stringify(to_Credentials));
/* global FooTable */
define(["jquery", "app/rspamd", "footable"],
- function ($, rspamd) {
+ ($, rspamd) => {
"use strict";
const ui = {};
const distinct_groups = [];
const selected_server = rspamd.getSelector("selSrv");
- data.forEach(function (group) {
- group.rules.forEach(function (item) {
+ data.forEach((group) => {
+ group.rules.forEach((item) => {
let max = 20;
let min = -20;
if (item.weight > max) {
});
// For better mean calculations
- const avg_freq = freqs.sort(function (a, b) {
- return Number(a) < Number(b);
- }).reduce(function (f1, acc) {
- return f1 + acc;
- }) / (freqs.length !== 0 ? freqs.length : 1.0);
+ const avg_freq = freqs
+ .sort((a, b) => Number(a) < Number(b))
+ .reduce((f1, acc) => f1 + acc) / (freqs.length !== 0 ? freqs.length : 1.0);
let mult = 1.0;
let exp = 0.0;
exp++;
}
}
- $.each(items, function (i, item) {
+ $.each(items, (i, item) => {
item.frequency = Number(item.frequency) * mult;
if (exp > 0) {
text: self.def
})).appendTo($form_grp);
- $.each(self.groups, function (i, group) {
+ $.each(self.groups, (i, group) => {
self.$group.append($("<option/>").text(group));
});
},
};
- $("#updateSymbols").on("click", function (e) {
+ $("#updateSymbols").on("click", (e) => {
e.preventDefault();
const checked_server = rspamd.getSelector("selSrv");
rspamd.query("symbols", {
/* global require */
define(["jquery", "app/rspamd"],
- function ($, rspamd) {
+ ($, rspamd) => {
"use strict";
const ui = {};
function server() {
if (rspamd.getSelector("selSrv") === "All SERVERS" &&
rspamd.getSelector("selLearnServers") === "random") {
- const servers = $("#selSrv option").slice(1).map(function (_, o) { return o.value; });
+ const servers = $("#selSrv option").slice(1).map((_, o) => o.value);
return servers[Math.floor(Math.random() * servers.length)];
}
return null;
success: function (neighbours_status) {
function scrollTop(rows_total) {
// Is there a way to get an event when all rows are loaded?
- rspamd.waitForRowsDisplayed("scan", rows_total, function () {
+ rspamd.waitForRowsDisplayed("scan", rows_total, () => {
$("#cleanScanHistory").removeAttr("disabled", true);
$("html, body").animate({
scrollTop: $("#scanResult").offset().top
scrollTop(rows_total);
} else {
rspamd.destroyTable("scan");
- require(["footable"], function () {
+ require(["footable"], () => {
// Is there a way to get an event when the table is destroyed?
- setTimeout(function () {
+ setTimeout(() => {
rspamd.initHistoryTable(data, items, "scan", columns_v2(), true);
scrollTop(rows_total);
}, 200);
function fillHashTable(rules) {
$("#hashTable tbody").empty();
for (const [rule, hashes] of Object.entries(rules)) {
- hashes.forEach(function (hash, i) {
+ hashes.forEach((hash, i) => {
$("#hashTable tbody").append("<tr>" +
(i === 0 ? '<td rowspan="' + Object.keys(hashes).length + '">' + rule + "</td>" : "") +
"<td>" + hash + "</td></tr>");
rspamd.bindHistoryTableEventHandlers("scan", 3);
$("#cleanScanHistory").off("click");
- $("#cleanScanHistory").on("click", function (e) {
+ $("#cleanScanHistory").on("click", (e) => {
e.preventDefault();
if (!confirm("Are you sure you want to clean scan history?")) { // eslint-disable-line no-alert
return;
.prop("disabled", ($.trim($("textarea").val()).length === 0));
}
enable_disable_scan_btn();
- $("textarea").on("input", function () {
+ $("textarea").on("input", () => {
enable_disable_scan_btn();
});
- $("#scanClean").on("click", function () {
+ $("#scanClean").on("click", () => {
$("#scan button:not(#cleanScanHistory, #scanOptionsToggle)").attr("disabled", true);
$("#scanForm")[0].reset();
$("#scanResult").hide();
let headers = {};
if ($.trim(data).length > 0) {
if (source === "scan") {
- headers = ["IP", "User", "From", "Rcpt", "Helo", "Hostname"].reduce(function (o, header) {
+ headers = ["IP", "User", "From", "Rcpt", "Helo", "Hostname"].reduce((o, header) => {
const value = $("#scan-opt-" + header.toLowerCase()).val();
if (value !== "") o[header] = value;
return o;
" - Rspamd Web Interface";
// Ugly hack to get d3pie work with requirejs
-define("d3.global", ["d3"], function (d3global) { // eslint-disable-line strict
+define("d3.global", ["d3"], (d3global) => { // eslint-disable-line strict
d3 = d3global;
});