From d1575c82140c149dc56e2a95cc9f928f55ec96e2 Mon Sep 17 00:00:00 2001 From: Alexander Moisseev Date: Mon, 8 Oct 2018 14:25:50 +0300 Subject: [WebUI] Add symbols sorting buttons to detail history rows --- interface/js/app/history.js | 51 +++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 13 deletions(-) (limited to 'interface/js/app/history.js') 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

" + + 'Sort by:
' + + '
' + + '' + + '' + + '' + + "
", 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 -- cgit v1.2.3