From 406ca54dc7d07fc1b5e6f8fd451f4499d547ea88 Mon Sep 17 00:00:00 2001 From: "andre.peters" Date: Sun, 19 Mar 2017 22:30:42 +0100 Subject: Fix date for all history items, draw error table with footable --- interface/js/app/history.js | 55 +++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 29 deletions(-) (limited to 'interface/js') diff --git a/interface/js/app/history.js b/interface/js/app/history.js index 76c365f4a..63fe8e0dd 100644 --- a/interface/js/app/history.js +++ b/interface/js/app/history.js @@ -22,13 +22,12 @@ THE SOFTWARE. */ -define(['jquery', 'datatables', 'footable'], +define(['jquery', 'footable'], function($) { var interface = {}; function unix_time_format(tm) { var date = new Date(tm ? tm * 1000 : 0); - return date.toLocaleString(); } @@ -73,6 +72,7 @@ function($) { var items = []; $.each(data, function (i, item) { + item.time = unix_time_format(item.unix_time) if (item.action === 'clean' || item.action === 'no action') { item.action = "
" + item.action + "
"; } else if (item.action === 'rewrite subject' || item.action === 'add header' || item.action === 'probable spam') { @@ -248,37 +248,34 @@ function($) { rspamd.alertMessage('alert-error', 'Cannot receive errors'); }, success: function (data) { - $.each(data, function (i, item) { - - items.push( - '' + new Date(item.ts * 1000) + '' + - '' + item.type + '' + - '' + item.pid + '' + - '' + item.module + '' + - '' + item.id + '' + - '
' + item.message + '
' - ); + $.each(data, function (i, item) { + items.push( + item.ts = unix_time_format(item.ts) + ); }); - $('', { - html: items.join('') - }).insertAfter('#errorsLog thead'); - tables.errors = $('#errorsLog').DataTable({ - "paging": true, - "orderMulti": false, - "order": [ - [0, "desc"], - ], - "info": false, + $('#errorsLog').footable({ "columns": [ - {"width": "15%", "searchable": true, "orderable": true, "type": "num"}, - {"width": "5%", "searchable": true, "orderable": true}, - {"width": "5%", "searchable": true, "orderable": true}, - {"width": "3%", "searchable": true, "orderable": true}, - {"width": "3%", "searchable": true, "orderable": true}, - {"width": "65%", "searchable": true, "orderable": true}, + {"sorted": true,"direction": "DESC","name":"ts","title":"Time","style":{"font-size":"11px","width":300,"maxWidth":300}}, + {"name":"type","title":"Worker type","breakpoints":"xs sm","style":{"font-size":"11px","width":150,"maxWidth":150}}, + {"name":"pid","title":"PID","breakpoints":"xs sm","style":{"font-size":"11px","width":110,"maxWidth":110}}, + {"name":"module","title":"Module","style":{"font-size":"11px"}}, + {"name":"id","title":"Internal ID","style":{"font-size":"11px"}}, + {"name":"message","title":"Message","breakpoints":"xs sm","style":{"font-size":"11px"}}, ], + "rows": data, + "paging": { + "enabled": true, + "limit": 5, + "size": 25 + }, + "filtering": { + "enabled": true, + "position": "left" + }, + "sorting": { + "enabled": true + } }); - tables.errors.columns.adjust().draw(); } }); }; -- cgit v1.2.3