From: Vsevolod Stakhov Date: Wed, 15 Mar 2017 12:57:04 +0000 (+0000) Subject: [WebUI] Add preliminary v2 history parser X-Git-Tag: 1.5.3~25 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=26aab9459c61810115bec031c82147d1f109a7e2;p=rspamd.git [WebUI] Add preliminary v2 history parser --- 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( + '' + unix_time_format(item.unix_time) + '' + + '
' + item.id + '
' + + '
' + item.ip + '
' + + '' + item.action + '' + + '' + item.score.toFixed(2) + ' / ' + item.required_score.toFixed(2) + '' + + '
' + item.symbols + '
' + + '' + item.size + '' + + '' + item['time-real'].toFixed(3) + '/' + item['time-virtual'].toFixed(3) + '' + + '
' + item.user + '
'); }); return items;