From: Vsevolod Stakhov Date: Sat, 18 Mar 2017 14:44:34 +0000 (+0000) Subject: [WebUI] Initial move towards footable X-Git-Tag: 1.5.4~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f20a17627041adf5dd79e441f372129296a13aa2;p=thirdparty%2Frspamd.git [WebUI] Initial move towards footable --- diff --git a/interface/index.html b/interface/index.html index 3fd3482060..7715d1d58d 100644 --- a/interface/index.html +++ b/interface/index.html @@ -8,6 +8,7 @@ + @@ -302,21 +303,9 @@
History
- - - - - - - - - - - - - - -
TimeIDIPActionScore / Req. scoreSymbolsSize
Scan Time (s)
User
+
+
+
diff --git a/interface/js/app/history.js b/interface/js/app/history.js index a194141143..76c365f4af 100644 --- a/interface/js/app/history.js +++ b/interface/js/app/history.js @@ -22,7 +22,7 @@ THE SOFTWARE. */ -define(['jquery', 'datatables'], +define(['jquery', 'datatables', 'footable'], function($) { var interface = {}; @@ -37,59 +37,33 @@ function($) { $.each(data.rows.map(function(elt) { return JSON.parse(elt);}), function (i, item) { - var action; - if (item.action === 'clean' || item.action === 'no action') { - action = 'label-success'; - } else if (item.action === 'rewrite subject' || - item.action === 'add header' || - item.action === 'probable spam') { - action = 'label-warning'; + item.action = "
" + item.action + "
"; + } else if (item.action === 'rewrite subject' || item.action === 'add header' || item.action === 'probable spam') { + item.action = "
" + item.action + "
"; } else if (item.action === 'spam' || item.action === 'reject') { - action = 'label-danger'; + item.action = "
" + item.action + "
"; } else { - action = 'label-info'; + item.action = "
" + item.action + "
"; } - var score; if (item.score < item.required_score) { - score = 'label-success'; + item.score = "" + item.score.toFixed(2) + " / " + item.required_score + ""; } else { - score = 'label-danger'; + item.score = "" + item.score.toFixed(2) + " / " + item.required_score + ""; + } + + if (item.user == null) { + item.user = "none"; } var symbols = Object.keys(item.symbols); - var nitem = []; - nitem.push('' + - unix_time_format(item.unix_time) + ''); - nitem.push('
' + item['message-id'] + - '
'); - nitem.push('
' + item.ip + '
'); - nitem.push('' + item.action + - ''); - nitem.push('' - + item.score.toFixed(2) + ' / ' + - item.required_score.toFixed(2) + ''); - nitem.push( '
' + symbols + '
'); - nitem.push('' + - item.size + ''); - nitem.push('' + - item.time_real.toFixed(3) + '/' + - item.time_virtual.toFixed(3) + ''); - nitem.push('
' + item.user + '
'); - - items.push(nitem.join("\n")); + item.symbols = symbols + item.time = unix_time_format(item.unix_time); + item.scan_time = item.time_real.toFixed(3) + '/' + + item.time_virtual.toFixed(3); + item.id = item['message-id']; + items.push(item); }); return items; @@ -99,35 +73,27 @@ function($) { var items = []; $.each(data, function (i, item) { - var action; - if (item.action === 'clean' || item.action === 'no action') { - action = 'label-success'; + item.action = "
" + item.action + "
"; } else if (item.action === 'rewrite subject' || item.action === 'add header' || item.action === 'probable spam') { - action = 'label-warning'; + item.action = "
" + item.action + "
"; } else if (item.action === 'spam' || item.action === 'reject') { - action = 'label-danger'; + item.action = "
" + item.action + "
"; } else { - action = 'label-info'; + item.action = "
" + item.action + "
"; } - var score; if (item.score < item.required_score) { - score = 'label-success'; + item.score = "" + item.score.toFixed(2) + " / " + item.required_score + ""; } else { - score = 'label-danger'; + item.score = "" + item.score.toFixed(2) + " / " + item.required_score + ""; } - items.push( - '' + item.time + '' + - '
' + item.id + '
' + - '
' + item.ip + '
' + - '' + item.action + '' + - '' + item.score.toFixed(2) + ' / ' + item.required_score.toFixed(2) + '' + - '
' + item.symbols + '
' + - '' + item.size + '' + - '' + item.scan_time.toFixed(3) + '' + - '
' + item.user + '
'); + if (item.user == null) { + item.user = "none"; + } + + items.push(item) }); return items; @@ -164,6 +130,57 @@ function($) { $('#historyLog').children('tbody').remove(); } + + FooTable.actionFilter = FooTable.Filtering.extend({ + construct : function(instance) { + this._super(instance); + this.actions = [ 'reject', 'add_header', 'greylist', + 'no action', 'soft reject' ]; + this.def = 'Any action'; + this.$action = null; + }, + $create : function() { + this._super(); + var self = this, $form_grp = $('
', { + 'class' : 'form-group' + }).append($('