displaying assigned domain quota

adding the amount of assigned domain quota to the disk usage display as potentially used disk space
master
heavygale 2019-09-29 17:45:36 +02:00
parent 8b453ab803
commit 1e6a032d1e
5 changed files with 51 additions and 12 deletions

View File

@ -45,3 +45,13 @@ tbody {
width: 15px;
height: 15px;
}
.disk_space {
margin-top: 20px;
}
.progress-bar-committed {
background-color: #B6E1F2;
}
.usage-info {
display: inline-block;
margin-right: 5px;
}

View File

@ -43,6 +43,10 @@ else {
<?php
$exec_fields = array('cmd' => 'system', 'task' => 'df', 'dir' => '/var/vmail');
$vmail_df = explode(',', json_decode(docker('post', 'dovecot-mailcow', 'exec', $exec_fields), true));
$domainQuota = round(domain_admin('total_quota')/1024);
$quotaPercent1 = round(($domainQuota/substr($vmail_df[3], 0, -1))*100);
$quotaPercent2 = round((($domainQuota-substr($vmail_df[2], 0, -1))/substr($vmail_df[3], 0, -1))*100);
$quotaPercent2 = ($quotaPercent2+substr($vmail_df[4], 0, -1)>100) ? 100-substr($vmail_df[4], 0, -1) : $quotaPercent2; //handling overcommitment
?>
<div role="tabpanel" class="tab-pane active" id="tab-containers">
<div class="panel panel-default">
@ -53,12 +57,15 @@ else {
<div class="row">
<div class="col-sm-3">
<p>/var/vmail on <?=$vmail_df[0];?></p>
<p><?=$vmail_df[2];?> / <?=$vmail_df[1];?> (<?=$vmail_df[4];?>)</p>
<p class="disk_space"><?=$lang['debug']['disk_space'];?> <?=$vmail_df[3];?>B</p>
</div>
<div class="col-sm-9">
<div class="progress">
<div class="progress-bar progress-bar-info" role="progressbar" style="width:<?=$vmail_df[4];?>"></div>
<div class="progress-bar progress-bar-committed" role="progressbar" style="width:<?=$quotaPercent2;?>%"></div>
</div>
<p><span class="container-indicator label usage-info progress-bar-info">&nbsp;</span> <?=$lang['debug']['disk_used'];?> <?=$vmail_df[2];?>B (<?=$vmail_df[4];?>)</p>
<p><span class="container-indicator label usage-info progress-bar-committed">&nbsp;</span> <?=$lang['debug']['total_quota'];?> <?=$domainQuota;?>GB (<?=$quotaPercent1;?>%)</p>
</div>
</div>
</div>
@ -344,7 +351,6 @@ $lang_admin = json_encode($lang['admin']);
echo "var lang = ". $lang_admin . ";\n";
echo "var csrf_token = '". $_SESSION['CSRF']['TOKEN'] . "';\n";
echo "var log_pagination_size = '". $LOG_PAGINATION_SIZE . "';\n";
?>
</script>
<?php

View File

@ -444,5 +444,18 @@ function domain_admin($_action, $_data = null) {
return $domainadmindata;
break;
case 'total_quota':
if ($_SESSION['mailcow_cc_role'] != "admin") {
$_SESSION['return'][] = array(
'type' => 'danger',
'log' => array(__FUNCTION__, $_action, $_data_log),
'msg' => 'access_denied'
);
return false;
}
$stmt = $pdo->query("SELECT SUM(`quota`) AS `quota` FROM `domain`");
$row = $stmt->fetch(PDO::FETCH_ASSOC);
return $row['quota'];
break;
}
}

View File

@ -150,7 +150,7 @@ $lang['success']['resource_removed'] = 'Ressource %s wurde entfernt';
$lang['warning']['cannot_delete_self'] = 'Kann derzeit eingeloggten Benutzer nicht entfernen';
$lang['warning']['no_active_admin'] = 'Kann letzten aktiven Administrator nicht deaktivieren';
$lang['danger']['max_quota_in_use'] = 'Mailbox Speicherplatzlimit muss größer oder gleich %d MiB sein';
$lang['danger']['domain_quota_m_in_use'] = 'Domain Speicherplatzlimit muss größer oder gleich %d MiB sein';
$lang['danger']['domain_quota_m_in_use'] = 'Domain-Speicherplatzlimit muss größer oder gleich %d MiB sein';
$lang['danger']['mailboxes_in_use'] = 'Maximale Anzahl an Mailboxen muss größer oder gleich %d sein';
$lang['danger']['aliases_in_use'] = 'Maximale Anzahl an Aliassen muss größer oder gleich %d sein';
$lang['danger']['sender_acl_invalid'] = 'Sender ACL %s ist ungültig';
@ -375,7 +375,7 @@ $lang['edit']['mailbox'] = 'Mailbox bearbeiten';
$lang['edit']['description'] = 'Beschreibung';
$lang['edit']['max_aliases'] = 'Max. Aliasse';
$lang['edit']['max_quota'] = 'Max. Größe per Mailbox (MiB)';
$lang['edit']['domain_quota'] = 'Domain Speicherplatz gesamt (MiB)';
$lang['edit']['domain_quota'] = 'Domain-Speicherplatz gesamt (MiB)';
$lang['edit']['backup_mx_options'] = 'Backup MX Optionen';
$lang['edit']['relay_domain'] = 'Diese Domain relayen';
$lang['edit']['relay_all'] = 'Alle Empfänger-Adressen relayen';
@ -474,7 +474,7 @@ $lang['add']['description'] = 'Beschreibung';
$lang['add']['max_aliases'] = 'Max. mögliche Aliasse';
$lang['add']['max_mailboxes'] = 'Max. mögliche Mailboxen';
$lang['add']['mailbox_quota_m'] = 'Max. Speicherplatz pro Mailbox (MiB)';
$lang['add']['domain_quota_m'] = 'Domain Speicherplatz gesamt (MiB)';
$lang['add']['domain_quota_m'] = 'Domain-Speicherplatz gesamt (MiB)';
$lang['add']['backup_mx_options'] = 'Backup MX Optionen';
$lang['add']['relay_all'] = 'Alle Empfänger-Adressen relayen';
$lang['add']['relay_domain'] = 'Relay Domain';
@ -791,6 +791,13 @@ $lang['debug']['solr_last_modified'] = 'Zuletzt geändert';
$lang['debug']['solr_size'] = 'Größe';
$lang['debug']['solr_docs'] = 'Dokumente';
$lang['debug']['disk_usage'] = 'Festplattenauslastung';
$lang['debug']['containers_info'] = "Container-Informationen";
$lang['debug']['disk_space'] = "Verfügbarer Speicherplatz:";
$lang['debug']['disk_used'] = "Von Mailboxen belegter Speicherplatz:";
$lang['debug']['total_quota'] = "Zugewiesener Domain-Speicherplatz:";
$lang['quarantine']['release_body'] = "Die ursprüngliche Nachricht wurde als EML-Datei im Anhang hinterlegt.";
$lang['danger']['release_send_failed'] = "Die Nachricht konnte nicht versendet werden: %s";
$lang['quarantine']['release_subject'] = "Potentiell schädliche Nachricht aus Quarantäne: %s";

View File

@ -820,6 +820,10 @@ $lang['debug']['disk_usage'] = 'Disk usage';
$lang['debug']['containers_info'] = "Container information";
$lang['debug']['restart_container'] = 'Restart';
$lang['debug']['disk_space'] = "Available disk space:";
$lang['debug']['disk_used'] = "Disk space occupied by mailboxes:";
$lang['debug']['total_quota'] = "Total amount of assigned domain quota:";
$lang['quarantine']['release_body'] = "We have attached your message as eml file to this message.";
$lang['danger']['release_send_failed'] = "Message could not be released: %s";
$lang['quarantine']['release_subject'] = "Potentially damaging quarantine item %s";
@ -915,4 +919,3 @@ $lang['mailbox']['alias_domain_backupmx'] = 'Alias domain inactive for relay dom
$lang['danger']['extra_acl_invalid'] = 'External sender address "%s" is invalid';
$lang['danger']['extra_acl_invalid_domain'] = 'External sender "%s" uses an invalid domain';