diff options
author | Alexander Moisseev <moiseev@mezonplus.ru> | 2018-10-08 14:25:50 +0300 |
---|---|---|
committer | Alexander Moisseev <moiseev@mezonplus.ru> | 2018-10-12 10:12:41 +0300 |
commit | d1575c82140c149dc56e2a95cc9f928f55ec96e2 (patch) | |
tree | cef3d68d3f7c34483352b26ee6538a3ec0a6b6a3 /interface | |
parent | a1ae82be354ddf7c55bd378eff6b618a2734a499 (diff) | |
download | rspamd-d1575c82140c149dc56e2a95cc9f928f55ec96e2.tar.gz rspamd-d1575c82140c149dc56e2a95cc9f928f55ec96e2.zip |
[WebUI] Add symbols sorting buttons
to detail history rows
Diffstat (limited to 'interface')
-rw-r--r-- | interface/js/app/history.js | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/interface/js/app/history.js b/interface/js/app/history.js index 1edd4bf28..184be994c 100644 --- a/interface/js/app/history.js +++ b/interface/js/app/history.js @@ -113,6 +113,11 @@ define(["jquery", "footable", "humanize"], }; } + function getSelector(id) { + var e = document.getElementById(id); + return e.options[e.selectedIndex].value; + } + function get_compare_function() { var compare_functions = { magnitude: function (e1, e2) { @@ -126,11 +131,6 @@ define(["jquery", "footable", "humanize"], } }; - function getSelector(id) { - var e = document.getElementById(id); - return e.options[e.selectedIndex].value; - } - return compare_functions[getSelector("selSymOrder")]; } @@ -346,7 +346,13 @@ define(["jquery", "footable", "humanize"], sortValue: function (val) { return Number(val.options.sortValue); } }, { name: "symbols", - title: "Symbols", + title: "Symbols<br /><br />" + + '<span style="font-weight:normal;">Sort by:</span><br />' + + '<div class="btn-group btn-group-xs btn-sym-order" data-toggle="buttons">' + + '<button type="button" class="btn btn-default btn-sym-magnitude" value="magnitude">Magnitude</button>' + + '<button type="button" class="btn btn-default btn-sym-score" value="score">Value</button>' + + '<button type="button" class="btn btn-default btn-sym-name" value="name">Name</button>' + + "</div>", breakpoints: "all", style: { "font-size": "11px", @@ -611,7 +617,15 @@ define(["jquery", "footable", "humanize"], "ready.ft.table": drawTooltips, "after.ft.sorting": drawTooltips, "after.ft.paging": drawTooltips, - "after.ft.filtering": drawTooltips + "after.ft.filtering": drawTooltips, + "expand.ft.row": function (e, ft, row) { + setTimeout(function () { + var detail_row = row.$el.next(); + var order = getSelector("selSymOrder"); + detail_row.find(".btn-sym-" + order) + .addClass("active").siblings().removeClass("active"); + }, 5); + } } }); } @@ -698,18 +712,29 @@ define(["jquery", "footable", "humanize"], }; ui.setup = function (rspamd, tables) { - $("#updateHistory").off("click"); - $("#updateHistory").on("click", function (e) { - e.preventDefault(); - ui.getHistory(rspamd, tables); - }); - $("#selSymOrder").unbind().change(function () { + function change_symbols_order(order) { + $(".btn-sym-" + order).addClass("active").siblings().removeClass("active"); var compare_function = get_compare_function(); $.each(tables.history.rows.all, function (i, row) { var cell_val = sort_symbols(symbols[i], compare_function); row.cells[8].val(cell_val, false, true); }); drawTooltips(); + } + + $("#updateHistory").off("click"); + $("#updateHistory").on("click", function (e) { + e.preventDefault(); + ui.getHistory(rspamd, tables); + }); + $("#selSymOrder").unbind().change(function () { + var order = this.value; + change_symbols_order(order); + }); + $(document).on("click", ".btn-sym-order button", function () { + var order = this.value; + $("#selSymOrder").val(order); + change_symbols_order(order); }); // @reset history log |