diff options
author | andre.peters <andre.peters@servercow.de> | 2017-03-19 22:30:42 +0100 |
---|---|---|
committer | andre.peters <andre.peters@servercow.de> | 2017-03-19 22:30:42 +0100 |
commit | 406ca54dc7d07fc1b5e6f8fd451f4499d547ea88 (patch) | |
tree | a77d0e5fd9096f9adba8fc9f197c600a4b9174b5 /interface/js | |
parent | 0d9361bc728f285458032286cebcd1b892aeb7ee (diff) | |
download | rspamd-406ca54dc7d07fc1b5e6f8fd451f4499d547ea88.tar.gz rspamd-406ca54dc7d07fc1b5e6f8fd451f4499d547ea88.zip |
Fix date for all history items, draw error table with footable
Diffstat (limited to 'interface/js')
-rw-r--r-- | interface/js/app/history.js | 55 |
1 files changed, 26 insertions, 29 deletions
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 = "<div style='font-size:11px' class='label label-success'>" + item.action + "</div>"; } 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( - '<tr><td data-order="' + item.ts + '">' + new Date(item.ts * 1000) + '</td>' + - '<td data-order="' + item.type + '">' + item.type + '</td>' + - '<td data-order="' + item.pid + '">' + item.pid + '</td>' + - '<td data-order="' + item.module + '">' + item.module + '</td>' + - '<td data-order="' + item.id + '">' + item.id + '</td>' + - '<td data-order="' + item.message + '"><div class="cell-overflow" tabindex="1" title="' + item.message + '">' + item.message + '</div></td></tr>' - ); + $.each(data, function (i, item) { + items.push( + item.ts = unix_time_format(item.ts) + ); }); - $('<tbody/>', { - 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(); } }); }; |