[Web] Remove blocking user_details function request in bcc list for faster loading with many mailboxes

master
andryyy 2021-08-19 20:27:59 +02:00
parent 62fbaf8248
commit 7ab1405b00
No known key found for this signature in database
GPG Key ID: 8EC34FF2794E25EF
6 changed files with 122 additions and 95 deletions

View File

@ -98,6 +98,38 @@ $(document).ready(function() {
auto_fill_quota($('#addSelectDomain').val()); auto_fill_quota($('#addSelectDomain').val());
}); });
auto_fill_quota($('#addSelectDomain').val()); auto_fill_quota($('#addSelectDomain').val());
// Read bcc local dests
// Using ajax to not be a blocking moo
$.get("/api/v1/get/bcc-destination-options", function(data){
// Domains
var optgroup = "<optgroup label='" + lang.domains + "'>";
$.each(data.domains, function(index, domain){
optgroup += "<option value='" + domain + "'>" + domain + "</option>"
});
optgroup += "</optgroup>"
$('#bcc-local-dest').append(optgroup);
// Alias domains
var optgroup = "<optgroup label='" + lang.domain_aliases + "'>";
$.each(data.alias_domains, function(index, alias_domain){
optgroup += "<option value='" + alias_domain + "'>" + alias_domain + "</option>"
});
optgroup += "</optgroup>"
$('#bcc-local-dest').append(optgroup);
// Mailboxes and aliases
$.each(data.mailboxes, function(mailbox, aliases){
var optgroup = "<optgroup label='" + mailbox + "'>";
$.each(aliases, function(index, alias){
optgroup += "<option value='" + alias + "'>" + alias + "</option>"
});
optgroup += "</optgroup>"
$('#bcc-local-dest').append(optgroup);
});
// Finish
$('#bcc-local-dest').find('option:selected').remove();
$('#bcc-local-dest').selectpicker('refresh');
});
$(".goto_checkbox").click(function( event ) { $(".goto_checkbox").click(function( event ) {
$("form[data-id='add_alias'] .goto_checkbox").not(this).prop('checked', false); $("form[data-id='add_alias'] .goto_checkbox").not(this).prop('checked', false);
if ($("form[data-id='add_alias'] .goto_checkbox:checked").length > 0) { if ($("form[data-id='add_alias'] .goto_checkbox:checked").length > 0) {

View File

@ -935,6 +935,33 @@ if (isset($_GET['query'])) {
break; break;
} }
break; break;
case "bcc-destination-options":
$domains = mailbox('get', 'domains');
$alias_domains = mailbox('get', 'alias_domains');
$data = array();
if (!empty($domains)) {
foreach ($domains as $domain) {
$data['domains'][] = $domain;
$mailboxes = mailbox('get', 'mailboxes', $domain);
foreach ($mailboxes as $mailbox) {
$data['mailboxes'][$mailbox][] = $mailbox;
$user_alias_details = user_get_alias_details($mailbox);
foreach ($user_alias_details['direct_aliases'] as $k => $v) {
$data['mailboxes'][$mailbox][] = $k;
}
foreach ($user_alias_details['shared_aliases'] as $k => $v) {
$data['mailboxes'][$mailbox][] = $k;
}
}
}
}
if (!empty($alias_domains)) {
foreach ($alias_domains as $alias_domain) {
$data['alias_domains'][] = $alias_domain;
}
}
process_get_return($data);
break;
case "syncjobs": case "syncjobs":
switch ($object) { switch ($object) {
case "all": case "all":

View File

@ -48,6 +48,7 @@
"app_password": "App-Passwort hinzufügen", "app_password": "App-Passwort hinzufügen",
"automap": "Ordner automatisch mappen (\"Sent items\", \"Sent\" => \"Sent\" etc.)", "automap": "Ordner automatisch mappen (\"Sent items\", \"Sent\" => \"Sent\" etc.)",
"backup_mx_options": "Relay-Optionen", "backup_mx_options": "Relay-Optionen",
"bcc_dest_format": "BCC-Ziel muss eine gültige E-Mail-Adresse sein.",
"comment_info": "Ein privater Kommentar ist für den Benutzer nicht einsehbar. Ein öffentlicher Kommentar wird als Tooltip im Interface des Benutzers angezeigt.", "comment_info": "Ein privater Kommentar ist für den Benutzer nicht einsehbar. Ein öffentlicher Kommentar wird als Tooltip im Interface des Benutzers angezeigt.",
"custom_params": "Eigene Parameter", "custom_params": "Eigene Parameter",
"custom_params_hint": "Richtig: --param=xy, falsch: --param xy", "custom_params_hint": "Richtig: --param=xy, falsch: --param xy",

View File

@ -48,7 +48,7 @@
"app_password": "Add app password", "app_password": "Add app password",
"automap": "Try to automap folders (\"Sent items\", \"Sent\" => \"Sent\" etc.)", "automap": "Try to automap folders (\"Sent items\", \"Sent\" => \"Sent\" etc.)",
"backup_mx_options": "Relay options", "backup_mx_options": "Relay options",
"bcc_dest_format": "BCC destination must be a single valid email address.<br> If you need to send a copy to multiple addresses, create an Alias and use it here.", "bcc_dest_format": "BCC destination must be a single valid email address.<br>If you need to send a copy to multiple addresses, create an alias and use it here.",
"comment_info": "A private comment is not visible to the user, while a public comment is shown as tooltip when hovering it in a user's overview", "comment_info": "A private comment is not visible to the user, while a public comment is shown as tooltip when hovering it in a user's overview",
"custom_params": "Custom parameters", "custom_params": "Custom parameters",
"custom_params_hint": "Right: --param=xy, wrong: --param xy", "custom_params_hint": "Right: --param=xy, wrong: --param xy",
@ -529,7 +529,7 @@
"app_passwd": "App password", "app_passwd": "App password",
"automap": "Try to automap folders (\"Sent items\", \"Sent\" => \"Sent\" etc.)", "automap": "Try to automap folders (\"Sent items\", \"Sent\" => \"Sent\" etc.)",
"backup_mx_options": "Relay options", "backup_mx_options": "Relay options",
"bcc_dest_format": "BCC destination must be a single valid email address.<br> If you need to send a copy to multiple addresses, create an Alias and use it here.", "bcc_dest_format": "BCC destination must be a single valid email address.<br>If you need to send a copy to multiple addresses, create an alias and use it here.",
"client_id": "Client ID", "client_id": "Client ID",
"client_secret": "Client secret", "client_secret": "Client secret",
"comment_info": "A private comment is not visible to the user, while a public comment is shown as tooltip when hovering it in a user's overview", "comment_info": "A private comment is not visible to the user, while a public comment is shown as tooltip when hovering it in a user's overview",

View File

@ -652,42 +652,8 @@ if (!isset($_SESSION['mailcow_cc_role'])) {
<div class="form-group"> <div class="form-group">
<label class="control-label col-sm-2" for="local_dest"><?=$lang['mailbox']['bcc_local_dest'];?></label> <label class="control-label col-sm-2" for="local_dest"><?=$lang['mailbox']['bcc_local_dest'];?></label>
<div class="col-sm-10"> <div class="col-sm-10">
<select data-live-search="true" data-size="20" name="local_dest" required> <select id="bcc-local-dest" data-live-search="true" data-size="20" name="local_dest" required>
<?php <option selected><?=$lang['footer']['loading'];?></option>
$domains = mailbox('get', 'domains');
$alias_domains = mailbox('get', 'alias_domains');
if (!empty($domains)) {
echo '<optgroup label="',$lang['mailbox']['domains'],'">';
foreach ($domains as $domain) {
echo "<option>".htmlspecialchars($domain)."</option>";
}
echo "</optgroup>";
}
if (!empty($alias_domains)) {
echo '<optgroup label="',$lang['mailbox']['domain_aliases'],'">';
foreach ($alias_domains as $alias_domain) {
echo "<option>".htmlspecialchars($alias_domain)."</option>";
}
echo "</optgroup>";
}
if (!empty($domains)) {
foreach ($domains as $domain) {
$mailboxes = mailbox('get', 'mailboxes', $domain);
foreach ($mailboxes as $mailbox) {
echo "<optgroup label=\"" . htmlspecialchars($mailbox) . "\">";
echo "<option> " . htmlspecialchars($mailbox) . "</option>";
$user_alias_details = user_get_alias_details($mailbox);
foreach ($user_alias_details['direct_aliases'] as $k => $v) {
echo "<option>" . htmlspecialchars($k) . "</option>";
}
foreach ($user_alias_details['shared_aliases'] as $k => $v) {
echo "<option>" . htmlspecialchars($k) . "</option>";
}
echo "</optgroup>";
}
}
}
?>
</select> </select>
</div> </div>
</div> </div>

View File

@ -11,6 +11,7 @@ if (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == 'doma
$tfa_data = get_tfa(); $tfa_data = get_tfa();
$fido2_data = fido2(array("action" => "get_friendly_names")); $fido2_data = fido2(array("action" => "get_friendly_names"));
$username = $_SESSION['mailcow_cc_username']; $username = $_SESSION['mailcow_cc_username'];
print_r(mailbox('get', 'mailbox_count'));
?> ?>
<div class="container"> <div class="container">