From 3f0aca7a354c8656d1a3076ee9038c95b5822cd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= Date: Sun, 22 Jul 2018 11:03:32 +0200 Subject: [PATCH] [Web] Add refresh button and counter to mailbox tables [Web] Fix multiple "no results" rows when refreshing an empty table [Web] Remember page when going back to a table with pagination, fixes #1598 --- data/web/css/debug.css | 3 + data/web/css/mailbox.css | 3 + data/web/debug.php | 36 +++++----- data/web/js/debug.js | 142 ++++++++++++++++++--------------------- data/web/js/mailbox.js | 102 +++++++++++++++++++++++++++- data/web/mailbox.php | 46 ++++++++++--- 6 files changed, 223 insertions(+), 109 deletions(-) diff --git a/data/web/css/debug.css b/data/web/css/debug.css index e46a5b07..9aa53256 100644 --- a/data/web/css/debug.css +++ b/data/web/css/debug.css @@ -35,3 +35,6 @@ table.footable>tbody>tr.footable-empty>td { .inputMissingAttr { border-color: #FF4136; } +.table-lines { + vertical-align: inherit; +} \ No newline at end of file diff --git a/data/web/css/mailbox.css b/data/web/css/mailbox.css index 44babe6a..f7685f1a 100644 --- a/data/web/css/mailbox.css +++ b/data/web/css/mailbox.css @@ -43,3 +43,6 @@ table.footable>tbody>tr.footable-empty>td { max-width: 150px; word-break: break-all; } +.table-lines { + vertical-align: inherit; +} \ No newline at end of file diff --git a/data/web/debug.php b/data/web/debug.php index 5bf97d32..3be1d85f 100644 --- a/data/web/debug.php +++ b/data/web/debug.php @@ -116,11 +116,11 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-
Postfix +
Postfix
- +
@@ -133,11 +133,11 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-
Dovecot +
Dovecot
- +
@@ -150,11 +150,11 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-
SOGo +
SOGo
- +
@@ -167,11 +167,11 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-
Netfilter +
Netfilter
- +
@@ -184,11 +184,11 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-
Rspamd history +
Rspamd history
- +
@@ -202,11 +202,11 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-
Autodiscover +
Autodiscover
- +
@@ -219,11 +219,11 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-
Watchdog +
Watchdog
- +
@@ -236,11 +236,11 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-
ACME +
ACME
- +
@@ -253,11 +253,11 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-
API +
API
- +
diff --git a/data/web/js/debug.js b/data/web/js/debug.js index 95b8ea69..fce14fde 100644 --- a/data/web/js/debug.js +++ b/data/web/js/debug.js @@ -1,44 +1,35 @@ jQuery(function($){ + if (localStorage.getItem("current_page") === null) { + var current_page = {}; + } else { + var current_page = JSON.parse(localStorage.getItem('current_page')); + } // http://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery var entityMap={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="}; function escapeHtml(n){return String(n).replace(/[&<>"'`=\/]/g,function(n){return entityMap[n]})} function humanFileSize(i){if(Math.abs(i)<1024)return i+" B";var B=["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],e=-1;do{i/=1024,++e}while(Math.abs(i)>=1024&&e()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; @@ -211,6 +216,28 @@ jQuery(function($){ var date = new Date(tm ? tm * 1000 : 0); return date.toLocaleString(); } + $(".refresh_table").on('click', function(e) { + e.preventDefault(); + var table_name = $(this).data('table'); + $('#' + table_name).find("tr.footable-empty").remove(); + draw_table = $(this).data('draw'); + eval(draw_table + '()'); + }); + function table_mailbox_ready(ft, name) { + heading = ft.$el.parents('.tab-pane').find('.panel-heading') + var ft_paging = ft.use(FooTable.Paging) + $(heading).children('.table-lines').text(function(){ + return ft_paging.totalRows; + }) + if (current_page[name]) { + ft_paging.goto(parseInt(current_page[name])) + } + } + function table_mailbox_paging(ft, name) { + var ft_paging = ft.use(FooTable.Paging) + current_page[name] = ft_paging.current; + localStorage.setItem('current_page', JSON.stringify(current_page)); + } function draw_domain_table() { ft_domain_table = FooTable.init('#domain_table', { "columns": [ @@ -273,6 +300,14 @@ jQuery(function($){ }, "sorting": { "enabled": true + }, + "on": { + "ready.ft.table": function(e, ft){ + table_mailbox_ready(ft, 'domain_table'); + }, + "after.ft.paging": function(e, ft){ + table_mailbox_paging(ft, 'domain_table'); + } } }); } @@ -351,6 +386,14 @@ jQuery(function($){ }, "sorting": { "enabled": true + }, + "on": { + "ready.ft.table": function(e, ft){ + table_mailbox_ready(ft, 'mailbox_table'); + }, + "after.ft.paging": function(e, ft){ + table_mailbox_paging(ft, 'mailbox_table'); + } } }); } @@ -408,6 +451,14 @@ jQuery(function($){ }, "sorting": { "enabled": true + }, + "on": { + "ready.ft.table": function(e, ft){ + table_mailbox_ready(ft, 'resource_table'); + }, + "after.ft.paging": function(e, ft){ + table_mailbox_paging(ft, 'resource_table'); + } } }); } @@ -462,6 +513,14 @@ jQuery(function($){ }, "sorting": { "enabled": true + }, + "on": { + "ready.ft.table": function(e, ft){ + table_mailbox_ready(ft, 'bcc_table'); + }, + "after.ft.paging": function(e, ft){ + table_mailbox_paging(ft, 'bcc_table'); + } } }); } @@ -511,6 +570,14 @@ jQuery(function($){ }, "sorting": { "enabled": true + }, + "on": { + "ready.ft.table": function(e, ft){ + table_mailbox_ready(ft, 'recipient_map_table'); + }, + "after.ft.paging": function(e, ft){ + table_mailbox_paging(ft, 'recipient_map_table'); + } } }); } @@ -572,6 +639,14 @@ jQuery(function($){ }, "sorting": { "enabled": true + }, + "on": { + "ready.ft.table": function(e, ft){ + table_mailbox_ready(ft, 'alias_table'); + }, + "after.ft.paging": function(e, ft){ + table_mailbox_paging(ft, 'alias_table'); + } } }); } @@ -616,11 +691,16 @@ jQuery(function($){ "connectors": false, "placeholder": lang.filter_table }, - "components": { - "filtering": FooTable.domainFilter - }, "sorting": { "enabled": true + }, + "on": { + "ready.ft.table": function(e, ft){ + table_mailbox_ready(ft, 'aliasdomain_table'); + }, + "after.ft.paging": function(e, ft){ + table_mailbox_paging(ft, 'aliasdomain_table'); + } } }); } @@ -688,6 +768,14 @@ jQuery(function($){ }, "sorting": { "enabled": true + }, + "on": { + "ready.ft.table": function(e, ft){ + table_mailbox_ready(ft, 'sync_job_table'); + }, + "after.ft.paging": function(e, ft){ + table_mailbox_paging(ft, 'sync_job_table'); + } } }); } @@ -743,6 +831,14 @@ jQuery(function($){ }, "sorting": { "enabled": true + }, + "on": { + "ready.ft.table": function(e, ft){ + table_mailbox_ready(ft, 'filter_table'); + }, + "after.ft.paging": function(e, ft){ + table_mailbox_paging(ft, 'filter_table'); + } } }); }; diff --git a/data/web/mailbox.php b/data/web/mailbox.php index 58a569dd..e236a8af 100644 --- a/data/web/mailbox.php +++ b/data/web/mailbox.php @@ -30,7 +30,10 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-

+ +
+ +
@@ -58,7 +61,10 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-

+ +
+ +
@@ -82,7 +88,10 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-

+ +
+ +
@@ -112,10 +121,10 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-
- + +
+
-

@@ -139,7 +148,10 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-

+ +
+ +
@@ -163,7 +175,10 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-

+ +
+ +
@@ -189,7 +204,10 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-

+ +
+ +

@@ -217,7 +235,10 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-

+ +
+ +

@@ -242,7 +263,10 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-

+ +
+ +