*/
define(["jquery"],
- function($) {
+ function ($) {
var interface = {};
function save_map_success(rspamd) {
error: function (data) {
save_map_error(rspamd, "local", null, null, data.statusText);
},
- success: function() { save_map_success(rspamd); },
+ success: function () { save_map_success(rspamd); },
});
}
}
}
- $("#saveActionsBtn").on("click", function() {
+ $("#saveActionsBtn").on("click", function () {
saveActions(rspamd.queryLocal);
});
- $("#saveActionsClusterBtn").on("click", function() {
+ $("#saveActionsClusterBtn").on("click", function () {
saveActions(rspamd.queryNeighbours);
});
},
}
// @upload edited actions
- interface.setup = function(rspamd) {
+ interface.setup = function (rspamd) {
// Modal form for maps
$(document).on("click", "[data-toggle=\"modal\"]", function () {
var item = $(this).data("item");
- getMapById(rspamd, item).done(function() {
+ getMapById(rspamd, item).done(function () {
$("#modalTitle").html(item.uri);
$("#" + item.map).first().show();
$("#modalDialog .progress").hide();
*/
define(["jquery", "d3evolution", "footable"],
- function($, D3Evolution, unused) {
+ function ($, D3Evolution, unused) {
var rrd_pie_config = {
header: {},
size: {
interpolate: getSelector("selInterpolate"),
convert: getSelector("selConvert"),
}));
- $("#selYScale").change(function() {
+ $("#selYScale").change(function () {
graph.yScale(this.value);
});
$("#selConvert").change(function () {
var interface = {};
var prevUnit = "msg/s";
- interface.draw = function(rspamd, graphs, neighbours, checked_server, type) {
+ interface.draw = function (rspamd, graphs, neighbours, checked_server, type) {
function updateWidgets(data) {
// Autoranging
});
};
- interface.setup = function() {
+ interface.setup = function () {
// Handling mouse events on overlapping elements
$("#rrd-pie").mouseover(function () {
$("#rrd-pie").css("z-index", "200");
*/
define(["jquery", "footable", "humanize"],
- function($, _, Humanize) {
+ function ($, _, Humanize) {
var interface = {};
var ft = {};
var htmlEscapes = {
var htmlEscaper = /[&<>"'/`=]/g;
var symbolDescriptions = {};
- EscapeHTML = function(string) {
- return ("" + string).replace(htmlEscaper, function(match) {
+ EscapeHTML = function (string) {
+ return ("" + string).replace(htmlEscaper, function (match) {
return htmlEscapes[match];
});
};
escape_HTML_array(item[prop]);
break;
case "symbols":
- Object.keys(item.symbols).map(function(key) {
+ Object.keys(item.symbols).map(function (key) {
var sym = item.symbols[key];
if (!sym.name) {
sym.name = key;
}
preprocess_item(item);
- Object.keys(item.symbols).map(function(key) {
+ Object.keys(item.symbols).map(function (key) {
var sym = item.symbols[key];
if (sym.description) {
item.symbols[key].str = str;
});
item.symbols = Object.keys(item.symbols)
- .map(function(key) {
+ .map(function (key) {
return item.symbols[key];
})
.sort(compare)
- .map(function(e) { return e.str; })
+ .map(function (e) { return e.str; })
.join("<br>\n");
item.time = {
"value": unix_time_format(item.unix_time),
"font-size": "11px",
"maxWidth": 110
},
- "sortValue": function(val) { return Number(val.options.sortValue); }
+ "sortValue": function (val) { return Number(val.options.sortValue); }
}, {
"name": "symbols",
"title": "Symbols",
"font-size": "11px",
"maxWidth": 72
},
- "sortValue": function(val) { return Number(val.options.sortValue); }
+ "sortValue": function (val) { return Number(val.options.sortValue); }
}, {
"sorted": true,
"direction": "DESC",
"style": {
"font-size": "11px"
},
- "sortValue": function(val) { return Number(val.options.sortValue); }
+ "sortValue": function (val) { return Number(val.options.sortValue); }
}, {
"name": "user",
"title": "Authenticated user",
"font-size": "11px",
"maxWidth": 110
},
- "sortValue": function(val) { return Number(val.options.sortValue); }
+ "sortValue": function (val) { return Number(val.options.sortValue); }
}, {
"name": "symbols",
"title": "Symbols",
"font-size": "11px",
"maxWidth": 80
},
- "sortValue": function(val) { return Number(val.options.sortValue); }
+ "sortValue": function (val) { return Number(val.options.sortValue); }
}, {
"sorted": true,
"direction": "DESC",
"style": {
"font-size": "11px"
},
- "sortValue": function(val) { return Number(val.options.sortValue); }
+ "sortValue": function (val) { return Number(val.options.sortValue); }
}, {
"name": "user",
"title": "Authenticated user",
interface.getHistory = function (rspamd, tables, neighbours, checked_server) {
FooTable.actionFilter = FooTable.Filtering.extend({
- construct : function(instance) {
+ construct : function (instance) {
this._super(instance);
this.actions = ["reject", "add header", "greylist",
"no action", "soft reject", "rewrite subject"];
this.def = "Any action";
this.$action = null;
},
- $create : function() {
+ $create : function () {
this._super();
var self = this, $form_grp = $("<div/>", {
"class" : "form-group"
text : self.def
})).appendTo($form_grp);
- $.each(self.actions, function(i, action) {
+ $.each(self.actions, function (i, action) {
self.$action.append($("<option/>").text(action));
});
},
- _onStatusDropdownChanged : function(e) {
+ _onStatusDropdownChanged : function (e) {
var self = e.data.self, selected = $(this).val();
if (selected !== self.def) {
if (selected === "reject") {
}
self.filter();
},
- draw : function() {
+ draw : function () {
this._super();
var action = this.find("action");
if (action instanceof FooTable.Filter) {
}
});
- var drawTooltips = function() {
+ var drawTooltips = function () {
// Update symbol description tooltips
$.each(symbolDescriptions, function (key, description) {
$("abbr[data-sym-key=" + key + "]").tooltip({
e.preventDefault();
interface.getHistory(rspamd, tables, neighbours, checked_server);
});
- $("#selSymOrder").unbind().change(function() {
+ $("#selSymOrder").unbind().change(function () {
interface.getHistory(rspamd, tables, neighbours, checked_server);
});
});
}
- interface.getErrors = function(rspamd, tables, neighbours, checked_server) {
+ interface.getErrors = function (rspamd, tables, neighbours, checked_server) {
if (rspamd.read_only) return;
if (checked_server !== "All SERVERS") {
});
};
- interface.setup = function(rspamd, tables) {
+ interface.setup = function (rspamd, tables) {
};
return interface;
});
// Public functions
interface.alertMessage = alertMessage;
- interface.setup = function() {
+ interface.setup = function () {
$("#selData").change(function () {
selData = this.value;
tabClick("#throughput_nav");
selData = tab_graph.setup();
};
- interface.connect = function() {
+ interface.connect = function () {
if (isLogged()) {
var data = JSON.parse(sessionStorage.getItem("Credentials"));
});
};
- interface.queryLocal = function(req_url, on_success, on_error, method, headers, params) {
+ interface.queryLocal = function (req_url, on_success, on_error, method, headers, params) {
var req_params = {
type: method,
jsonp: false,
xhr.setRequestHeader("Password", getPassword());
if (headers) {
- $.each(headers, function(hname, hvalue) {
+ $.each(headers, function (hname, hvalue) {
xhr.setRequestHeader(hname, hvalue);
});
}
alertMessage("alert-success", "Data saved");
}
},
- error: function(jqXHR, textStatus, errorThrown) {
+ error: function (jqXHR, textStatus, errorThrown) {
if (on_error) {
on_error("local", jqXHR, textStatus, errorThrown);
}
}
};
if (params) {
- $.each(params, function(k, v) {
+ $.each(params, function (k, v) {
req_params[k] = v;
});
}
$.ajax(req_params);
};
- interface.queryNeighbours = function(req_url, on_success, on_error, method, headers, params, req_data) {
+ interface.queryNeighbours = function (req_url, on_success, on_error, method, headers, params, req_data) {
$.ajax({
dataType: "json",
type: "GET",
xhr.setRequestHeader("Password", getPassword());
if (headers) {
- $.each(headers, function(hname, hvalue) {
+ $.each(headers, function (hname, hvalue) {
xhr.setRequestHeader(hname, hvalue);
});
}
}
}
},
- error: function(jqXHR, textStatus, errorThrown) {
+ error: function (jqXHR, textStatus, errorThrown) {
neighbours_status[ind].status = false;
neighbours_status[ind].checked = true;
if (on_error) {
// error display
};
if (params) {
- $.each(params, function(k, v) {
+ $.each(params, function (k, v) {
req_params[k] = v;
});
}
});
};
- interface.drawPie = function(obj, id, data, conf) {
+ interface.drawPie = function (obj, id, data, conf) {
if (obj) {
obj.updateProp("data.content",
data.filter(function (elt) {
*/
define(["jquery", "d3pie", "humanize"],
- function($, d3pie, Humanize) {
+ function ($, d3pie, Humanize) {
// @ ms to date
function msToTime(seconds) {
/* eslint-disable no-bitwise */
}
// Public API
var interface = {
- statWidgets: function(rspamd, graphs, checked_server) {
- rspamd.queryNeighbours("/auth", function(neighbours_status) {
+ statWidgets: function (rspamd, graphs, checked_server) {
+ rspamd.queryNeighbours("/auth", function (neighbours_status) {
var neighbours_sum = {
version: neighbours_status[0].data.version,
auth: "ok",
*/
define(["jquery", "footable"],
- function($) {
+ function ($) {
var interface = {};
var ft = {};
});
// For better mean calculations
- var avg_freq = freqs.sort(function(a, b) {
+ var avg_freq = freqs.sort(function (a, b) {
return Number(a) < Number(b);
- }).reduce(function(f1, acc) {
+ }).reduce(function (f1, acc) {
return f1 + acc;
}) / (freqs.length != 0 ? freqs.length : 1.0);
var mult = 1.0;
return [items, distinct_groups];
}
// @get symbols into modal form
- interface.getSymbols = function(rspamd, tables, checked_server) {
+ interface.getSymbols = function (rspamd, tables, checked_server) {
$.ajax({
dataType: "json",
success: function (data) {
var items = process_symbols_data(data);
FooTable.groupFilter = FooTable.Filtering.extend({
- construct : function(instance) {
+ construct : function (instance) {
this._super(instance);
this.groups = items[1];
this.def = "Any group";
this.$group = null;
},
- $create : function() {
+ $create : function () {
this._super();
var self = this, $form_grp = $("<div/>", {
"class" : "form-group"
text : self.def
})).appendTo($form_grp);
- $.each(self.groups, function(i, group) {
+ $.each(self.groups, function (i, group) {
self.$group.append($("<option/>").text(group));
});
},
- _onStatusDropdownChanged : function(e) {
+ _onStatusDropdownChanged : function (e) {
var self = e.data.self, selected = $(this).val();
if (selected !== self.def) {
self.addFilter("group", selected, ["group"]);
}
self.filter();
},
- draw : function() {
+ draw : function () {
this._super();
var group = this.find("group");
if (group instanceof FooTable.Filter) {
{"name":"symbol", "title":"Symbol", "style":{"font-size":"11px"}},
{"name":"description", "title":"Description", "breakpoints":"xs sm", "style":{"font-size":"11px"}},
{"name":"weight", "title":"Score", "style":{"font-size":"11px"}},
- {"name":"frequency", "title":"Frequency", "breakpoints":"xs sm", "style":{"font-size":"11px"}, "sortValue": function(value) { return Number(value).toFixed(2); }},
+ {"name":"frequency", "title":"Frequency", "breakpoints":"xs sm", "style":{"font-size":"11px"}, "sortValue": function (value) { return Number(value).toFixed(2); }},
{"name":"time", "title":"Avg. time", "breakpoints":"xs sm", "style":{"font-size":"11px"}},
{"name":"save", "title":"Save", "style":{"font-size":"11px"}},
],
rspamd.alertMessage("alert-modal alert-error", data.statusText);
}
});
- $(document).on("click", "#symbolsTable :button", function(event) {
+ $(document).on("click", "#symbolsTable :button", function (event) {
var value = $(this).data("save");
if (!value) return;
saveSymbols(rspamd, "./savesymbols", "symbolsTable", value == "cluster");
});
};
- interface.setup = function(rspamd, tables) {
+ interface.setup = function (rspamd, tables) {
$("#updateSymbols").on("click", function (e) {
e.preventDefault();
$.ajax({
*/
define(["jquery"],
- function($) {
+ function ($) {
var interface = {};
function cleanTextUpload(source) {
});
}
- interface.setup = function(rspamd) {
+ interface.setup = function (rspamd) {
$("textarea").change(function () {
if ($(this).val().length !== "") {
$(this).closest("form").find("button").removeAttr("disabled").removeClass("disabled");
(window.location.pathname !== "/" ? window.location.pathname : "") +
" - Rspamd Web Interface";
-define("d3.global", ["d3"], function(_) {
+define("d3.global", ["d3"], function (_) {
d3 = _;
});
// Load main UI
require(["domReady"],
- function(domReady) {
+ function (domReady) {
domReady(function () {
require(["jquery", "d3", "app/rspamd"],
function ($, d3, rspamd) {