From: Vsevolod Stakhov Date: Mon, 14 Nov 2016 16:53:33 +0000 (+0000) Subject: [WebUI] Add support for errors ring in WebUI X-Git-Tag: 1.4.0~71^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d69f2e3e9d8ac40aeb57b1a67905a675f7d190b7;p=rspamd.git [WebUI] Add support for errors ring in WebUI --- diff --git a/interface/index.html b/interface/index.html index 502e5791c..1db58c87c 100644 --- a/interface/index.html +++ b/interface/index.html @@ -270,6 +270,29 @@ +
+
+
+ +
+ +
Errors
+
+
+ + + + + + + + + +
TimeWorkerPIDModuleIDMessage
+
+
diff --git a/interface/js/rspamd.js b/interface/js/rspamd.js index 271a0b797..57d70a39f 100644 --- a/interface/js/rspamd.js +++ b/interface/js/rspamd.js @@ -28,6 +28,7 @@ //$.cookie.json = true; var pie; var history; + var errors; var graph; var symbols; var read_only = false; @@ -62,6 +63,9 @@ if (history) { history.destroy(); } + if (errors) { + errors.destroy(); + } if (symbols) { symbols.destroy(); symbols = null; @@ -154,6 +158,7 @@ $('#listMaps').empty(); $('#modalBody').empty(); $('#historyLog tbody').remove(); + $('#errorsLog tbody').remove(); $('#symbolsTable tbody').remove(); password = ''; } @@ -616,6 +621,60 @@ }); } + function getErrors() { + + if (errors) { + errors.destroy(); + $('#errorsLog').children('tbody').remove(); + } + + var items = []; + $.ajax({ + dataType: 'json', + url: 'errors', + jsonp: false, + beforeSend: function (xhr) { + xhr.setRequestHeader('Password', getPassword()); + }, + error: function () { + 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 + '
' + ); + }); + $('', { + html: items.join('') + }).insertAfter('#errorsLog thead'); + errors = $('#errorsLog').DataTable({ + "paging": true, + "orderMulti": false, + "order": [ + [0, "desc"], + ], + "info": false, + "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}, + ], + }); + errors.columns.adjust().draw(); + } + }); + } + function decimalStep(number) { var digits = ((+number).toFixed(20)).replace(/^-?\d*\.?|0+$/g, '').length; if (digits == 0 || digits > 4) { @@ -730,6 +789,7 @@ }, success: function (data) { getHistory(); + getErrors(); }, error: function (data) { alertMessage('alert-modal alert-error', data.statusText); @@ -741,6 +801,9 @@ $('#updateHistory').on('click', function () { getHistory(); }); + $('#updateErrors').on('click', function () { + getErrors(); + }); $('#updateSymbols').on('click', function () { getSymbols(); @@ -1178,6 +1241,7 @@ }); $('#history_nav').bind('click', function () { getHistory(); + getErrors(); }); $('#symbols_nav').bind('click', function () { getSymbols();