aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-07-12 12:50:54 +0100
committerGitHub <noreply@github.com>2018-07-12 12:50:54 +0100
commit58ded36de7fed73ec39030afe8be3ad74c921fe5 (patch)
treecddc84a2ee0a9095d4ad51ea9d0cc755d6690647
parent7f169bd819f5b35cd3237308b3e4441cc02934ff (diff)
parentebfc92f3490d961f81d0d54b98f2f89e728a7a22 (diff)
downloadrspamd-58ded36de7fed73ec39030afe8be3ad74c921fe5.tar.gz
rspamd-58ded36de7fed73ec39030afe8be3ad74c921fe5.zip
Merge pull request #2336 from moisseev/eslint
[WebUI] Enable strict mode,
-rw-r--r--.eslintrc.json4
-rw-r--r--interface/js/app/config.js17
-rw-r--r--interface/js/app/graph.js9
-rw-r--r--interface/js/app/history.js25
-rw-r--r--interface/js/app/rspamd.js63
-rw-r--r--interface/js/app/stats.js7
-rw-r--r--interface/js/app/symbols.js9
-rw-r--r--interface/js/app/upload.js7
-rw-r--r--interface/js/main.js3
9 files changed, 74 insertions, 70 deletions
diff --git a/.eslintrc.json b/.eslintrc.json
index 19f85ea9c..9454f85d8 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -71,6 +71,7 @@
"no-empty": "off",
"no-empty-function": "off",
"no-inline-comments": "off",
+ "no-invalid-this": "off",
"no-loop-func": "off",
"no-negated-condition": "off",
"no-param-reassign": "off",
@@ -80,7 +81,6 @@
"one-var-declaration-per-line": "off",
"prefer-spread": "off",
"sort-keys": "off",
- "sort-vars": "off",
- "strict": "off"
+ "sort-vars": "off"
}
}
diff --git a/interface/js/app/config.js b/interface/js/app/config.js
index 160061694..293fd7842 100644
--- a/interface/js/app/config.js
+++ b/interface/js/app/config.js
@@ -22,11 +22,10 @@
THE SOFTWARE.
*/
-/* global $span:true, $tbody:true */
-
define(["jquery"],
function ($) {
- var interface = {};
+ "use strict";
+ var ui = {};
function save_map_success(rspamd) {
rspamd.alertMessage("alert-modal alert-success", "Map data successfully saved");
@@ -74,7 +73,7 @@ define(["jquery"],
success: function (data) {
$listmaps.empty();
$("#modalBody").empty();
- $tbody = $("<tbody>");
+ var $tbody = $("<tbody>");
$.each(data, function (i, item) {
var label;
@@ -85,7 +84,7 @@ define(["jquery"],
}
var $tr = $("<tr>");
$("<td class=\"col-md-2 maps-cell\">" + label + "</td>").appendTo($tr);
- $span = $("<span class=\"map-link\" data-toggle=\"modal\" data-target=\"#modalDialog\">" + item.uri + "</span>").data("item", item);
+ var $span = $("<span class=\"map-link\" data-toggle=\"modal\" data-target=\"#modalDialog\">" + item.uri + "</span>").data("item", item);
$span.wrap("<td>").parent().appendTo($tr);
$("<td>" + item.description + "</td>").appendTo($tr);
$tr.appendTo($tbody);
@@ -235,7 +234,7 @@ define(["jquery"],
}
// @upload edited actions
- interface.setup = function (rspamd) {
+ ui.setup = function (rspamd) {
// Modal form for maps
$(document).on("click", "[data-toggle=\"modal\"]", function () {
var item = $(this).data("item");
@@ -279,8 +278,8 @@ define(["jquery"],
});
};
- interface.getActions = getActions;
- interface.getMaps = getMaps;
+ ui.getActions = getActions;
+ ui.getMaps = getMaps;
- return interface;
+ return ui;
});
diff --git a/interface/js/app/graph.js b/interface/js/app/graph.js
index 7ff570852..c7e0041ea 100644
--- a/interface/js/app/graph.js
+++ b/interface/js/app/graph.js
@@ -27,6 +27,7 @@
define(["jquery", "d3evolution", "footable"],
function ($, D3Evolution) {
+ "use strict";
var rrd_pie_config = {
header: {},
size: {
@@ -168,10 +169,10 @@ define(["jquery", "d3evolution", "footable"],
});
}
- var interface = {};
+ var ui = {};
var prevUnit = "msg/s";
- interface.draw = function (rspamd, graphs, neighbours, checked_server, type) {
+ ui.draw = function (rspamd, graphs, neighbours, checked_server, type) {
function updateWidgets(data) {
// Autoranging
@@ -280,7 +281,7 @@ define(["jquery", "d3evolution", "footable"],
});
};
- interface.setup = function () {
+ ui.setup = function () {
// Handling mouse events on overlapping elements
$("#rrd-pie").mouseover(function () {
$("#rrd-pie").css("z-index", "200");
@@ -294,5 +295,5 @@ define(["jquery", "d3evolution", "footable"],
return getSelector("selData");
};
- return interface;
+ return ui;
});
diff --git a/interface/js/app/history.js b/interface/js/app/history.js
index 122f8df6e..8e34dff24 100644
--- a/interface/js/app/history.js
+++ b/interface/js/app/history.js
@@ -26,7 +26,8 @@
define(["jquery", "footable", "humanize"],
function ($, _, Humanize) {
- var interface = {};
+ "use strict";
+ var ui = {};
var ft = {};
var htmlEscapes = {
"&": "&amp;",
@@ -483,7 +484,7 @@ define(["jquery", "footable", "humanize"],
return func();
}
- interface.getHistory = function (rspamd, tables, neighbours, checked_server) {
+ ui.getHistory = function (rspamd, tables, neighbours, checked_server) {
FooTable.actionFilter = FooTable.Filtering.extend({
construct : function (instance) {
this._super(instance);
@@ -661,10 +662,10 @@ define(["jquery", "footable", "humanize"],
$("#updateHistory").off("click");
$("#updateHistory").on("click", function (e) {
e.preventDefault();
- interface.getHistory(rspamd, tables, neighbours, checked_server);
+ ui.getHistory(rspamd, tables, neighbours, checked_server);
});
$("#selSymOrder").unbind().change(function () {
- interface.getHistory(rspamd, tables, neighbours, checked_server);
+ ui.getHistory(rspamd, tables, neighbours, checked_server);
});
// @reset history log
@@ -684,8 +685,8 @@ define(["jquery", "footable", "humanize"],
}
if (checked_server === "All SERVERS") {
rspamd.queryNeighbours("errors", function () {
- interface.getHistory(rspamd, tables, neighbours, checked_server);
- interface.getErrors(rspamd, tables, neighbours, checked_server);
+ ui.getHistory(rspamd, tables, neighbours, checked_server);
+ ui.getErrors(rspamd, tables, neighbours, checked_server);
});
}
else {
@@ -698,8 +699,8 @@ define(["jquery", "footable", "humanize"],
xhr.setRequestHeader("Password", rspamd.getPassword());
},
success: function () {
- interface.getHistory(rspamd, tables, neighbours, checked_server);
- interface.getErrors(rspamd, tables, neighbours, checked_server);
+ ui.getHistory(rspamd, tables, neighbours, checked_server);
+ ui.getErrors(rspamd, tables, neighbours, checked_server);
},
error: function (data) {
rspamd.alertMessage("alert-modal alert-error", data.statusText);
@@ -742,7 +743,7 @@ define(["jquery", "footable", "humanize"],
});
}
- interface.getErrors = function (rspamd, tables, neighbours, checked_server) {
+ ui.getErrors = function (rspamd, tables, neighbours, checked_server) {
if (rspamd.read_only) return;
if (checked_server !== "All SERVERS") {
@@ -775,10 +776,10 @@ define(["jquery", "footable", "humanize"],
$("#updateErrors").off("click");
$("#updateErrors").on("click", function (e) {
e.preventDefault();
- interface.getErrors(rspamd, tables, neighbours, checked_server);
+ ui.getErrors(rspamd, tables, neighbours, checked_server);
});
};
- interface.setup = function () {};
- return interface;
+ ui.setup = function () {};
+ return ui;
});
diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js
index b935cf6c2..a07d4ac03 100644
--- a/interface/js/app/rspamd.js
+++ b/interface/js/app/rspamd.js
@@ -29,12 +29,13 @@ define(["jquery", "d3pie", "visibility", "app/stats", "app/graph", "app/config",
"app/symbols", "app/history", "app/upload"],
function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
tab_symbols, tab_history, tab_upload) {
+ "use strict";
// begin
var graphs = {};
var tables = {};
var neighbours = []; // list of clusters
var checked_server = "All SERVERS";
- var interface = {
+ var ui = {
read_only: false,
};
@@ -75,7 +76,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
stopTimers();
cleanCredentials();
- interface.connect();
+ ui.connect();
}
function tabClick(tab_id) {
@@ -90,32 +91,32 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
switch (tab_id) {
case "#status_nav":
- tab_stat.statWidgets(interface, graphs, checked_server);
+ tab_stat.statWidgets(ui, graphs, checked_server);
timer_id.status = Visibility.every(10000, function () {
- tab_stat.statWidgets(interface, graphs, checked_server);
+ tab_stat.statWidgets(ui, graphs, checked_server);
});
break;
case "#throughput_nav":
- tab_graph.draw(interface, graphs, neighbours, checked_server, selData);
+ tab_graph.draw(ui, graphs, neighbours, checked_server, selData);
var autoRefresh = {
hourly: 60000,
daily: 300000
};
timer_id.throughput = Visibility.every(autoRefresh[selData] || 3600000, function () {
- tab_graph.draw(interface, graphs, neighbours, checked_server, selData);
+ tab_graph.draw(ui, graphs, neighbours, checked_server, selData);
});
break;
case "#configuration_nav":
- tab_config.getActions(interface);
- tab_config.getMaps(interface);
+ tab_config.getActions(ui);
+ tab_config.getMaps(ui);
break;
case "#symbols_nav":
- tab_symbols.getSymbols(interface, tables, checked_server);
+ tab_symbols.getSymbols(ui, tables, checked_server);
break;
case "#history_nav":
- tab_history.getHistory(interface, tables, neighbours, checked_server);
- tab_history.getErrors(interface, tables, neighbours, checked_server);
+ tab_history.getHistory(ui, tables, neighbours, checked_server);
+ tab_history.getErrors(ui, tables, neighbours, checked_server);
break;
case "#disconnect":
disconnect();
@@ -180,8 +181,8 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
}
// Public functions
- interface.alertMessage = alertMessage;
- interface.setup = function () {
+ ui.alertMessage = alertMessage;
+ ui.setup = function () {
$("#selData").change(function () {
selData = this.value;
tabClick("#throughput_nav");
@@ -231,25 +232,25 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
tabClick("#status_nav");
}
});
- tab_config.setup(interface);
- tab_symbols.setup(interface, tables);
- tab_history.setup(interface, tables);
- tab_upload.setup(interface);
+ tab_config.setup(ui);
+ tab_symbols.setup(ui, tables);
+ tab_history.setup(ui, tables);
+ tab_upload.setup(ui);
selData = tab_graph.setup();
};
- interface.connect = function () {
+ ui.connect = function () {
if (isLogged()) {
var data = JSON.parse(sessionStorage.getItem("Credentials"));
if (data && data[checked_server].read_only) {
- interface.read_only = true;
+ ui.read_only = true;
$("#learning_nav").hide();
$("#resetHistory").attr("disabled", true);
$("#errors-history").hide();
}
else {
- interface.read_only = false;
+ ui.read_only = false;
$("#learning_nav").show();
$("#resetHistory").removeAttr("disabled", true);
}
@@ -257,10 +258,9 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
return;
}
- var ui = $("#mainUI");
var dialog = $("#connectDialog");
var backdrop = $("#backDrop");
- $(ui).hide();
+ $("#mainUI").hide();
$(dialog).show();
$(backdrop).show();
$("#connectPassword").focus();
@@ -290,13 +290,13 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
// Is actually never returned by Rspamd
} else {
if (data.read_only) {
- interface.read_only = true;
+ ui.read_only = true;
$("#learning_nav").hide();
$("#resetHistory").attr("disabled", true);
$("#errors-history").hide();
}
else {
- interface.read_only = false;
+ ui.read_only = false;
$("#learning_nav").show();
$("#resetHistory").removeAttr("disabled", true);
}
@@ -308,7 +308,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
}
},
error: function (data) {
- interface.alertMessage("alert-modal alert-error", data.statusText);
+ ui.alertMessage("alert-modal alert-error", data.statusText);
$("#connectPassword").val("");
$("#connectPassword").focus();
}
@@ -316,7 +316,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
});
};
- interface.queryLocal = function (req_url, on_success, on_error, method, headers, params) {
+ ui.queryLocal = function (req_url, on_success, on_error, method, headers, params) {
var req_params = {
type: method,
jsonp: false,
@@ -355,7 +355,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
$.ajax(req_params);
};
- interface.queryNeighbours = function (req_url, on_success, on_error, method, headers, params, req_data) {
+ ui.queryNeighbours = function (req_url, on_success, on_error, method, headers, params, req_data) {
$.ajax({
dataType: "json",
type: "GET",
@@ -387,7 +387,6 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
});
});
$.each(neighbours_status, function (ind) {
- "use strict";
method = typeof method !== "undefined" ? method : "GET";
var req_params = {
type: method,
@@ -453,12 +452,12 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
});
},
error: function () {
- interface.alertMessage("alert-error", "Cannot receive neighbours data");
+ ui.alertMessage("alert-error", "Cannot receive neighbours data");
},
});
};
- interface.drawPie = function (obj, id, data, conf) {
+ ui.drawPie = function (obj, id, data, conf) {
if (obj) {
obj.updateProp("data.content",
data.filter(function (elt) {
@@ -548,7 +547,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
return obj;
};
- interface.getPassword = getPassword;
+ ui.getPassword = getPassword;
- return interface;
+ return ui;
});
diff --git a/interface/js/app/stats.js b/interface/js/app/stats.js
index 19b1d72a7..56f3e7101 100644
--- a/interface/js/app/stats.js
+++ b/interface/js/app/stats.js
@@ -24,7 +24,8 @@
define(["jquery", "d3pie", "humanize"],
function ($, d3pie, Humanize) {
- // @ ms to date
+ "use strict";
+ // @ ms to date
function msToTime(seconds) {
/* eslint-disable no-bitwise */
var years = seconds / 31536000 >> 0; // 3600*24*365
@@ -170,7 +171,7 @@ define(["jquery", "d3pie", "humanize"],
}
}
// Public API
- var interface = {
+ var ui = {
statWidgets: function (rspamd, graphs, checked_server) {
rspamd.queryNeighbours("/auth", function (neighbours_status) {
var neighbours_sum = {
@@ -232,6 +233,6 @@ define(["jquery", "d3pie", "humanize"],
},
};
- return interface;
+ return ui;
}
);
diff --git a/interface/js/app/symbols.js b/interface/js/app/symbols.js
index ac569ee9d..928933739 100644
--- a/interface/js/app/symbols.js
+++ b/interface/js/app/symbols.js
@@ -26,8 +26,9 @@
define(["jquery", "footable"],
function ($) {
- var interface = {};
+ "use strict";
var ft = {};
+ var ui = {};
function saveSymbols(rspamd, action, id, is_cluster) {
var inputs = $("#" + id + " :input[data-role=\"numerictextbox\"]");
@@ -155,7 +156,7 @@ define(["jquery", "footable"],
return [items, distinct_groups];
}
// @get symbols into modal form
- interface.getSymbols = function (rspamd) {
+ ui.getSymbols = function (rspamd) {
$.ajax({
dataType: "json",
@@ -262,7 +263,7 @@ define(["jquery", "footable"],
});
};
- interface.setup = function (rspamd) {
+ ui.setup = function (rspamd) {
$("#updateSymbols").on("click", function (e) {
e.preventDefault();
$.ajax({
@@ -284,5 +285,5 @@ define(["jquery", "footable"],
});
};
- return interface;
+ return ui;
});
diff --git a/interface/js/app/upload.js b/interface/js/app/upload.js
index 2926e62e2..fad074668 100644
--- a/interface/js/app/upload.js
+++ b/interface/js/app/upload.js
@@ -24,7 +24,8 @@
define(["jquery"],
function ($) {
- var interface = {};
+ "use strict";
+ var ui = {};
function cleanTextUpload(source) {
$("#" + source + "TextSource").val("");
@@ -169,7 +170,7 @@ define(["jquery"],
});
}
- interface.setup = function (rspamd) {
+ ui.setup = function (rspamd) {
$("textarea").change(function () {
if ($(this).val().length !== "") {
$(this).closest("form").find("button").removeAttr("disabled").removeClass("disabled");
@@ -210,5 +211,5 @@ define(["jquery"],
};
- return interface;
+ return ui;
});
diff --git a/interface/js/main.js b/interface/js/main.js
index 515645667..bdc89dd5f 100644
--- a/interface/js/main.js
+++ b/interface/js/main.js
@@ -27,13 +27,14 @@ document.title = window.location.hostname +
(window.location.pathname !== "/" ? window.location.pathname : "") +
" - Rspamd Web Interface";
-define("d3.global", ["d3"], function (_) {
+define("d3.global", ["d3"], function (_) { // eslint-disable-line strict
d3 = _; // eslint-disable-line no-global-assign
});
// Load main UI
require(["domReady"],
function (domReady) {
+ "use strict";
domReady(function () {
require(["jquery", "d3", "app/rspamd"],
function ($, d3, rspamd) {