From: Vsevolod Stakhov Date: Tue, 1 Nov 2016 09:14:44 +0000 (+0000) Subject: [WebUI] Rework symbols scores X-Git-Tag: 1.4.0~161 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6edc7ab347abcf76c3ee99ff115a55b459cc998;p=thirdparty%2Frspamd.git [WebUI] Rework symbols scores --- diff --git a/interface/index.html b/interface/index.html index efdf783c8b..17f14738f7 100644 --- a/interface/index.html +++ b/interface/index.html @@ -29,6 +29,7 @@
  • Throughput
  • Configuration
  • +
  • Symbols
  • Learning
  • Scan
  • History
  • @@ -125,22 +126,37 @@
    -
    Rules
    +
    Lists
    -
    - +
    + +
    +
    + +
    -
    Lists
    +
    + +
    + +
    Symbols and rules
    - +
    + + + + + + + + +
    Symbol nameGroupDescriptionScoreHitsAvg. time
    @@ -257,7 +273,6 @@
    - diff --git a/interface/js/rspamd.js b/interface/js/rspamd.js index 7bb7cdf98b..7cd267da11 100644 --- a/interface/js/rspamd.js +++ b/interface/js/rspamd.js @@ -29,6 +29,7 @@ var pie; var history; var graph; + var symbols; var selected = []; // Keep graph selectors state @@ -58,6 +59,10 @@ if (history) { history.destroy(); } + if (symbols) { + symbols.destroy(); + symbols = null; + } cleanCredentials(); connectRSPAMD(); // window.location.reload(); @@ -168,8 +173,9 @@ } $('#statWidgets').empty(); $('#listMaps').empty(); - $('#historyLog tbody').remove(); $('#modalBody').empty(); + $('#historyLog tbody').remove(); + $('#symbolsTable tbody').remove(); password = ''; } function isLogged() { @@ -261,7 +267,7 @@ } if (mode === 'update') { $('#modalBody').empty(); - getSymbols(); + getMaps(); } $.each(data, function (i, item) { $.ajax({ @@ -609,7 +615,7 @@ items.push( '' + item.time + '' + - '
    ' + item.id + '' + + '
    ' + item.id + '
    ' + '
    ' + item.ip + '
    ' + '' + item.action + '' + '' + item.score.toFixed(2) + ' / ' + item.required_score.toFixed(2) + '' + @@ -639,6 +645,19 @@ } // @get symbols into modal form function getSymbols() { + var symbols_length = 50; + + if (symbols) { + var sl = document.getElementsByName('symbols_length')[0]; + if (sl !== undefined) { + symbols_length = parseInt(sl.value); + } else { + symbols_length = 50; + } + symbols.destroy(); + symbols = null; + $('#symbolsTable').children('tbody').remove(); + } var items = []; $.ajax({ dataType: 'json', @@ -649,17 +668,7 @@ xhr.setRequestHeader('Password', getPassword()); }, success: function (data) { - $('#modalBody').empty(); - data.sort(function(a, b) { - return a.group.localeCompare(b.group); - }); $.each(data, function (i, group) { - items.push('
    ' + - '

    ' + group.group + '

    ' + - '
    '); - group.rules.sort(function(a, b) { - return a.symbol.localeCompare(b.symbol); - }); $.each(group.rules, function (i, item) { var max = 20; var min = -20; @@ -669,27 +678,32 @@ if (item.weight < min) { min = item.weight * 2; } - items.push('
    ' + - '' + - '
    ' + - '' + item.symbol + '' + + '
    ' + group.group + '
    ' + + '
    ' + item.description + '
    ' + + '' + - '
    ' + - '
    '); + '' + + '' + item.frequency + '' + + '' + Number(item.time).toFixed(2) + 'ms' + + '' + + ''); }); }); - $('
    ', { - id: 'symbolsForm', - method: 'post', - action: '/savesymbols', - 'data-type': 'symbols', - style: 'display:none', - html: items.join('') }).appendTo('#modalBody'); + $('', { html: items.join('') }).insertAfter('#symbolsTable thead'); + symbols = $('#symbolsTable').DataTable({ + "aLengthMenu": [[100, 200, -1], [100, 200, "All"]], + "bStateSave": true, + "orderMulti": true, + "order": [[ 1, "asc" ], [0, "asc"], [3, "desc"]], + "pageLength": symbols_length + }); }, error: function (data) { alertMessage('alert-modal alert-error', data.statusText); @@ -1143,7 +1157,6 @@ $('#configuration_nav').bind('click', function (e) { getActions(); getMaps(); - getSymbols(); }); $(document).ajaxStart(function () { @@ -1161,5 +1174,8 @@ $('#history_nav').bind('click', function() { getHistory(); }); + $('#symbols_nav').bind('click', function() { + getSymbols(); + }); }); })();