master
andryyy 2017-05-13 09:42:17 +02:00
parent 0950985894
commit 0a90bdc4df
2 changed files with 12 additions and 5 deletions

View File

@ -175,7 +175,7 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm
<div class="form-group"> <div class="form-group">
<label class="control-label col-sm-2" for="domain"><?=$lang['add']['domain'];?>:</label> <label class="control-label col-sm-2" for="domain"><?=$lang['add']['domain'];?>:</label>
<div class="col-sm-10"> <div class="col-sm-10">
<select id="addSelectDomain" name="domain" id="domain" title="<?=$lang['add']['select'];?>" required> <select id="addSelectDomain" name="domain" id="domain" required>
<?php <?php
foreach (mailbox_get_domains() as $domain) { foreach (mailbox_get_domains() as $domain) {
echo "<option>".htmlspecialchars($domain)."</option>"; echo "<option>".htmlspecialchars($domain)."</option>";

View File

@ -1,18 +1,25 @@
$(document).ready(function() { $(document).ready(function() {
// add.php
// Get max. possible quota for a domain when domain field changes auto_fill_quota = function(domain) {
$('#addSelectDomain').on('change', function() { $.get("/api/v1/get/domain/" + domain, function(data){
$.get("/api/v1/get/domain/" + this.value, function(data){
var result = $.parseJSON(JSON.stringify(data)); var result = $.parseJSON(JSON.stringify(data));
max_new_mailbox_quota = ( result.max_new_mailbox_quota / 1048576); max_new_mailbox_quota = ( result.max_new_mailbox_quota / 1048576);
if (max_new_mailbox_quota != '0') { if (max_new_mailbox_quota != '0') {
$("#quotaBadge").html('max. ' + max_new_mailbox_quota + ' MiB'); $("#quotaBadge").html('max. ' + max_new_mailbox_quota + ' MiB');
$('#addInputQuota').attr({"disabled": false, "value": "", "type": "number", "max": max_new_mailbox_quota}); $('#addInputQuota').attr({"disabled": false, "value": "", "type": "number", "max": max_new_mailbox_quota});
$('#addInputQuota').val(max_new_mailbox_quota);
} }
else { else {
$("#quotaBadge").html('max. ' + max_new_mailbox_quota + ' MiB'); $("#quotaBadge").html('max. ' + max_new_mailbox_quota + ' MiB');
$('#addInputQuota').attr({"disabled": true, "value": "", "type": "text", "value": "n/a"}); $('#addInputQuota').attr({"disabled": true, "value": "", "type": "text", "value": "n/a"});
$('#addInputQuota').val(max_new_mailbox_quota);
} }
}); });
}
$('#addSelectDomain').on('change', function() {
auto_fill_quota($('#addSelectDomain').val());
}); });
auto_fill_quota($('#addSelectDomain').val());
}); });