From 263eee06553bde7310cc30e290b7e2e769db48b7 Mon Sep 17 00:00:00 2001 From: Alexander Moisseev Date: Thu, 5 Apr 2018 18:03:38 +0300 Subject: [PATCH] [WebUI] Add symbols order selector to history --- interface/css/rspamd.css | 10 ++++++++-- interface/index.html | 11 +++++++++-- interface/js/app/history.js | 19 ++++++++++++++++--- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/interface/css/rspamd.css b/interface/css/rspamd.css index 3af8baad7..c52e133c1 100644 --- a/interface/css/rspamd.css +++ b/interface/css/rspamd.css @@ -160,6 +160,13 @@ input.action-scores { padding-right: 20px; } +#selSymOrder { + height: auto; +} +.widget-title-form label { + font-weight: normal; +} + .btn-upload-trigger { position:relative; z-index:1; @@ -281,8 +288,7 @@ td.maps-cell { margin:0 0 0 36px; } .widget-title .buttons { - float:left; - margin:2px 2px 0 0; + padding:2px 2px 0 0; } .widget-title .label { padding:3px 5px 2px; diff --git a/interface/index.html b/interface/index.html index 85794a49d..8cb21794f 100644 --- a/interface/index.html +++ b/interface/index.html @@ -286,14 +286,21 @@
-
+
+
+ + +
-
+
History
diff --git a/interface/js/app/history.js b/interface/js/app/history.js index af0a2a80e..fba1dd58f 100644 --- a/interface/js/app/history.js +++ b/interface/js/app/history.js @@ -116,6 +116,18 @@ function($, _, Humanize) { function process_history_v2(data) { var items = []; + function getSelector(id) { + var e = document.getElementById(id); + return e.options[e.selectedIndex].value; + } + var compare = (getSelector("selSymOrder") === "score") + ? function (e1, e2) { + return Math.abs(e1.score) < Math.abs(e2.score); + } + : function (e1, e2) { + return e1.name.localeCompare(e2.name); + }; + $.each(data.rows, function (i, item) { @@ -141,9 +153,7 @@ function($, _, Humanize) { map(function(key) { return item.symbols[key]; }). - sort(function(e1, e2) { - return Math.abs(e1.score) < Math.abs(e2.score); - }). + sort(compare). map(function(e) { return e.str; }). join("
\n"); item.time = { @@ -605,6 +615,9 @@ function($, _, Humanize) { e.preventDefault(); interface.getHistory(rspamd, tables, neighbours, checked_server); }); + $("#selSymOrder").change(function() { + interface.getHistory(rspamd, tables, neighbours, checked_server); + }); // @reset history log $('#resetHistory').off('click'); -- 2.39.5