aboutsummaryrefslogtreecommitdiffstats
path: root/interface/js/app
diff options
context:
space:
mode:
authormoisseev <moiseev@mezonplus.ru>2020-06-20 19:59:34 +0300
committermoisseev <moiseev@mezonplus.ru>2020-06-20 19:59:34 +0300
commit68956878f6e0b35b5d7994cb5d7db713cec9f660 (patch)
treee9056e843f4e84078d147c7d3c6295ba5171caa5 /interface/js/app
parent187785857ff3dd0c9ed42be3f627c081ca10f289 (diff)
downloadrspamd-68956878f6e0b35b5d7994cb5d7db713cec9f660.tar.gz
rspamd-68956878f6e0b35b5d7994cb5d7db713cec9f660.zip
[WebUI] Add selectors reference
Diffstat (limited to 'interface/js/app')
-rw-r--r--interface/js/app/rspamd.js2
-rw-r--r--interface/js/app/selectors.js63
2 files changed, 61 insertions, 4 deletions
diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js
index ffd3173d9..e4d9176a2 100644
--- a/interface/js/app/rspamd.js
+++ b/interface/js/app/rspamd.js
@@ -266,7 +266,7 @@ function ($, D3pie, visibility, NProgress, stickyTabs, tab_stat, tab_graph, tab_
$('#selSrv [value="' + e.name + '"]').prop("disabled", true);
}
});
- tab_selectors.checkSelectors(ui);
+ tab_selectors.displayUI(ui);
},
errorMessage: "Cannot get server status",
server: "All SERVERS"
diff --git a/interface/js/app/selectors.js b/interface/js/app/selectors.js
index 69fcd3ed4..600259e18 100644
--- a/interface/js/app/selectors.js
+++ b/interface/js/app/selectors.js
@@ -34,7 +34,7 @@ define(["jquery"],
});
}
- ui.checkSelectors = function (rspamd) {
+ function checkSelectors(rspamd) {
function toggle_form_group_class(remove, add) {
var icon = {
error: "remove",
@@ -63,9 +63,66 @@ define(["jquery"],
$("#selector-feedback-icon").hide();
enable_disable_check_btn();
}
+ }
+
+ function buildLists(rspamd) {
+ function build_table_from_json(json, table_id) {
+ Object.keys(json).forEach(function (key) {
+ var td = $("<td/>");
+ var tr = $("<tr/>")
+ .append(td.clone().html("<code>" + key + "</code>"))
+ .append(td.clone().html(json[key].description));
+ $(table_id + " tbody").append(tr);
+ });
+ }
+
+ function getList(list) {
+ rspamd.query("plugins/selectors/list_" + list, {
+ method: "GET",
+ success: function (neighbours_status) {
+ var json = neighbours_status[0].data;
+ build_table_from_json(json, "#selectorsTable-" + list);
+ },
+ server: get_server(rspamd)
+ });
+ }
+
+ getList("extractors");
+ getList("transforms");
+ }
+
+ ui.displayUI = function (rspamd) {
+ buildLists(rspamd);
+ checkSelectors(rspamd);
};
ui.setup = function (rspamd) {
+ function toggleSidebar(side) {
+ $("#sidebar-" + side).toggleClass("collapsed");
+ var contentClass = "col-md-6";
+ var openSidebarsCount = $("#sidebar-left").hasClass("collapsed") +
+ $("#sidebar-right").hasClass("collapsed");
+ switch (openSidebarsCount) {
+ case 1:
+ contentClass = "col-md-9";
+ break;
+ case 2:
+ contentClass = "col-md-12";
+ break;
+ default:
+ }
+ $("#content").removeClass("col-md-12 col-md-9 col-md-6")
+ .addClass(contentClass);
+ }
+ $("#sidebar-tab-left>a").click(function () {
+ toggleSidebar("left");
+ return false;
+ });
+ $("#sidebar-tab-right>a").click(function () {
+ toggleSidebar("right");
+ return false;
+ });
+
$("#selectorsMsgClean").on("click", function () {
$("#selectorsChkMsgBtn").attr("disabled", true);
$("#selectorsMsgArea").val("");
@@ -73,7 +130,7 @@ define(["jquery"],
});
$("#selectorsClean").on("click", function () {
$("#selectorsSelArea").val("");
- ui.checkSelectors(rspamd);
+ checkSelectors(rspamd);
return false;
});
$("#selectorsChkMsgBtn").on("click", function () {
@@ -86,7 +143,7 @@ define(["jquery"],
enable_disable_check_btn();
});
$("#selectorsSelArea").on("input", function () {
- ui.checkSelectors(rspamd);
+ checkSelectors(rspamd);
});
};