From b7e71546d2c26a65e41696641390bf4522a66a30 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 15 Mar 2017 15:54:50 +0000 Subject: [PATCH] [WebUI] Rework history v2 function --- interface/js/app/history.js | 50 ++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/interface/js/app/history.js b/interface/js/app/history.js index 28305bdb6..3ffb01e20 100644 --- a/interface/js/app/history.js +++ b/interface/js/app/history.js @@ -27,7 +27,7 @@ function($) { var interface = {}; function unix_time_format(tm) { - var date = new Date(tm*1000); + var date = new Date(tm ? tm * 1000 : 0); return date.toLocaleString(); } @@ -41,7 +41,9 @@ function($) { 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') { + } 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'; @@ -57,17 +59,37 @@ function($) { } 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 + '
'); + 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( '
' + item.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")); }); return items; @@ -156,7 +178,7 @@ function($) { var items = process_history_data(data); $('', { - html: items.join('') + html: items.join("\n") }).insertAfter('#historyLog thead'); tables.history = $('#historyLog').DataTable({ "aLengthMenu": [ -- 2.39.5