Browse Source

[WebUI] Add support for errors ring in WebUI

tags/1.4.0
Vsevolod Stakhov 7 years ago
parent
commit
d69f2e3e9d
2 changed files with 87 additions and 0 deletions
  1. 23
    0
      interface/index.html
  2. 64
    0
      interface/js/rspamd.js

+ 23
- 0
interface/index.html View File

@@ -270,6 +270,29 @@
</table>
</div>
</div>
<div class="widget-box">
<div class="widget-title">
<div class="buttons pull-right">
<button class="btn btn-info btn-sm" id="updateErrors">
<i class="glyphicon glyphicon-refresh"></i> Update
</button>
</div>
<span class="icon"><i class="glyphicon glyphicon-eye-open"></i></span>
<h5>Errors</h5>
</div>
<div class="widget-content nopadding">
<table class="table table-log table-hover" id="errorsLog">
<thead>
<th title="Time">Time</th>
<th title="Worker">Worker</th>
<th title="PID">PID</th>
<th title="Module">Module</th>
<th title="ID">ID</th>
<th title="Message">Message</th>
</thead>
</table>
</div>
</div>

</div>


+ 64
- 0
interface/js/rspamd.js View File

@@ -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(
'<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>'
);
});
$('<tbody/>', {
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();

Loading…
Cancel
Save