From 156e2aa6a09822924b92f06e5c338f27fcc2e537 Mon Sep 17 00:00:00 2001 From: "andre.peters" Date: Sun, 19 Mar 2017 19:21:57 +0100 Subject: Use FooTable to draw symbol table --- interface/js/app/symbols.js | 141 +++++++++++++++++++++++++++++++------------- 1 file changed, 99 insertions(+), 42 deletions(-) (limited to 'interface') diff --git a/interface/js/app/symbols.js b/interface/js/app/symbols.js index f1169e544..6d7463620 100644 --- a/interface/js/app/symbols.js +++ b/interface/js/app/symbols.js @@ -22,7 +22,7 @@ THE SOFTWARE. */ -define(['jquery', 'datatables'], +define(['jquery', 'footable'], function($) { var interface = {} @@ -36,6 +36,7 @@ function($) { value: parseFloat($(this).val()) }); }); + if (is_cluster) { rspamd.queryNeighbours(url, function () { rspamd.alertMessage('alert-modal alert-success', 'Symbols successfully saved'); @@ -94,6 +95,8 @@ function($) { xhr.setRequestHeader('Password', rspamd.getPassword()); }, success: function (data) { + var distinct_groups = []; + var lookup = {}; $.each(data, function (i, group) { $.each(group.rules, function (i, item) { var max = 20; @@ -101,6 +104,7 @@ function($) { if (item.weight > max) { max = item.weight * 2; } + item.group = group.group if (item.weight < min) { min = item.weight * 2; } @@ -110,57 +114,110 @@ function($) { } else { label_class = 'scorebar-spam'; } - + item.weight = '' if (!item.time) { item.time = 0; } + item.time = Number(item.time).toFixed(2) + 's' if (!item.frequency) { item.frequency = 0; } - items.push('' + - '
' + group.group + '
' + - '' + item.symbol + '' + - '
' + item.description + '
' + - '' + - '' + item.frequency + '' + - '' + Number(item.time).toFixed(2) + 'ms' + - '' + - ''); + item.frequency = Number(item.frequency).toFixed(2) + if (!(item.group in lookup)) { + lookup[item.group] = 1; + distinct_groups.push(item.group); + } + item.save = '' + + ' '; + items.push(item) }); }); - $('', { - html: items.join('') - }).insertAfter('#symbolsTable thead'); - tables.symbols = $('#symbolsTable').DataTable({ - "paging": false, - "orderMulti": true, - "order": [ - [0, "asc"], - [1, "asc"], - [3, "desc"] - ], - "info": false, + FooTable.groupFilter = FooTable.Filtering.extend({ + construct : function(instance) { + this._super(instance); + this.groups = distinct_groups; + this.def = 'Any group'; + this.$group = null; + }, + $create : function() { + this._super(); + var self = this, $form_grp = $('
', { + 'class' : 'form-group' + }).append($('