diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-03-15 12:57:04 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-03-15 12:57:04 +0000 |
commit | 26aab9459c61810115bec031c82147d1f109a7e2 (patch) | |
tree | 71e4fb8e1c93f6195c5ca5517fa5a173c394d95e /interface | |
parent | a70a29a33ac156398101e0a431ecc912093899a3 (diff) | |
download | rspamd-26aab9459c61810115bec031c82147d1f109a7e2.tar.gz rspamd-26aab9459c61810115bec031c82147d1f109a7e2.zip |
[WebUI] Add preliminary v2 history parser
Diffstat (limited to 'interface')
-rw-r--r-- | interface/js/app/history.js | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/interface/js/app/history.js b/interface/js/app/history.js index b592ce0fc..28305bdb6 100644 --- a/interface/js/app/history.js +++ b/interface/js/app/history.js @@ -27,14 +27,47 @@ function($) { var interface = {}; function unix_time_format(tm) { + var date = new Date(tm*1000); + return date.toLocaleString(); } function process_history_v2(data) { var items = []; - $.each(data.rows, function (i, item) { + $.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'; + } else if (item.action === 'spam' || item.action === 'reject') { + action = 'label-danger'; + } else { + action = 'label-info'; + } + var score; + if (item.score < item.required_score) { + score = 'label-success'; + } else { + score = 'label-danger'; + } + + console.log(item) + + items.push( + '<tr><td data-order="' + item.unix_time + '">' + unix_time_format(item.unix_time) + '</td>' + + '<td data-order="' + item.id + '"><div class="cell-overflow" tabindex="1" title="' + item.id + '">' + item.id + '</div></td>' + + '<td data-order="' + item.ip + '"><div class="cell-overflow" tabindex="1" title="' + item.ip + '">' + item.ip + '</div></td>' + + '<td data-order="' + item.action + '"><span class="label ' + action + '">' + item.action + '</span></td>' + + '<td data-order="' + item.score + '"><span class="label ' + score + '">' + item.score.toFixed(2) + ' / ' + item.required_score.toFixed(2) + '</span></td>' + + '<td data-order="' + item.symbols + '"><div class="cell-overflow" tabindex="1" title="' + item.symbols + '">' + item.symbols + '</div></td>' + + '<td data-order="' + item.size + '">' + item.size + '</td>' + + '<td data-order="' + item['time-real'] + '">' + item['time-real'].toFixed(3) + '/' + item['time-virtual'].toFixed(3) + '</td>' + + '<td data-order="' + item.user + '"><div class="cell-overflow" tabindex="1" "title="' + item.user + '">' + item.user + '</div></td></tr>'); }); return items; |