[Web] Implement table size to quarantine, implements #3325

This commit is contained in:
andryyy 2020-02-22 19:23:57 +01:00
parent 6adeab072d
commit 26e2a1230a
No known key found for this signature in database
GPG Key ID: 8EC34FF2794E25EF
7 changed files with 75 additions and 4 deletions

View File

@ -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');

View File

@ -7,7 +7,43 @@ jQuery(function($){
var entityMap={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};
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<B.length-1);return i.toFixed(1)+" "+B[e]}
// Set paging
$('[data-page-size]').on('click', function(e){
e.preventDefault();
var new_size = $(this).data('page-size');
var parent_ul = $(this).closest('ul');
var table_id = $(parent_ul).data('table-id');
FooTable.get('#' + table_id).pageSize(new_size);
//$(this).parent().addClass('active').siblings().removeClass('active')
heading = $(this).parents('.panel').find('.panel-heading')
var n_results = $(heading).children('.table-lines').text().split(' / ')[1];
$(heading).children('.table-lines').text(function(){
if (new_size > 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');
}
},
});
}

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -678,6 +678,9 @@
"scope_ask_permission": "Приложение запросило доступ к"
},
"quarantine": {
"refresh": "Обновить",
"table_size": "Размер таблицы",
"table_size_show_n": "Отображать %s полей",
"action": "Действия",
"atts": "Вложения",
"check_hash": "Поиск по хешу файла на @ VT",

View File

@ -11,7 +11,21 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><?=$lang['quarantine']['quarantine'];?></h3>
<?=$lang['quarantine']['quarantine'];?> <span class="badge badge-info table-lines"></span>
<div class="btn-group pull-right">
<button class="btn btn-xs btn-default refresh_table" data-draw="draw_quarantine_table" data-table="quarantinetable"><?=$lang['quarantine']['refresh'];?></button>
<button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown"><?=$lang['quarantine']['table_size'];?>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" data-table-id="quarantinetable" role="menu">
<li><a href="#" data-page-size="10"><?=sprintf($lang['quarantine']['table_size_show_n'], 10);?></a></li>
<li><a href="#" data-page-size="20"><?=sprintf($lang['quarantine']['table_size_show_n'], 20);?></a></li>
<li><a href="#" data-page-size="50"><?=sprintf($lang['quarantine']['table_size_show_n'], 50);?></a></li>
<li><a href="#" data-page-size="100"><?=sprintf($lang['quarantine']['table_size_show_n'], 100);?></a></li>
<li><a href="#" data-page-size="200"><?=sprintf($lang['quarantine']['table_size_show_n'], 200);?></a></li>
<li><a href="#" data-page-size="500"><?=sprintf($lang['quarantine']['table_size_show_n'], 500);?></a></li>
</ul>
</div>
</div>
<p style="margin:10px" class="help-block"><?=$lang['quarantine']['qinfo'];?></p>
<p style="margin:10px">