From 34991810fb61e1bc8cf4a501416b763df52294a4 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 2 Jul 2016 21:16:37 +0100 Subject: [PATCH] [WebUI] Rework webui - Remove uploaders as they are utterly broken - Simplify actions loading - Rework interface loading --- interface/css/rspamd.css | 2 +- interface/index.html | 46 +---------- interface/js/rspamd.js | 171 +++++++-------------------------------- 3 files changed, 32 insertions(+), 187 deletions(-) diff --git a/interface/css/rspamd.css b/interface/css/rspamd.css index 87ecc3bb3..fd73d41ce 100644 --- a/interface/css/rspamd.css +++ b/interface/css/rspamd.css @@ -302,7 +302,7 @@ input::-webkit-inner-spin-button { height:200px; } .scan-textarea { - height:400px; + height:300px; } .stat-boxes { overflow:hidden !important; diff --git a/interface/index.html b/interface/index.html index a009f7060..cef29803f 100644 --- a/interface/index.html +++ b/interface/index.html @@ -6,7 +6,6 @@ - @@ -116,8 +115,7 @@
Actions
-
-
+
@@ -148,20 +146,6 @@
Learn RSPAMD
-
-
-
-
Upload SPAM examples:
- -
-
-
-
Upload HAM examples:
- -
-
-
-
@@ -175,29 +159,6 @@

-
-
-
Upload Fuzzy examples:
-
- -
- -
-
-
- -
- -
-
- -
-
-
Insert raw Fuzzy storage:
@@ -207,7 +168,7 @@ Flag
- +
@@ -215,7 +176,7 @@ Weight
- +

@@ -357,7 +318,6 @@ - diff --git a/interface/js/rspamd.js b/interface/js/rspamd.js index bf860b238..a7972caa6 100644 --- a/interface/js/rspamd.js +++ b/interface/js/rspamd.js @@ -549,6 +549,12 @@ // } // @get history log function getHistory() { + + if (history) { + history.destroy(); + $('#historyLog').children('tbody').remove(); + } + var items = []; $.ajax({ dataType: 'json', @@ -671,8 +677,10 @@ } // @update history log $('#resetHistory').on('click', function () { - history.destroy(); - $('#historyLog').children('tbody').remove(); + if (history) { + history.destroy(); + $('#historyLog').children('tbody').remove(); + } $.ajax({ dataType: 'json', type: 'GET', @@ -688,143 +696,12 @@ } }); }); + // @reset history log $('#updateHistory').on('click', function () { - history.destroy(); - $('#historyLog').children('tbody').remove(); getHistory(); }); - // @spam upload form - function createUploaders() { - var spamUploader = new qq.FineUploader({ - element: $('#uploadSpamFiles')[0], - request: { - endpoint: 'learnspam', - customHeaders: { - 'Password': getPassword() - } - }, - validation: { - allowedExtensions: ['eml', 'msg', 'txt', 'html'], - sizeLimit: 52428800 - }, - autoUpload: false, - text: { - uploadButton: ' Select Files' - }, - retry: { - enableAuto: false - }, - template: '
' + - '
{dragZoneText}
' + - '
{uploadButtonText}
' + - '{dropProcessingText}' + - '
    ' + - '
    ', - classes: { - success: 'alert-success', - fail: 'alert-error' - }, - debug: true, - callbacks: { - onError: function () { - alertMessage('alert-error', 'Cannot upload data'); - } - } - }); - var hamUploader = new qq.FineUploader({ - element: $('#uploadHamFiles')[0], - request: { - endpoint: 'learnham', - customHeaders: { - 'Password': getPassword() - } - }, - validation: { - allowedExtensions: ['eml', 'msg', 'txt', 'html'], - sizeLimit: 52428800 - }, - autoUpload: false, - text: { - uploadButton: ' Select Files' - }, - retry: { - enableAuto: true - }, - template: '
    ' + - '
    {dragZoneText}
    ' + - '
    {uploadButtonText}
    ' + - '{dropProcessingText}' + - '
      ' + - '
      ', - classes: { - success: 'alert-success', - fail: 'alert-error' - }, - debug: true, - callbacks: { - onError: function () { - alertMessage('alert-error', 'Cannot upload data'); - } - } - }); - var data = { - flag: $('#fuzzyFlagUpload').val(), - weight: $('#fuzzyWeightUpload').val() - }; - var fuzzyUploader = new qq.FineUploader({ - element: $('#uploadFuzzyFiles')[0], - request: { - endpoint: 'learnfuzzy', - customHeaders: { - 'Password': getPassword() - } - }, - validation: { - allowedExtensions: ['eml', 'msg', 'txt', 'html', 'pdf'], - sizeLimit: 52428800 - }, - autoUpload: false, - text: { - uploadButton: ' Select Files' - }, - retry: { - enableAuto: true - }, - template: '
      ' + - '
      {dragZoneText}
      ' + - '
      {uploadButtonText}
      ' + - '{dropProcessingText}' + - '
        ' + - '
        ', - classes: { - success: 'alert-success', - fail: 'alert-error' - }, - debug: true, - callbacks: { - onError: function () { - alertMessage('alert-error', 'Cannot upload data'); - } - } - }); - // @upload spam button - $('#uploadSpamTrigger').on('click', function () { - spamUploader.uploadStoredFiles(); - return false; - }); - // @upload ham button - $('#uploadHamTrigger').on('click', function () { - hamUploader.uploadStoredFiles(); - return false; - }); - // @upload fuzzy button - $('#uploadFuzzyTrigger').on('click', function () { - fuzzyUploader.uploadStoredFiles(); - uploadText(data, 'fuzzy'); - return false; - }); - } + // @upload text function uploadText(data, source) { if (source === 'spam') { @@ -1033,10 +910,11 @@ min = item.value; } }); - $('', { id: 'actionsForm', class: '', html: items.join('') }).appendTo('#actionsBody'); - $('
        ' + + + $('#actionsBody').html('' + items.join('') + + '
        ' + '
        ').appendTo('#actionsForm'); + 'type="submit">Save actions
        '); } }); } @@ -1194,17 +1072,21 @@ statWidgets(); $('#mainUI').show(); $('#progress').show(); - getActions(); - getMaps(); - createUploaders(); - getSymbols(); - getHistory(); + getChart(); initGraph(); $('#progress').hide(); $(disconnect).show(); } + connectRSPAMD(); + + $('#configuration_nav').bind('click', function (e) { + getActions(); + getMaps(); + getSymbols(); + }); + $(document).ajaxStart(function () { $('#navBar').addClass('loading'); }); @@ -1217,5 +1099,8 @@ $('#throughput_nav').bind('click', function () { getGraphData(selected.selData); }); + $('#history_nav').bind('click', function() { + getHistory(); + }); }); })(); -- 2.39.5