From 84a78dbd0d37f5f1968d3914423076de1a070322 Mon Sep 17 00:00:00 2001 From: Kraeutergarten Date: Thu, 16 May 2019 08:20:21 +0200 Subject: [PATCH 1/2] Adds only existing domains in table to the filter and removes additional ajax request. --- data/web/js/site/mailbox.js | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/data/web/js/site/mailbox.js b/data/web/js/site/mailbox.js index 2ed049f41..a26874b87 100644 --- a/data/web/js/site/mailbox.js +++ b/data/web/js/site/mailbox.js @@ -3,28 +3,18 @@ $(document).ready(function() { FooTable.domainFilter = FooTable.Filtering.extend({ construct: function(instance){ this._super(instance); - var domain_list = []; - $.ajax({ - dataType: 'json', - url: '/api/v1/get/domain/all', - jsonp: false, - async: true, - error: function () { - domain_list.push('Cannot read domain list'); - }, - success: function (data) { - $.each(data, function (i, item) { - domain_list.push(item.domain_name); - }); - } - }); - this.domains = domain_list; this.def = 'All Domains'; this.$domain = null; }, $create: function(){ this._super(); - var self = this, + var self = this; + var domains = []; + + $.each(self.ft.rows.all, function(i, row){ + if($.inArray(row.val().domain, domains) === -1) domains.push(row.val().domain); + }); + $form_grp = $('
', {'class': 'form-group'}) .append($('