Futher JS code style fixestags/1.7.8
@@ -134,7 +134,7 @@ jobs: | |||
paths: | |||
- node_modules | |||
key: v1-dependencies-{{ checksum "package.json" }} | |||
- run: ./node_modules/.bin/eslint ./ | |||
- run: ./node_modules/.bin/eslint -v && ./node_modules/.bin/eslint ./ | |||
workflows: | |||
version: 2 |
@@ -2,7 +2,89 @@ | |||
"env": { | |||
"browser": true | |||
}, | |||
"extends": "eslint:all", | |||
"rules": { | |||
"newline-per-chained-call": "off" | |||
"array-bracket-newline": ["error", "consistent"], | |||
"camelcase": "off", | |||
"capitalized-comments": "off", | |||
"comma-dangle": ["error", "only-multiline"], | |||
"curly": ["error", "multi-line"], | |||
"dot-location": ["error", "property"], | |||
"func-names": "off", | |||
// "func-style": ["error", "declaration"], | |||
"id-length": ["error", { "min": 1 }], | |||
// "max-len": ["error", { "code": 120 }], | |||
"max-params": ["warn", 9], | |||
"max-statements": ["warn", 25], | |||
"multiline-comment-style": "off", | |||
"multiline-ternary": ["error", "always-multiline"], | |||
"newline-per-chained-call": ["error", { "ignoreChainWithDepth": 5 }], | |||
"no-extra-parens": ["error", "functions"], | |||
"no-implicit-globals": "off", | |||
"no-magic-numbers": "off", | |||
"no-plusplus": "off", | |||
"no-ternary": "off", | |||
// "no-use-before-define": ["error", { "functions": false }], | |||
"no-var": "off", | |||
"object-curly-newline": ["error", { "consistent": true }], | |||
"object-property-newline": ["error", { "allowAllPropertiesOnSameLine": true }], | |||
"object-shorthand": "off", | |||
"one-var": "off", | |||
"padded-blocks": "off", | |||
"prefer-arrow-callback": "off", | |||
"prefer-destructuring": "off", | |||
"prefer-template": "off", | |||
"quote-props" : ["error", "consistent-as-needed"], | |||
"require-jsdoc": "off", | |||
"space-before-function-paren": ["error", { | |||
"anonymous": "always", | |||
"named": "never" | |||
}], | |||
"vars-on-top": "off", | |||
// Temporarily disabled rules | |||
"array-callback-return": "off", | |||
"array-element-newline": "off", | |||
"block-scoped-var": "off", | |||
"brace-style": "off", | |||
"callback-return": "off", | |||
"consistent-return": "off", | |||
"consistent-this": "off", | |||
"default-case": "off", | |||
"eqeqeq": "off", | |||
"func-style": "off", | |||
"function-paren-newline": "off", | |||
"global-require": "off", | |||
"guard-for-in": "off", | |||
"init-declarations": "off", | |||
"key-spacing": "off", | |||
"line-comment-position": "off", | |||
"max-len": "off", | |||
"max-lines": "off", | |||
"max-lines-per-function": "off", | |||
"max-statements-per-line": "off", | |||
"new-cap": "off", | |||
"no-else-return": "off", | |||
"no-empty": "off", | |||
"no-empty-function": "off", | |||
"no-eq-null": "off", | |||
"no-implicit-coercion": "off", | |||
"no-inline-comments": "off", | |||
"no-loop-func": "off", | |||
"no-multi-assign": "off", | |||
"no-negated-condition": "off", | |||
"no-param-reassign": "off", | |||
"no-redeclare": "off", | |||
"no-shadow": "off", | |||
"no-undef": "off", | |||
"no-undefined": "off", | |||
"no-underscore-dangle": "off", | |||
"no-use-before-define": "off", | |||
"one-var-declaration-per-line": "off", | |||
"prefer-spread": "off", | |||
"sort-keys": "off", | |||
"sort-vars": "off", | |||
"strict": "off" | |||
} | |||
} |
@@ -23,7 +23,7 @@ | |||
*/ | |||
define(["jquery"], | |||
function($) { | |||
function ($) { | |||
var interface = {}; | |||
function save_map_success(rspamd) { | |||
@@ -51,13 +51,12 @@ define(["jquery"], | |||
error: function (data) { | |||
save_map_error(rspamd, "local", null, null, data.statusText); | |||
}, | |||
success: function() { save_map_success(rspamd); }, | |||
success: function () { save_map_success(rspamd); }, | |||
}); | |||
} | |||
// @get maps id | |||
function getMaps(rspamd) { | |||
var items = []; | |||
var $listmaps = $("#listMaps"); | |||
$listmaps.closest(".widget-box").hide(); | |||
$.ajax({ | |||
@@ -112,7 +111,7 @@ define(["jquery"], | |||
disabled = "disabled=\"disabled\""; | |||
} | |||
$("#"+item.map).remove(); | |||
$("#" + item.map).remove(); | |||
$("<form class=\"form-horizontal form-map\" method=\"post\" action=\"savemap\" data-type=\"map\" id=\"" + | |||
item.map + "\" style=\"display:none\">" + | |||
"<textarea class=\"list-textarea\"" + disabled + ">" + text + | |||
@@ -222,10 +221,10 @@ define(["jquery"], | |||
} | |||
} | |||
$("#saveActionsBtn").on("click", function() { | |||
$("#saveActionsBtn").on("click", function () { | |||
saveActions(rspamd.queryLocal); | |||
}); | |||
$("#saveActionsClusterBtn").on("click", function() { | |||
$("#saveActionsClusterBtn").on("click", function () { | |||
saveActions(rspamd.queryNeighbours); | |||
}); | |||
}, | |||
@@ -233,11 +232,11 @@ define(["jquery"], | |||
} | |||
// @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(); | |||
@@ -269,7 +268,7 @@ define(["jquery"], | |||
var id = $(form).attr("id"); | |||
var data = $("#" + id).find("textarea").val(); | |||
rspamd.queryNeighbours(action, save_map_success, save_map_error, "POST", { | |||
"Map": id, | |||
Map: id, | |||
}, { | |||
data: data, | |||
dataType: "text", |
@@ -24,7 +24,7 @@ | |||
*/ | |||
define(["jquery", "d3evolution", "footable"], | |||
function($, D3Evolution, unused) { | |||
function ($, D3Evolution) { | |||
var rrd_pie_config = { | |||
header: {}, | |||
size: { | |||
@@ -95,7 +95,7 @@ define(["jquery", "d3evolution", "footable"], | |||
interpolate: getSelector("selInterpolate"), | |||
convert: getSelector("selConvert"), | |||
})); | |||
$("#selYScale").change(function() { | |||
$("#selYScale").change(function () { | |||
graph.yScale(this.value); | |||
}); | |||
$("#selConvert").change(function () { | |||
@@ -124,7 +124,7 @@ define(["jquery", "d3evolution", "footable"], | |||
return { | |||
label: graph_options.legend.entries[i].label, | |||
value: value ^ 0, | |||
value: value ^ 0, // eslint-disable-line no-bitwise | |||
min: +yExtents[0].toFixed(6), | |||
avg: +avg.toFixed(6), | |||
max: +yExtents[1].toFixed(6), | |||
@@ -156,11 +156,11 @@ define(["jquery", "d3evolution", "footable"], | |||
}, | |||
columns: [ | |||
{name: "label", title: "Action"}, | |||
{name: "value", title: "Messages", defaultContent: ""}, | |||
{name: "min", title: "Minimum, " + unit, defaultContent: ""}, | |||
{name: "avg", title: "Average, " + unit, defaultContent: ""}, | |||
{name: "max", title: "Maximum, " + unit, defaultContent: ""}, | |||
{name: "last", title: "Last, " + unit}, | |||
{name: "value", title: "Messages", defaultContent: ""}, | |||
{name: "min", title: "Minimum, " + unit, defaultContent: ""}, | |||
{name: "avg", title: "Average, " + unit, defaultContent: ""}, | |||
{name: "max", title: "Maximum, " + unit, defaultContent: ""}, | |||
{name: "last", title: "Last, " + unit}, | |||
], | |||
rows: rows | |||
}); | |||
@@ -169,7 +169,7 @@ define(["jquery", "d3evolution", "footable"], | |||
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 | |||
@@ -263,7 +263,7 @@ define(["jquery", "d3evolution", "footable"], | |||
url: neighbours[checked_server].url + "graph", | |||
jsonp: false, | |||
data: { | |||
"type": type | |||
type: type | |||
}, | |||
beforeSend: function (xhr) { | |||
xhr.setRequestHeader("Password", rspamd.getPassword()); | |||
@@ -278,7 +278,7 @@ define(["jquery", "d3evolution", "footable"], | |||
}); | |||
}; | |||
interface.setup = function() { | |||
interface.setup = function () { | |||
// Handling mouse events on overlapping elements | |||
$("#rrd-pie").mouseover(function () { | |||
$("#rrd-pie").css("z-index", "200"); |
@@ -23,7 +23,7 @@ | |||
*/ | |||
define(["jquery", "footable", "humanize"], | |||
function($, _, Humanize) { | |||
function ($, _, Humanize) { | |||
var interface = {}; | |||
var ft = {}; | |||
var htmlEscapes = { | |||
@@ -36,11 +36,11 @@ define(["jquery", "footable", "humanize"], | |||
"`": "`", | |||
"=": "=" | |||
}; | |||
var htmlEscaper = /[&<>"'\/`=]/g; | |||
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]; | |||
}); | |||
}; | |||
@@ -62,7 +62,7 @@ define(["jquery", "footable", "humanize"], | |||
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; | |||
@@ -102,10 +102,10 @@ define(["jquery", "footable", "humanize"], | |||
} | |||
item.score = { | |||
"options": { | |||
"sortValue": item.score | |||
options: { | |||
sortValue: item.score | |||
}, | |||
"value": score_content | |||
value: score_content | |||
}; | |||
if (item.user == null) { | |||
@@ -140,7 +140,7 @@ define(["jquery", "footable", "humanize"], | |||
var full = shrt = ""; | |||
if (smtp) { | |||
full = "[" + item.rcpt_smtp.join(", ") + "] "; | |||
shrt = "[" + item.rcpt_smtp.slice(0, rcpt_lim).join(",​") + more("rcpt_smtp") + "]"; | |||
shrt = "[" + item.rcpt_smtp.slice(0, rcpt_lim).join(",​") + more("rcpt_smtp") + "]"; | |||
if (mime) { | |||
full += " "; | |||
shrt += " "; | |||
@@ -154,16 +154,16 @@ define(["jquery", "footable", "humanize"], | |||
} | |||
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) { | |||
var str = "<strong><abbr data-sym-key=\"" + key + "\">" + sym.name + "</abbr></strong>" + "(" + sym.score + ")"; | |||
var str = "<strong><abbr data-sym-key=\"" + key + "\">" + sym.name + "</abbr></strong>(" + sym.score + ")"; | |||
// Store description for tooltip | |||
symbolDescriptions[key] = sym.description; | |||
} else { | |||
var str = "<strong>" + sym.name + "</strong>" + "(" + sym.score + ")"; | |||
var str = "<strong>" + sym.name + "</strong>(" + sym.score + ")"; | |||
} | |||
if (sym.options) { | |||
@@ -171,26 +171,26 @@ define(["jquery", "footable", "humanize"], | |||
} | |||
item.symbols[key].str = str; | |||
}); | |||
item.symbols = Object.keys(item.symbols). | |||
map(function(key) { | |||
item.symbols = Object.keys(item.symbols) | |||
.map(function (key) { | |||
return item.symbols[key]; | |||
}). | |||
sort(compare). | |||
map(function(e) { return e.str; }). | |||
join("<br>\n"); | |||
}) | |||
.sort(compare) | |||
.map(function (e) { return e.str; }) | |||
.join("<br>\n"); | |||
item.time = { | |||
"value": unix_time_format(item.unix_time), | |||
"options": { | |||
"sortValue": item.unix_time | |||
value: unix_time_format(item.unix_time), | |||
options: { | |||
sortValue: item.unix_time | |||
} | |||
}; | |||
var scan_time = item.time_real.toFixed(3) + " / " + | |||
item.time_virtual.toFixed(3); | |||
item.scan_time = { | |||
"options": { | |||
"sortValue": item.time_real | |||
options: { | |||
sortValue: item.time_real | |||
}, | |||
"value": scan_time | |||
value: scan_time | |||
}; | |||
item.id = item["message-id"]; | |||
@@ -221,15 +221,15 @@ define(["jquery", "footable", "humanize"], | |||
item.time = unix_time_format(item.unix_time); | |||
preprocess_item(item); | |||
item.scan_time = { | |||
"options": { | |||
"sortValue": item.scan_time | |||
options: { | |||
sortValue: item.scan_time | |||
}, | |||
"value": item.scan_time | |||
value: item.scan_time | |||
}; | |||
item.time = { | |||
"value": unix_time_format(item.unix_time), | |||
"options": { | |||
"sortValue": item.unix_time | |||
value: unix_time_format(item.unix_time), | |||
options: { | |||
sortValue: item.unix_time | |||
} | |||
}; | |||
@@ -241,9 +241,9 @@ define(["jquery", "footable", "humanize"], | |||
function columns_v2() { | |||
return [{ | |||
"name": "id", | |||
"title": "ID", | |||
"style": { | |||
name: "id", | |||
title: "ID", | |||
style: { | |||
"font-size": "11px", | |||
"minWidth": 130, | |||
"overflow": "hidden", | |||
@@ -252,106 +252,106 @@ define(["jquery", "footable", "humanize"], | |||
"whiteSpace": "normal" | |||
} | |||
}, { | |||
"name": "ip", | |||
"title": "IP address", | |||
"breakpoints": "xs sm md", | |||
"style": { | |||
name: "ip", | |||
title: "IP address", | |||
breakpoints: "xs sm md", | |||
style: { | |||
"font-size": "11px", | |||
"minWidth": 88 | |||
} | |||
}, { | |||
"name": "sender_mime", | |||
"title": "[Envelope From] From", | |||
"breakpoints": "xs sm md", | |||
"style": { | |||
name: "sender_mime", | |||
title: "[Envelope From] From", | |||
breakpoints: "xs sm md", | |||
style: { | |||
"font-size": "11px", | |||
"minWidth": 100, | |||
"maxWidth": 200, | |||
"word-wrap": "break-word" | |||
} | |||
}, { | |||
"name": "rcpt_mime_short", | |||
"title": "[Envelope To] To/Cc/Bcc", | |||
"breakpoints": "xs sm md", | |||
"style": { | |||
name: "rcpt_mime_short", | |||
title: "[Envelope To] To/Cc/Bcc", | |||
breakpoints: "xs sm md", | |||
style: { | |||
"font-size": "11px", | |||
"minWidth": 100, | |||
"maxWidth": 200, | |||
"word-wrap": "break-word" | |||
} | |||
}, { | |||
"name": "rcpt_mime", | |||
"title": "[Envelope To] To/Cc/Bcc", | |||
"breakpoints": "all", | |||
"style": { | |||
name: "rcpt_mime", | |||
title: "[Envelope To] To/Cc/Bcc", | |||
breakpoints: "all", | |||
style: { | |||
"font-size": "11px", | |||
"word-wrap": "break-word" | |||
} | |||
}, { | |||
"name": "subject", | |||
"title": "Subject", | |||
"breakpoints": "xs sm md", | |||
"style": { | |||
name: "subject", | |||
title: "Subject", | |||
breakpoints: "xs sm md", | |||
style: { | |||
"font-size": "11px", | |||
"word-break": "break-all", | |||
"minWidth": 150 | |||
} | |||
}, { | |||
"name": "action", | |||
"title": "Action", | |||
"style": { | |||
name: "action", | |||
title: "Action", | |||
style: { | |||
"font-size": "11px", | |||
"minwidth": 82 | |||
} | |||
}, { | |||
"name": "score", | |||
"title": "Score", | |||
"style": { | |||
name: "score", | |||
title: "Score", | |||
style: { | |||
"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", | |||
"breakpoints": "all", | |||
"style": { | |||
name: "symbols", | |||
title: "Symbols", | |||
breakpoints: "all", | |||
style: { | |||
"font-size": "11px", | |||
"width": 550, | |||
"maxWidth": 550 | |||
} | |||
}, { | |||
"name": "size", | |||
"title": "Msg size", | |||
"breakpoints": "xs sm md", | |||
"style": { | |||
name: "size", | |||
title: "Msg size", | |||
breakpoints: "xs sm md", | |||
style: { | |||
"font-size": "11px", | |||
"minwidth": 50, | |||
}, | |||
"formatter": Humanize.compactInteger | |||
formatter: Humanize.compactInteger | |||
}, { | |||
"name": "scan_time", | |||
"title": "Scan time", | |||
"breakpoints": "xs sm md", | |||
"style": { | |||
name: "scan_time", | |||
title: "Scan time", | |||
breakpoints: "xs sm md", | |||
style: { | |||
"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", | |||
"name": "time", | |||
"title": "Time", | |||
"style": { | |||
sorted: true, | |||
direction: "DESC", | |||
name: "time", | |||
title: "Time", | |||
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", | |||
"breakpoints": "xs sm md", | |||
"style": { | |||
name: "user", | |||
title: "Authenticated user", | |||
breakpoints: "xs sm md", | |||
style: { | |||
"font-size": "11px", | |||
"minWidth": 100, | |||
"maxWidth": 130, | |||
@@ -362,9 +362,9 @@ define(["jquery", "footable", "humanize"], | |||
function columns_legacy() { | |||
return [{ | |||
"name": "id", | |||
"title": "ID", | |||
"style": { | |||
name: "id", | |||
title: "ID", | |||
style: { | |||
"font-size": "11px", | |||
"width": 300, | |||
"maxWidth": 300, | |||
@@ -374,72 +374,72 @@ define(["jquery", "footable", "humanize"], | |||
"whiteSpace": "nowrap" | |||
} | |||
}, { | |||
"name": "ip", | |||
"title": "IP address", | |||
"breakpoints": "xs sm", | |||
"style": { | |||
name: "ip", | |||
title: "IP address", | |||
breakpoints: "xs sm", | |||
style: { | |||
"font-size": "11px", | |||
"width": 150, | |||
"maxWidth": 150 | |||
} | |||
}, { | |||
"name": "action", | |||
"title": "Action", | |||
"style": { | |||
name: "action", | |||
title: "Action", | |||
style: { | |||
"font-size": "11px", | |||
"width": 110, | |||
"maxWidth": 110 | |||
} | |||
}, { | |||
"name": "score", | |||
"title": "Score", | |||
"style": { | |||
name: "score", | |||
title: "Score", | |||
style: { | |||
"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", | |||
"breakpoints": "all", | |||
"style": { | |||
name: "symbols", | |||
title: "Symbols", | |||
breakpoints: "all", | |||
style: { | |||
"font-size": "11px", | |||
"width": 550, | |||
"maxWidth": 550 | |||
} | |||
}, { | |||
"name": "size", | |||
"title": "Message size", | |||
"breakpoints": "xs sm", | |||
"style": { | |||
name: "size", | |||
title: "Message size", | |||
breakpoints: "xs sm", | |||
style: { | |||
"font-size": "11px", | |||
"width": 120, | |||
"maxWidth": 120 | |||
}, | |||
"formatter": Humanize.compactInteger | |||
formatter: Humanize.compactInteger | |||
}, { | |||
"name": "scan_time", | |||
"title": "Scan time", | |||
"breakpoints": "xs sm", | |||
"style": { | |||
name: "scan_time", | |||
title: "Scan time", | |||
breakpoints: "xs sm", | |||
style: { | |||
"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", | |||
"name": "time", | |||
"title": "Time", | |||
"style": { | |||
sorted: true, | |||
direction: "DESC", | |||
name: "time", | |||
title: "Time", | |||
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", | |||
"breakpoints": "xs sm", | |||
"style": { | |||
name: "user", | |||
title: "Authenticated user", | |||
breakpoints: "xs sm", | |||
style: { | |||
"font-size": "11px", | |||
"width": 200, | |||
"maxWidth": 200 | |||
@@ -448,13 +448,13 @@ define(["jquery", "footable", "humanize"], | |||
} | |||
var process_functions = { | |||
"2": process_history_v2, | |||
"legacy": process_history_legacy | |||
2: process_history_v2, | |||
legacy: process_history_legacy | |||
}; | |||
var columns = { | |||
"2": columns_v2, | |||
"legacy": columns_legacy | |||
2: columns_v2, | |||
legacy: columns_legacy | |||
}; | |||
function process_history_data(data) { | |||
@@ -485,24 +485,24 @@ define(["jquery", "footable", "humanize"], | |||
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" | |||
class : "form-group" | |||
}).append($("<label/>", { | |||
"class" : "sr-only", | |||
class : "sr-only", | |||
text : "Action" | |||
})).prependTo(self.$form); | |||
self.$action = $("<select/>", { | |||
"class" : "form-control" | |||
class : "form-control" | |||
}).on("change", { | |||
self : self | |||
}, self._onStatusDropdownChanged).append( | |||
@@ -510,11 +510,11 @@ define(["jquery", "footable", "humanize"], | |||
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") { | |||
@@ -527,7 +527,7 @@ define(["jquery", "footable", "humanize"], | |||
} | |||
self.filter(); | |||
}, | |||
draw : function() { | |||
draw : function () { | |||
this._super(); | |||
var action = this.find("action"); | |||
if (action instanceof FooTable.Filter) { | |||
@@ -542,13 +542,13 @@ define(["jquery", "footable", "humanize"], | |||
} | |||
}); | |||
var drawTooltips = function() { | |||
var drawTooltips = function () { | |||
// Update symbol description tooltips | |||
$.each(symbolDescriptions, function (key, description) { | |||
$("abbr[data-sym-key=" + key + "]").tooltip({ | |||
"placement": "bottom", | |||
"html": true, | |||
"title": description | |||
placement: "bottom", | |||
html: true, | |||
title: description | |||
}); | |||
}); | |||
}; | |||
@@ -585,36 +585,34 @@ define(["jquery", "footable", "humanize"], | |||
var items = process_history_data(data); | |||
ft.history = FooTable.init("#historyTable", { | |||
"columns": get_history_columns(data), | |||
"rows": items, | |||
"paging": { | |||
"enabled": true, | |||
"limit": 5, | |||
"size": 25 | |||
columns: get_history_columns(data), | |||
rows: items, | |||
paging: { | |||
enabled: true, | |||
limit: 5, | |||
size: 25 | |||
}, | |||
"filtering": { | |||
"enabled": true, | |||
"position": "left", | |||
"connectors": false | |||
filtering: { | |||
enabled: true, | |||
position: "left", | |||
connectors: false | |||
}, | |||
"sorting": { | |||
"enabled": true | |||
sorting: { | |||
enabled: true | |||
}, | |||
"components": { | |||
"filtering": FooTable.actionFilter | |||
components: { | |||
filtering: FooTable.actionFilter | |||
}, | |||
"on": { | |||
on: { | |||
"ready.ft.table": drawTooltips, | |||
"after.ft.sorting": drawTooltips, | |||
"after.ft.paging": drawTooltips, | |||
"after.ft.filtering": drawTooltips | |||
} | |||
}); | |||
} else { | |||
if (ft.history) { | |||
ft.history.destroy(); | |||
ft.history = undefined; | |||
} | |||
} else if (ft.history) { | |||
ft.history.destroy(); | |||
ft.history = undefined; | |||
} | |||
}); | |||
} | |||
@@ -632,25 +630,25 @@ define(["jquery", "footable", "humanize"], | |||
success: function (data) { | |||
var items = process_history_data(data); | |||
ft.history = FooTable.init("#historyTable", { | |||
"columns": get_history_columns(data), | |||
"rows": items, | |||
"paging": { | |||
"enabled": true, | |||
"limit": 5, | |||
"size": 25 | |||
columns: get_history_columns(data), | |||
rows: items, | |||
paging: { | |||
enabled: true, | |||
limit: 5, | |||
size: 25 | |||
}, | |||
"filtering": { | |||
"enabled": true, | |||
"position": "left", | |||
"connectors": false | |||
filtering: { | |||
enabled: true, | |||
position: "left", | |||
connectors: false | |||
}, | |||
"sorting": { | |||
"enabled": true | |||
sorting: { | |||
enabled: true | |||
}, | |||
"components": { | |||
"filtering": FooTable.actionFilter | |||
components: { | |||
filtering: FooTable.actionFilter | |||
}, | |||
"on": { | |||
on: { | |||
"ready.ft.table": drawTooltips, | |||
"after.ft.sorting": drawTooltips, | |||
"after.ft.paging": drawTooltips, | |||
@@ -665,7 +663,7 @@ define(["jquery", "footable", "humanize"], | |||
e.preventDefault(); | |||
interface.getHistory(rspamd, tables, neighbours, checked_server); | |||
}); | |||
$("#selSymOrder").unbind().change(function() { | |||
$("#selSymOrder").unbind().change(function () { | |||
interface.getHistory(rspamd, tables, neighbours, checked_server); | |||
}); | |||
@@ -673,7 +671,7 @@ define(["jquery", "footable", "humanize"], | |||
$("#resetHistory").off("click"); | |||
$("#resetHistory").on("click", function (e) { | |||
e.preventDefault(); | |||
if (!confirm("Are you sure you want to reset history log?")) { | |||
if (!confirm("Are you sure you want to reset history log?")) { // eslint-disable-line no-alert | |||
return; | |||
} | |||
if (ft.history) { | |||
@@ -685,7 +683,7 @@ define(["jquery", "footable", "humanize"], | |||
ft.errors = undefined; | |||
} | |||
if (checked_server === "All SERVERS") { | |||
rspamd.queryNeighbours("errors", function (data) { | |||
rspamd.queryNeighbours("errors", function () { | |||
interface.getHistory(rspamd, tables, neighbours, checked_server); | |||
interface.getErrors(rspamd, tables, neighbours, checked_server); | |||
}); | |||
@@ -719,32 +717,32 @@ define(["jquery", "footable", "humanize"], | |||
); | |||
}); | |||
ft.errors = FooTable.init("#errorsLog", { | |||
"columns": [ | |||
{"sorted": true, "direction": "DESC", "name":"ts", "title":"Time", "style":{"font-size":"11px", "width":300, "maxWidth":300}}, | |||
{"name":"type", "title":"Worker type", "breakpoints":"xs sm", "style":{"font-size":"11px", "width":150, "maxWidth":150}}, | |||
{"name":"pid", "title":"PID", "breakpoints":"xs sm", "style":{"font-size":"11px", "width":110, "maxWidth":110}}, | |||
{"name":"module", "title":"Module", "style":{"font-size":"11px"}}, | |||
{"name":"id", "title":"Internal ID", "style":{"font-size":"11px"}}, | |||
{"name":"message", "title":"Message", "breakpoints":"xs sm", "style":{"font-size":"11px"}}, | |||
columns: [ | |||
{sorted: true, direction: "DESC", name:"ts", title:"Time", style:{"font-size":"11px", "width":300, "maxWidth":300}}, | |||
{name:"type", title:"Worker type", breakpoints:"xs sm", style:{"font-size":"11px", "width":150, "maxWidth":150}}, | |||
{name:"pid", title:"PID", breakpoints:"xs sm", style:{"font-size":"11px", "width":110, "maxWidth":110}}, | |||
{name:"module", title:"Module", style:{"font-size":"11px"}}, | |||
{name:"id", title:"Internal ID", style:{"font-size":"11px"}}, | |||
{name:"message", title:"Message", breakpoints:"xs sm", style:{"font-size":"11px"}}, | |||
], | |||
"rows": data, | |||
"paging": { | |||
"enabled": true, | |||
"limit": 5, | |||
"size": 25 | |||
rows: data, | |||
paging: { | |||
enabled: true, | |||
limit: 5, | |||
size: 25 | |||
}, | |||
"filtering": { | |||
"enabled": true, | |||
"position": "left", | |||
"connectors": false | |||
filtering: { | |||
enabled: true, | |||
position: "left", | |||
connectors: false | |||
}, | |||
"sorting": { | |||
"enabled": true | |||
sorting: { | |||
enabled: true | |||
} | |||
}); | |||
} | |||
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") { | |||
@@ -781,7 +779,6 @@ define(["jquery", "footable", "humanize"], | |||
}); | |||
}; | |||
interface.setup = function(rspamd, tables) { | |||
}; | |||
interface.setup = function () {}; | |||
return interface; | |||
}); |
@@ -82,7 +82,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, | |||
stopTimers(); | |||
if (tab_id === "#refresh") { | |||
tab_id = "#" + $(".navbar-nav .active > a" ).attr("id"); | |||
tab_id = "#" + $(".navbar-nav .active > a").attr("id"); | |||
} | |||
switch (tab_id) { | |||
@@ -179,7 +179,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, | |||
// Public functions | |||
interface.alertMessage = alertMessage; | |||
interface.setup = function() { | |||
interface.setup = function () { | |||
$("#selData").change(function () { | |||
selData = this.value; | |||
tabClick("#throughput_nav"); | |||
@@ -236,7 +236,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, | |||
selData = tab_graph.setup(); | |||
}; | |||
interface.connect = function() { | |||
interface.connect = function () { | |||
if (isLogged()) { | |||
var data = JSON.parse(sessionStorage.getItem("Credentials")); | |||
@@ -267,7 +267,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, | |||
$("#connectForm").on("submit", function (e) { | |||
e.preventDefault(); | |||
var password = $("#connectPassword").val(); | |||
if (!/^[\u0000-\u007f]*$/.test(password)) { | |||
if (!(/^[\u0020-\u007e]*$/).test(password)) { | |||
alertMessage("alert-modal alert-error", "Invalid characters in the password"); | |||
$("#connectPassword").focus(); | |||
return; | |||
@@ -314,7 +314,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, | |||
}); | |||
}; | |||
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, | |||
@@ -322,7 +322,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, | |||
xhr.setRequestHeader("Password", getPassword()); | |||
if (headers) { | |||
$.each(headers, function(hname, hvalue) { | |||
$.each(headers, function (hname, hvalue) { | |||
xhr.setRequestHeader(hname, hvalue); | |||
}); | |||
} | |||
@@ -336,7 +336,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, | |||
alertMessage("alert-success", "Data saved"); | |||
} | |||
}, | |||
error: function(jqXHR, textStatus, errorThrown) { | |||
error: function (jqXHR, textStatus, errorThrown) { | |||
if (on_error) { | |||
on_error("local", jqXHR, textStatus, errorThrown); | |||
} | |||
@@ -346,14 +346,14 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, | |||
} | |||
}; | |||
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", | |||
@@ -370,7 +370,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, | |||
url: window.location.href | |||
} | |||
}; | |||
} else { | |||
} else { | |||
neighbours = data; | |||
} | |||
var neighbours_status = []; | |||
@@ -395,7 +395,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, | |||
xhr.setRequestHeader("Password", getPassword()); | |||
if (headers) { | |||
$.each(headers, function(hname, hvalue) { | |||
$.each(headers, function (hname, hvalue) { | |||
xhr.setRequestHeader(hname, hvalue); | |||
}); | |||
} | |||
@@ -419,7 +419,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, | |||
} | |||
} | |||
}, | |||
error: function(jqXHR, textStatus, errorThrown) { | |||
error: function (jqXHR, textStatus, errorThrown) { | |||
neighbours_status[ind].status = false; | |||
neighbours_status[ind].checked = true; | |||
if (on_error) { | |||
@@ -443,7 +443,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, | |||
// error display | |||
}; | |||
if (params) { | |||
$.each(params, function(k, v) { | |||
$.each(params, function (k, v) { | |||
req_params[k] = v; | |||
}); | |||
} | |||
@@ -456,7 +456,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, | |||
}); | |||
}; | |||
interface.drawPie = function(obj, id, data, conf) { | |||
interface.drawPie = function (obj, id, data, conf) { | |||
if (obj) { | |||
obj.updateProp("data.content", | |||
data.filter(function (elt) { | |||
@@ -466,79 +466,79 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, | |||
} else { | |||
obj = new d3pie(id, | |||
$.extend({}, { | |||
"header": { | |||
"title": { | |||
"text": "Rspamd filter stats", | |||
"fontSize": 24, | |||
"font": "open sans" | |||
header: { | |||
title: { | |||
text: "Rspamd filter stats", | |||
fontSize: 24, | |||
font: "open sans" | |||
}, | |||
"subtitle": { | |||
"color": "#999999", | |||
"fontSize": 12, | |||
"font": "open sans" | |||
subtitle: { | |||
color: "#999999", | |||
fontSize: 12, | |||
font: "open sans" | |||
}, | |||
"titleSubtitlePadding": 9 | |||
titleSubtitlePadding: 9 | |||
}, | |||
"footer": { | |||
"color": "#999999", | |||
"fontSize": 10, | |||
"font": "open sans", | |||
"location": "bottom-left" | |||
footer: { | |||
color: "#999999", | |||
fontSize: 10, | |||
font: "open sans", | |||
location: "bottom-left" | |||
}, | |||
"size": { | |||
"canvasWidth": 600, | |||
"canvasHeight": 400, | |||
"pieInnerRadius": "20%", | |||
"pieOuterRadius": "85%" | |||
size: { | |||
canvasWidth: 600, | |||
canvasHeight: 400, | |||
pieInnerRadius: "20%", | |||
pieOuterRadius: "85%" | |||
}, | |||
"data": { | |||
data: { | |||
// "sortOrder": "value-desc", | |||
"content": data.filter(function (elt) { | |||
content: data.filter(function (elt) { | |||
return elt.value > 0; | |||
}) | |||
}, | |||
"labels": { | |||
"outer": { | |||
"hideWhenLessThanPercentage": 1, | |||
"pieDistance": 30 | |||
labels: { | |||
outer: { | |||
hideWhenLessThanPercentage: 1, | |||
pieDistance: 30 | |||
}, | |||
"inner": { | |||
"hideWhenLessThanPercentage": 4 | |||
inner: { | |||
hideWhenLessThanPercentage: 4 | |||
}, | |||
"mainLabel": { | |||
"fontSize": 14 | |||
mainLabel: { | |||
fontSize: 14 | |||
}, | |||
"percentage": { | |||
"color": "#eeeeee", | |||
"fontSize": 14, | |||
"decimalPlaces": 0 | |||
percentage: { | |||
color: "#eeeeee", | |||
fontSize: 14, | |||
decimalPlaces: 0 | |||
}, | |||
"lines": { | |||
"enabled": true | |||
lines: { | |||
enabled: true | |||
}, | |||
"truncation": { | |||
"enabled": true | |||
truncation: { | |||
enabled: true | |||
} | |||
}, | |||
"tooltips": { | |||
"enabled": true, | |||
"type": "placeholder", | |||
"string": "{label}: {value} ({percentage}%)" | |||
tooltips: { | |||
enabled: true, | |||
type: "placeholder", | |||
string: "{label}: {value} ({percentage}%)" | |||
}, | |||
"effects": { | |||
"pullOutSegmentOnClick": { | |||
"effect": "back", | |||
"speed": 400, | |||
"size": 8 | |||
effects: { | |||
pullOutSegmentOnClick: { | |||
effect: "back", | |||
speed: 400, | |||
size: 8 | |||
}, | |||
"load": { | |||
"effect": "none" | |||
load: { | |||
effect: "none" | |||
} | |||
}, | |||
"misc": { | |||
"gradient": { | |||
"enabled": true, | |||
"percentage": 100 | |||
misc: { | |||
gradient: { | |||
enabled: true, | |||
percentage: 100 | |||
} | |||
} | |||
}, conf)); |
@@ -23,14 +23,16 @@ | |||
*/ | |||
define(["jquery", "d3pie", "humanize"], | |||
function($, d3pie, Humanize) { | |||
function ($, d3pie, Humanize) { | |||
// @ ms to date | |||
function msToTime(seconds) { | |||
/* eslint-disable no-bitwise */ | |||
years = seconds / 31536000 >> 0; // 3600*24*365 | |||
months = seconds % 31536000 / 2628000 >> 0; // 3600*24*365/12 | |||
days = seconds % 31536000 % 2628000 / 86400 >> 0; // 24*3600 | |||
hours = seconds % 31536000 % 2628000 % 86400 / 3600 >> 0; | |||
minutes = seconds % 31536000 % 2628000 % 86400 % 3600 / 60 >> 0; | |||
/* eslint-enable no-bitwise */ | |||
if (years > 0) { | |||
if (months > 0) { | |||
out = years + "yr " + months + "mth"; | |||
@@ -122,7 +124,7 @@ define(["jquery", "d3pie", "humanize"], | |||
"<td class=\"col4\" title=\"SStatus\"><span class=\"icon\"><i class=\"" + glyph_status + "\"></i></span></td>" + | |||
"<td class=\"col5\" title=\"short_id\">" + short_id + "</td></tr>"); | |||
$("#selSrv").append( $("<option value=\"" + key + "\">" + key + "</option>")); | |||
$("#selSrv").append($("<option value=\"" + key + "\">" + key + "</option>")); | |||
if (checked_server == key) { | |||
$("#clusterTable tbody [value=\"" + key + "\"]").prop("checked", true); | |||
@@ -141,30 +143,30 @@ define(["jquery", "d3pie", "humanize"], | |||
if (creds && creds[checked_server]) { | |||
var data = creds[checked_server].data; | |||
var new_data = [{ | |||
"color" : "#66CC00", | |||
"label" : "Clean", | |||
"data" : data.clean, | |||
"value" : data.clean | |||
color : "#66CC00", | |||
label : "Clean", | |||
data : data.clean, | |||
value : data.clean | |||
}, { | |||
"color" : "#BF8040", | |||
"label" : "Temporarily rejected", | |||
"data" : data.soft_reject, | |||
"value" : data.soft_reject | |||
color : "#BF8040", | |||
label : "Temporarily rejected", | |||
data : data.soft_reject, | |||
value : data.soft_reject | |||
}, { | |||
"color" : "#FFAD00", | |||
"label" : "Probable spam", | |||
"data" : data.probable, | |||
"value" : data.probable | |||
color : "#FFAD00", | |||
label : "Probable spam", | |||
data : data.probable, | |||
value : data.probable | |||
}, { | |||
"color" : "#436EEE", | |||
"label" : "Greylisted", | |||
"data" : data.greylist, | |||
"value" : data.greylist | |||
color : "#436EEE", | |||
label : "Greylisted", | |||
data : data.greylist, | |||
value : data.greylist | |||
}, { | |||
"color" : "#FF0000", | |||
"label" : "Rejected", | |||
"data" : data.reject, | |||
"value" : data.reject | |||
color : "#FF0000", | |||
label : "Rejected", | |||
data : data.reject, | |||
value : data.reject | |||
}]; | |||
return rspamd.drawPie(pie, "chart", new_data); | |||
@@ -172,8 +174,8 @@ define(["jquery", "d3pie", "humanize"], | |||
} | |||
// 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", | |||
@@ -189,8 +191,8 @@ define(["jquery", "d3pie", "humanize"], | |||
config_id: "" | |||
}; | |||
var status_count = 0; | |||
for(var e in neighbours_status) { | |||
if(neighbours_status[e].status === true) { | |||
for (var e in neighbours_status) { | |||
if (neighbours_status[e].status === true) { | |||
// Remove alert status | |||
localStorage.removeItem(e + "_alerted"); | |||
neighbours_sum.clean += neighbours_status[e].data.clean; | |||
@@ -206,7 +208,8 @@ define(["jquery", "d3pie", "humanize"], | |||
} | |||
neighbours_sum.uptime = Math.floor(neighbours_sum.uptime / status_count); | |||
var to_Credentials = {}; | |||
to_Credentials["All SERVERS"] = {name: "All SERVERS", | |||
to_Credentials["All SERVERS"] = { | |||
name: "All SERVERS", | |||
url: "", | |||
host: "", | |||
checked: true, |
@@ -23,7 +23,7 @@ | |||
*/ | |||
define(["jquery", "footable"], | |||
function($) { | |||
function ($) { | |||
var interface = {}; | |||
var ft = {}; | |||
@@ -126,9 +126,9 @@ define(["jquery", "footable"], | |||
}); | |||
// 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; | |||
@@ -137,7 +137,7 @@ define(["jquery", "footable"], | |||
if (avg_freq > 0.0) { | |||
while (mult * avg_freq < 1.0) { | |||
mult *= 10; | |||
exp ++; | |||
exp++; | |||
} | |||
} | |||
$.each(items, function (i, item) { | |||
@@ -153,7 +153,7 @@ define(["jquery", "footable"], | |||
return [items, distinct_groups]; | |||
} | |||
// @get symbols into modal form | |||
interface.getSymbols = function(rspamd, tables, checked_server) { | |||
interface.getSymbols = function (rspamd) { | |||
$.ajax({ | |||
dataType: "json", | |||
@@ -166,23 +166,23 @@ define(["jquery", "footable"], | |||
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" | |||
class : "form-group" | |||
}).append($("<label/>", { | |||
"class" : "sr-only", | |||
class : "sr-only", | |||
text : "Group" | |||
})).prependTo(self.$form); | |||
self.$group = $("<select/>", { | |||
"class" : "form-control" | |||
class : "form-control" | |||
}).on("change", { | |||
self : self | |||
}, self._onStatusDropdownChanged).append( | |||
@@ -190,11 +190,11 @@ define(["jquery", "footable"], | |||
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"]); | |||
@@ -203,7 +203,7 @@ define(["jquery", "footable"], | |||
} | |||
self.filter(); | |||
}, | |||
draw : function() { | |||
draw : function () { | |||
this._super(); | |||
var group = this.find("group"); | |||
if (group instanceof FooTable.Filter) { | |||
@@ -214,33 +214,33 @@ define(["jquery", "footable"], | |||
} | |||
}); | |||
ft.symbols = FooTable.init("#symbolsTable", { | |||
"columns": [ | |||
{"sorted": true, "direction": "ASC", "name":"group", "title":"Group", "style":{"font-size":"11px"}}, | |||
{"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":"time", "title":"Avg. time", "breakpoints":"xs sm", "style":{"font-size":"11px"}}, | |||
{"name":"save", "title":"Save", "style":{"font-size":"11px"}}, | |||
columns: [ | |||
{sorted: true, direction: "ASC", name:"group", title:"Group", style:{"font-size":"11px"}}, | |||
{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:"time", title:"Avg. time", breakpoints:"xs sm", style:{"font-size":"11px"}}, | |||
{name:"save", title:"Save", style:{"font-size":"11px"}}, | |||
], | |||
"rows": items[0], | |||
"paging": { | |||
"enabled": true, | |||
"limit": 5, | |||
"size": 25 | |||
rows: items[0], | |||
paging: { | |||
enabled: true, | |||
limit: 5, | |||
size: 25 | |||
}, | |||
"filtering": { | |||
"enabled": true, | |||
"position": "left", | |||
"connectors": false | |||
filtering: { | |||
enabled: true, | |||
position: "left", | |||
connectors: false | |||
}, | |||
"sorting": { | |||
"enabled": true | |||
sorting: { | |||
enabled: true | |||
}, | |||
components: { | |||
filtering: FooTable.groupFilter | |||
}, | |||
"on": { | |||
on: { | |||
"ready.ft.table": function () { | |||
if (rspamd.read_only) { | |||
$(".mb-disabled").attr("disabled", true); | |||
@@ -253,14 +253,14 @@ define(["jquery", "footable"], | |||
rspamd.alertMessage("alert-modal alert-error", data.statusText); | |||
} | |||
}); | |||
$(document).on("click", "#symbolsTable :button", function(event) { | |||
$(document).on("click", "#symbolsTable :button", function () { | |||
var value = $(this).data("save"); | |||
if (!value) return; | |||
saveSymbols(rspamd, "./savesymbols", "symbolsTable", value == "cluster"); | |||
}); | |||
}; | |||
interface.setup = function(rspamd, tables) { | |||
interface.setup = function (rspamd) { | |||
$("#updateSymbols").on("click", function (e) { | |||
e.preventDefault(); | |||
$.ajax({ |
@@ -23,7 +23,7 @@ | |||
*/ | |||
define(["jquery"], | |||
function($) { | |||
function ($) { | |||
var interface = {}; | |||
function cleanTextUpload(source) { | |||
@@ -140,8 +140,8 @@ define(["jquery"], | |||
// Show tooltips | |||
$.each(sym_desc, function (k, v) { | |||
$("#" + k).tooltip({ | |||
"placement": "bottom", | |||
"title": v | |||
placement: "bottom", | |||
title: v | |||
}); | |||
}); | |||
$("html, body").animate({ | |||
@@ -169,7 +169,7 @@ define(["jquery"], | |||
}); | |||
} | |||
interface.setup = function(rspamd) { | |||
interface.setup = function (rspamd) { | |||
$("textarea").change(function () { | |||
if ($(this).val().length !== "") { | |||
$(this).closest("form").find("button").removeAttr("disabled").removeClass("disabled"); |
@@ -10,7 +10,6 @@ requirejs.config({ | |||
d3evolution: "d3evolution.min", | |||
d3pie: "d3pie.min", | |||
footable: "footable.min", | |||
bootstrap: "bootstrap.min", | |||
}, | |||
shim: { | |||
d3: {exports: "d3"}, | |||
@@ -26,13 +25,13 @@ document.title = window.location.hostname + | |||
(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) { |