1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2026-03-26 19:27:23 +01:00
This commit is contained in:
guyzmo
2017-05-30 16:32:02 +00:00
committed by GitHub
7 changed files with 256 additions and 33 deletions

View File

@@ -26,7 +26,7 @@
</div>
</div>
<div class="form-group">
<label for="addaliasAddress" class="col-sm-1 control-label">Alias</label>
<label for="addaliasAddress" class="col-sm-2 control-label">Alias</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="addaliasAddress">
<div style="margin-top: 3px; padding-left: 3px; font-size: 90%" class="text-muted">
@@ -36,7 +36,7 @@
</div>
</div>
<div class="form-group">
<label for="addaliasForwardsTo" class="col-sm-1 control-label">Forwards To</label>
<label for="addaliasForwardsTo" class="col-sm-2 control-label">Forwards To</label>
<div class="col-sm-10">
<textarea class="form-control" rows="3" id="addaliasForwardsTo"></textarea>
<div style="margin-top: 3px; padding-left: 3px; font-size: 90%" class="text-muted">
@@ -45,7 +45,7 @@
</div>
</div>
<div class="form-group">
<label for="addaliasSenders" class="col-sm-1 control-label">Permitted Senders</label>
<label for="addaliasSenders" class="col-sm-2 control-label">Permitted Senders</label>
<div class="col-sm-10">
<div class="radio">
<label>
@@ -64,6 +64,20 @@
</div>
</div>
</div>
<div class="form-group">
<label for="addaliasDnsHandling" class="col-sm-2 control-label">Services</label>
<div class="col-sm-10">
<div id="alias_service_buttons" class="btn-group btn-group-xs">
<button id="addaliasMailHandling" data-mode="mail" class="btn btn-xs btn-success active" disabled>MAIL</button>
<button id="addaliasDnsHandling" data-mode="dns" class="btn btn-xs btn-success active">DNS</button>
<button id="addaliasWebHandling" data-mode="www" class="btn btn-xs btn-success active">WWW</button>
</div>
<div id="alias_service_info" class="text-info small" style="display: none; margin: .5em 0 0 0;">
<span class="dns hidden">When deactivated, the DNS service is not configured for the domain</span>
<span class="www hidden">When deactivated, the Web services is not configured for the domain</span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-1 col-sm-11">
<button id="add-alias-button" type="submit" class="btn btn-primary">Add Alias</button>
@@ -200,7 +214,33 @@ function show_aliases() {
}
})
$('#alias_type_buttons button[data-mode="regular"]').click(); // init
})
// Service buttons
$('#alias_service_buttons button').off('click').click(function() {
if ($(this).hasClass('active')) {
$(this).removeClass('active');
$(this).addClass('btn-default');
$(this).removeClass('btn-success');
$('#alias_service_info .www').addClass('hidden');
$('#alias_service_info .dns').addClass('hidden');
if ($(this).attr('data-mode') == "dns") {
$('#alias_service_info').slideDown();
$('#addalias-form .dns').removeClass('hidden');
} else if ($(this).attr('data-mode') == "www") {
$('#alias_service_info').slideDown();
$('#addalias-form .www').removeClass('hidden');
}
} else {
$(this).addClass('active');
$(this).removeClass('btn-default');
$(this).addClass('btn-success');
$('#alias_service_info').slideUp();
$('#addalias-form .www').addClass('hidden');
$('#addalias-form .dns').addClass('hidden');
}
return false;
});
});
}
var is_alias_add_update = false;
@@ -209,6 +249,8 @@ function do_add_alias() {
var form_address = $("#addaliasAddress").val();
var form_forwardsto = $("#addaliasForwardsTo").val();
var form_senders = ($('#addaliasForwardsToAdvanced').prop('checked') ? $("#addaliasSenders").val() : '');
var form_dns = $('#addaliasDnsHandling').hasClass('active');
var form_web = $('#addaliasWebHandling').hasClass('active');
if ($('#addaliasForwardsToAdvanced').prop('checked') && !/\S/.exec($("#addaliasSenders").val())) {
show_modal_error(title, "You did not enter any permitted senders.");
return false;
@@ -220,7 +262,9 @@ function do_add_alias() {
update_if_exists: is_alias_add_update ? '1' : '0',
address: form_address,
forwards_to: form_forwardsto,
permitted_senders: form_senders
permitted_senders: form_senders,
dns_enabled: form_dns,
web_enabled: form_web
},
function(r) {
// Responses are multiple lines of pre-formatted text.
@@ -242,8 +286,14 @@ function aliases_reset_form() {
$('#alias-cancel').addClass('hidden');
$('#add-alias-button').text('Add Alias');
is_alias_add_update = false;
$('#addaliasDnsHandling').prop('disabled', false).addClass('btn-success');
$('#addaliasWebHandling').prop('disabled', false).addClass('btn-success');
}
function aliases_edit(elem) {
var address = $(elem).parents('tr').attr('data-address');
var receiverdivs = $(elem).parents('tr').find('.forwardsTo div');
@@ -267,6 +317,8 @@ function aliases_edit(elem) {
$('#addaliasForwardsToAdvanced').prop('checked', senders != "");
$('#addaliasForwardsToNotAdvanced').prop('checked', senders == "");
$("#addaliasSenders").val(senders);
$('#addaliasDnsHandling').prop('disabled', true);
$('#addaliasWebHandling').prop('disabled', true);
$('#add-alias-button').text('Update');
$('body').animate({ scrollTop: 0 })
is_alias_add_update = true;

View File

@@ -23,6 +23,13 @@
<input type="text" class="form-control" id="customdnsQname" placeholder="subdomain">
</td><td style="padding: 0 1em; font-weight: bold;">.</td><td>
<select id="customdnsZone" class="form-control"> </select>
<div class="input-group" id="customdnsZoneFree">
<input type="text" class="form-control" placeholder="new-domain.tld" class="hidden">
<span class="input-group-btn">
<button class="btn btn-default" type="button" onclick="reset_zone_free(); return false;">X</button>
</span>
</div>
</td></tr></table>
<div class="text-info" style="margin-top: .5em">Leave the left field blank to set a record on the chosen domain name, or enter a subdomain.</div>
</div>
@@ -166,19 +173,69 @@ function show_custom_dns() {
$('#secondarydns-clear-instructions').toggle(data.hostnames.length > 0);
});
$('#customdnsZone').text('');
var dns_list_domains = $('<optgroup/>').attr('label', 'Domains');
var dns_list_customs = $('<optgroup/>').attr('label', 'Custom');
var dns_list_advanced = $('<optgroup/>').attr('label', 'Advanced');
$('#customdnsZone').append(dns_list_domains);
$('#customdnsZone').append(dns_list_customs);
$('#customdnsZone').append(dns_list_advanced);
dns_list_advanced.append($('<option/>').text("New domain..."));
// Append all domains offered by mail
api(
"/dns/zones",
"GET",
{ },
function(data) {
$('#customdnsZone').text('');
for (var i = 0; i < data.length; i++) {
$('#customdnsZone').append($('<option/>').text(data[i]));
function(zones) {
for (var i = 0; i < zones.length; i++) {
dns_list_domains.append($('<option/>').text(zones[i]));
}
// Append all custom domains that are not offering mail
api(
"/dns/custom",
"GET",
{ },
function(customs) {
seen = [];
for (var i = 0; i < customs.length; i++) {
fqdn = customs[i].qname.replace(/.*\.(?=[^.]*\.[^.]*$)/, "");
console.log(fqdn, seen);
if ($.inArray(fqdn, seen) == -1) {
seen.push(fqdn);
dns_list_customs.append($('<option/>').text(fqdn));
}
}
$('#customdnsZone')[0].selectedIndex = 0;
});
});
show_current_custom_dns();
show_customdns_rtype_hint();
$(function() {
$('#customdnsZone').on('change', function(){
var selected = $(this).find("option:selected").val();
if (selected === "New domain...") {
$('#customdnsZoneFree').removeClass('hidden');
$('#customdnsZone').addClass('hidden');
return true;
}
});
return false;
});
reset_zone_free();
}
function reset_zone_free() {
$('#customdnsZoneFree').addClass('hidden');
$('#customdnsZone').removeClass('hidden');
$('#customdnsZone')[0].selectedIndex = 0;
}
function show_current_custom_dns() {
@@ -238,6 +295,14 @@ function do_set_custom_dns(qname, rtype, value, method) {
qname = $('#customdnsQname').val() + '.' + $('#customdnsZone').val();
else
qname = $('#customdnsZone').val();
if ($('#customdnsZone').val() === 'New domain...') {
if ($('#customdnsQname').val() != '')
qname = $('#customdnsQname').val() + '.' + $('#customdnsZoneFree input').val();
else
qname = $('#customdnsZoneFree input').val();
}
rtype = $('#customdnsType').val();
value = $('#customdnsValue').val();
method = 'POST';

View File

@@ -28,8 +28,21 @@
<option value="admin">Administrator</option>
</select>
</div>
<div class="form-group">
<div class="col-sm-15">
<div id="user_service_buttons" class="btn-group btn-group">
<button id="adduserMailHandling" data-mode="mail" class="btn btn-success active" disabled>MAIL</button>
<button id="adduserDnsHandling" data-mode="dns" class="btn btn-success active">DNS</button>
<button id="adduserWebHandling" data-mode="www" class="btn btn-success active">WWW</button>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary">Add User</button>
</form>
<div id="user_service_info" class="text-info small" style="display: none; margin: .5em 0 0 0;">
<span class="dns hidden">When deactivated, the DNS service is not configured for the domain</span>
<span class="www hidden">When deactivated, the Web services is not configured for the domain</span>
</div>
<ul style="margin-top: 1em; padding-left: 1.5em; font-size: 90%;">
<li>Passwords must be at least eight characters and may not contain spaces. For best results, <a href="#" onclick="return generate_random_password()">generate a random password</a>.</li>
<li>Use <a href="#" onclick="return show_panel('aliases')">aliases</a> to create email addresses that forward to existing accounts.</li>
@@ -179,19 +192,50 @@ function show_users() {
}
}
})
// Service buttons
$('#user_service_buttons button').off('click').click(function() {
if ($(this).hasClass('active')) {
$(this).removeClass('active');
$(this).addClass('btn-default');
$(this).removeClass('btn-success');
$('#user_service_info .www').addClass('hidden');
$('#user_service_info .dns').addClass('hidden');
if ($(this).attr('data-mode') == "dns") {
$('#user_service_info').slideDown();
$('#user_service_info .dns').removeClass('hidden');
} else if ($(this).attr('data-mode') == "www") {
$('#user_service_info').slideDown();
$('#user_service_info .www').removeClass('hidden');
}
} else {
$(this).addClass('active');
$(this).removeClass('btn-default');
$(this).addClass('btn-success');
$('#user_service_info').slideUp();
$('#user_service_info .www').addClass('hidden');
$('#user_service_info .dns').addClass('hidden');
}
return false;
});
}
function do_add_user() {
var email = $("#adduserEmail").val();
var pw = $("#adduserPassword").val();
var privs = $("#adduserPrivs").val();
var form_dns = $('#adduserDnsHandling').hasClass('active');
var form_web = $('#adduserWebHandling').hasClass('active');
api(
"/mail/users/add",
"POST",
{
email: email,
password: pw,
privileges: privs
privileges: privs,
dns_enabled: form_dns,
web_enabled: form_web
},
function(r) {
// Responses are multiple lines of pre-formatted text.