From 26e2a1230a29cbeaf028b6abcad05831eb9637fe Mon Sep 17 00:00:00 2001 From: andryyy Date: Sat, 22 Feb 2020 19:23:57 +0100 Subject: [PATCH] [Web] Implement table size to quarantine, implements #3325 --- data/web/js/site/mailbox.js | 2 +- data/web/js/site/quarantine.js | 51 ++++++++++++++++++++++++++++++++-- data/web/lang/lang.de.json | 3 ++ data/web/lang/lang.en.json | 3 ++ data/web/lang/lang.nl.json | 1 + data/web/lang/lang.ru.json | 3 ++ data/web/quarantine.php | 16 ++++++++++- 7 files changed, 75 insertions(+), 4 deletions(-) diff --git a/data/web/js/site/mailbox.js b/data/web/js/site/mailbox.js index cb1d5d2e..a4e78b02 100644 --- a/data/web/js/site/mailbox.js +++ b/data/web/js/site/mailbox.js @@ -48,7 +48,7 @@ $(document).ready(function() { $(this.$domain).closest("select").selectpicker(); } }); - // todo + // Set paging $('[data-page-size]').on('click', function(e){ e.preventDefault(); var new_size = $(this).data('page-size'); diff --git a/data/web/js/site/quarantine.js b/data/web/js/site/quarantine.js index eea00352..307b39a2 100644 --- a/data/web/js/site/quarantine.js +++ b/data/web/js/site/quarantine.js @@ -7,7 +7,43 @@ jQuery(function($){ 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 n_results) { + new_size = n_results; + } + return new_size + ' / ' + n_results; + }) + }); + $(".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_quarantine_ready(ft, name) { + $('.refresh_table').prop("disabled", false); + heading = ft.$el.parents('.panel').find('.panel-heading') + var ft_paging = ft.use(FooTable.Paging) + $(heading).children('.table-lines').text(function(){ + var total_rows = ft_paging.totalRows; + var size = ft_paging.size; + if (size > total_rows) { + size = total_rows; + } + return size + ' / ' + total_rows; + }) + } function draw_quarantine_table() { ft_quarantinetable = FooTable.init('#quarantinetable', { "columns": [ @@ -69,7 +105,18 @@ jQuery(function($){ "paging": {"enabled": true,"limit": 5,"size": pagination_size}, "sorting": {"enabled": true}, "filtering": {"enabled": true,"position": "left","connectors": false,"placeholder": lang.filter_table}, - "toggleSelector": "table tbody span.footable-toggle" + "toggleSelector": "table tbody span.footable-toggle", + "on": { + "destroy.ft.table": function(e, ft){ + $('.refresh_table').attr('disabled', 'true'); + }, + "ready.ft.table": function(e, ft){ + table_quarantine_ready(ft, 'quarantinetable'); + }, + "after.ft.filtering": function(e, ft){ + table_quarantine_ready(ft, 'quarantinetable'); + } + }, }); } diff --git a/data/web/lang/lang.de.json b/data/web/lang/lang.de.json index 99b8432d..14891787 100644 --- a/data/web/lang/lang.de.json +++ b/data/web/lang/lang.de.json @@ -524,6 +524,9 @@ "help": "Hilfe ein-/ausblenden" }, "quarantine": { + "refresh": "Neu laden", + "table_size": "Tabellengröße", + "table_size_show_n": "Zeige %s Einträge", "disabled_by_config": "Die derzeitige Konfiguration deaktiviert die Funktion des Quarantäne-Systems.", "learn_spam_delete": "Als Spam lernen und löschen", "quarantine": "Quarantäne", diff --git a/data/web/lang/lang.en.json b/data/web/lang/lang.en.json index 7ec7cde8..d711fc95 100644 --- a/data/web/lang/lang.en.json +++ b/data/web/lang/lang.en.json @@ -523,6 +523,9 @@ "help": "Show/Hide help panel" }, "quarantine": { + "refresh": "Refresh", + "table_size": "Table size", + "table_size_show_n": "Show %s items", "disabled_by_config": "The current system configuration disables the quarantine functionality.", "quarantine": "Quarantine", "learn_spam_delete": "Learn as spam and delete", diff --git a/data/web/lang/lang.nl.json b/data/web/lang/lang.nl.json index 0bee235f..ed22b7ec 100644 --- a/data/web/lang/lang.nl.json +++ b/data/web/lang/lang.nl.json @@ -521,6 +521,7 @@ "help": "Toon/verberg hulppaneel" }, "quarantine": { + "refresh": "Ververs", "disabled_by_config": "De huidige systeemconfiguratie deactiveert de quarantainefunctionaliteit.", "quarantine": "Quarantaine", "learn_spam_delete": "Markeer als spam en verwijder", diff --git a/data/web/lang/lang.ru.json b/data/web/lang/lang.ru.json index be194f6c..b3e6b63c 100644 --- a/data/web/lang/lang.ru.json +++ b/data/web/lang/lang.ru.json @@ -678,6 +678,9 @@ "scope_ask_permission": "Приложение запросило доступ к" }, "quarantine": { + "refresh": "Обновить", + "table_size": "Размер таблицы", + "table_size_show_n": "Отображать %s полей", "action": "Действия", "atts": "Вложения", "check_hash": "Поиск по хешу файла на @ VT", diff --git a/data/web/quarantine.php b/data/web/quarantine.php index 60c323d9..6eb7e27c 100644 --- a/data/web/quarantine.php +++ b/data/web/quarantine.php @@ -11,7 +11,21 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
-

+ +
+ + + +