From 92f8b4a09156c5b30d6f4fc49e82a38208d500a6 Mon Sep 17 00:00:00 2001 From: andryyy Date: Mon, 6 Apr 2020 08:52:27 +0200 Subject: [PATCH] [Web] Add domain statistics --- data/web/inc/functions.mailbox.inc.php | 14 ++++++++++++-- data/web/js/site/mailbox.js | 16 +++++++++++++--- data/web/lang/lang.de.json | 1 + data/web/lang/lang.en.json | 1 + 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/data/web/inc/functions.mailbox.inc.php b/data/web/inc/functions.mailbox.inc.php index 272003b4..8238db31 100644 --- a/data/web/inc/functions.mailbox.inc.php +++ b/data/web/inc/functions.mailbox.inc.php @@ -3238,8 +3238,18 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { $domaindata['def_new_mailbox_quota'] = ($row['defquota'] * 1048576); } $domaindata['quota_used_in_domain'] = $MailboxDataDomain['in_use']; - $domaindata['bytes_total'] = $SumQuotaInUse['bytes_total']; - $domaindata['msgs_total'] = $SumQuotaInUse['msgs_total']; + if (!empty($SumQuotaInUse['bytes_total'])) { + $domaindata['bytes_total'] = $SumQuotaInUse['bytes_total']; + } + else { + $domaindata['bytes_total'] = 0; + } + if (!empty($SumQuotaInUse['msgs_total'])) { + $domaindata['msgs_total'] = $SumQuotaInUse['msgs_total']; + } + else { + $domaindata['msgs_total'] = 0; + } $domaindata['mboxes_in_domain'] = $MailboxDataDomain['count']; $domaindata['mboxes_left'] = $row['mailboxes'] - $MailboxDataDomain['count']; $domaindata['domain_name'] = $row['domain']; diff --git a/data/web/js/site/mailbox.js b/data/web/js/site/mailbox.js index baefd8c7..6a6314a3 100644 --- a/data/web/js/site/mailbox.js +++ b/data/web/js/site/mailbox.js @@ -247,6 +247,15 @@ jQuery(function($){ return Number(res[0]); }, }, + {"name":"stats","style":{"whiteSpace":"nowrap"},"title":lang.stats,"formatter": function(value){ + res = value.split("/"); + return ' ' + res[0] + ' / ' + humanFileSize(res[1]); + }, + "sortValue": function(value){ + res = value.split("/"); + return Number(res[0]); + }, + }, {"name":"def_quota_for_mbox","title":lang.mailbox_defquota,"breakpoints":"xs sm md","style":{"width":"125px"}}, {"name":"max_quota_for_mbox","title":lang.mailbox_quota,"breakpoints":"xs sm","style":{"width":"125px"}}, {"name":"rl","title":"RL","breakpoints":"xs sm md lg","style":{"maxWidth":"100px","width":"100px"}}, @@ -266,7 +275,8 @@ jQuery(function($){ $.each(data, function (i, item) { item.aliases = item.aliases_in_domain + " / " + item.max_num_aliases_for_domain; item.mailboxes = item.mboxes_in_domain + " / " + item.max_num_mboxes_for_domain; - item.quota = item.quota_used_in_domain + "/" + item.max_quota_for_domain; + item.quota = item.quota_used_in_domain + "/" + item.max_quota_for_domain + "/" + item.bytes_total; + item.stats = item.msgs_total + "/" + item.bytes_total; if (!item.rl) { item.rl = '∞'; } else { @@ -354,7 +364,7 @@ jQuery(function($){ {"name":"last_mail_login","breakpoints":"xs sm","formatter":function unix_time_format(tm) { if (tm == '') { return lang.no; } else { var date = new Date(tm ? tm * 1000 : 0); return date.toLocaleString(); }},"title":lang.last_mail_login,"style":{"width":"170px"}}, {"name":"quarantine_notification","filterable": false,"title":lang.quarantine_notification,"breakpoints":"all"}, {"name":"in_use","filterable": false,"type":"html","title":lang.in_use,"sortValue": function(value){ - return Number($(value).find(".progress-bar").attr('aria-valuenow')); + return Number($(value).find(".progress-bar-mailbox").attr('aria-valuenow')); }, }, {"name":"messages","filterable": false,"title":lang.msg_num,"breakpoints":"xs sm md"}, @@ -413,7 +423,7 @@ jQuery(function($){ ''; } item.in_use = '
' + - '
' + item.percent_in_use + '%' + '
'; item.username = escapeHtml(item.username); }); diff --git a/data/web/lang/lang.de.json b/data/web/lang/lang.de.json index 9a8983f5..0f8200ef 100644 --- a/data/web/lang/lang.de.json +++ b/data/web/lang/lang.de.json @@ -572,6 +572,7 @@ "notified": "Benachrichtigt" }, "mailbox": { + "stats": "Statistik", "last_mail_login": "Letzter Mail-Login", "table_size": "Tabellengröße", "table_size_show_n": "Zeige %s Einträge", diff --git a/data/web/lang/lang.en.json b/data/web/lang/lang.en.json index c91e8213..49cfa4a5 100644 --- a/data/web/lang/lang.en.json +++ b/data/web/lang/lang.en.json @@ -571,6 +571,7 @@ "notified": "Notified" }, "mailbox": { + "stats": "Statistics", "last_mail_login": "Last mail login", "table_size": "Table size", "table_size_show_n": "Show %s items",