From: Vsevolod Stakhov Date: Mon, 30 Jan 2017 23:37:38 +0000 (+0000) Subject: [WebUI] Add preliminary save symbols clustering X-Git-Tag: 1.5.0~217 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=94340378587dd1319f14cb4d58fdd6c1662d3dd7;p=thirdparty%2Frspamd.git [WebUI] Add preliminary save symbols clustering --- diff --git a/interface/index.html b/interface/index.html index 11a0f3f5a8..d8f6e8c704 100644 --- a/interface/index.html +++ b/interface/index.html @@ -189,9 +189,10 @@ Symbol Description Score - Hits + Frequency Avg.time Save data + Save cluster diff --git a/interface/js/rspamd.js b/interface/js/rspamd.js index ad0f5ce5f3..5e2b5bfa72 100644 --- a/interface/js/rspamd.js +++ b/interface/js/rspamd.js @@ -1043,7 +1043,8 @@ '" id="_sym_' + item.symbol + '">' + '' + item.frequency + '' + '' + Number(item.time).toFixed(2) + 'ms' + - ''); + '' + + ''); }); }); $('', { @@ -1065,12 +1066,16 @@ {"width": "7%", "searchable": false, "orderable": true, "type": "num"}, {"searchable": false, "orderable": true, "type": "num"}, {"searchable": false, "orderable": true, "type": "num"}, - {"width": "5%", "searchable": false, "orderable": false, "type": "html"} + {"width": "5%", "searchable": false, "orderable": false, "type": "html"}, + {"width": "7%", "searchable": false, "orderable": false, "type": "html"} ], }); symbols.columns.adjust().draw(); - $('#symbolsTable :button').on('click', - function(){saveSymbols("./savesymbols", "symbolsTable");}); + $('#symbolsTable :button').on('click', function() { + var value = $(this).attr("value"); + saveSymbols("./savesymbols", "symbolsTable", + value == 'Save cluster'); + }); if (read_only) { $( ".mb-disabled" ).attr('disabled', true); } @@ -1447,7 +1452,7 @@ } // @upload symbols from modal - function saveSymbols(action, id) { + function saveSymbols(action, id, is_cluster) { var inputs = $('#' + id + ' :input[data-role="numerictextbox"]'); var url = action; var values = []; @@ -1457,24 +1462,36 @@ value: parseFloat($(this).val()) }); }); - $.ajax({ - data: JSON.stringify(values), - dataType: 'json', - type: 'POST', - url: url, - jsonp: false, - beforeSend: function (xhr) { - xhr.setRequestHeader('Password', getPassword()); - }, - success: function () { + if (is_cluster) { + queryNeighbours(url, function () { alertMessage('alert-modal alert-success', 'Symbols successfully saved'); - }, - error: function (data) { - alertMessage('alert-modal alert-error', data.statusText); - } - }); - $('#modalDialog').modal('hide'); - return false; + }, function (serv, qXHR, textStatus, errorThrown) { + alertMessage('alert-modal alert-error', + 'Save symbols error on ' + + serv.name + ': ' + errorThrown); + }, "POST", {}, { + data: JSON.stringify(values), + dataType: "json", + }); + } + else { + $.ajax({ + data: JSON.stringify(values), + dataType: 'json', + type: 'POST', + url: url, + jsonp: false, + beforeSend: function (xhr) { + xhr.setRequestHeader('Password', getPassword()); + }, + success: function () { + alertMessage('alert-modal alert-success', 'Symbols successfully saved'); + }, + error: function (data) { + alertMessage('alert-modal alert-error', data.statusText); + } + }); + } } // @connect to server function connectRSPAMD() {