2022-06-29 11:28:26 +02:00
|
|
|
|
{% extends "default.html" %}
|
2020-01-08 21:38:01 +01:00
|
|
|
|
|
2022-06-29 11:28:26 +02:00
|
|
|
|
{% set active_page = "directory" %}
|
|
|
|
|
{% block title %}Directory{% endblock %}
|
2020-01-08 21:38:01 +01:00
|
|
|
|
{% block default_content %}
|
2022-06-29 11:28:26 +02:00
|
|
|
|
|
2020-01-08 21:38:01 +01:00
|
|
|
|
<div class="row">
|
2020-04-05 19:59:48 +02:00
|
|
|
|
<div class="col">
|
2022-06-29 11:28:26 +02:00
|
|
|
|
<h1 class="h3">
|
|
|
|
|
Directories
|
|
|
|
|
<a class="ml-3 text-info"
|
|
|
|
|
style="font-size: 12px"
|
|
|
|
|
data-toggle="collapse"
|
|
|
|
|
href="#howtouse"
|
|
|
|
|
role="button"
|
|
|
|
|
aria-expanded="false"
|
|
|
|
|
aria-controls="collapseExample">
|
2020-05-03 10:47:29 +02:00
|
|
|
|
How to use <i class="fe fe-chevrons-down"></i>
|
|
|
|
|
</a>
|
|
|
|
|
</h1>
|
2020-01-16 22:21:19 +01:00
|
|
|
|
{% if not current_user.is_premium() %}
|
|
|
|
|
|
2022-06-29 11:28:26 +02:00
|
|
|
|
<div class="alert alert-danger" role="alert">This feature is only available in premium plan.</div>
|
|
|
|
|
{% endif %}
|
2024-08-28 13:07:34 +02:00
|
|
|
|
<div class="alert alert-primary collapse {% if not dirs %}show{% endif %}" id="howtouse" role="alert">
|
2020-04-15 22:52:30 +02:00
|
|
|
|
<div>
|
|
|
|
|
Directory allows you to create aliases <b>on the fly</b>.
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mt-2 pb-2">
|
2022-06-29 11:28:26 +02:00
|
|
|
|
1️⃣ Pick a name for your directory, says <em>my_directory</em>
|
|
|
|
|
<br />
|
2020-05-03 10:47:29 +02:00
|
|
|
|
2️⃣ Quickly use one of the following formats to create an alias on-the-fly <b>without creating this alias
|
2022-06-29 11:28:26 +02:00
|
|
|
|
beforehand</b>
|
2020-01-08 21:38:01 +01:00
|
|
|
|
</div>
|
2022-06-29 11:28:26 +02:00
|
|
|
|
<div class="pl-3 py-2 bg-secondary">
|
|
|
|
|
<em>my_directory/<b>anything</b>@{{ FIRST_ALIAS_DOMAIN }}</em> or
|
|
|
|
|
<br />
|
|
|
|
|
<em>my_directory+<b>anything</b>@{{ FIRST_ALIAS_DOMAIN }}</em> or
|
|
|
|
|
<br />
|
|
|
|
|
<em>my_directory#<b>anything</b>@{{ FIRST_ALIAS_DOMAIN }}</em>
|
|
|
|
|
<br />
|
|
|
|
|
</div>
|
|
|
|
|
<em><b>anything</b></em> is any string composed of lowercase characters.
|
|
|
|
|
<br />
|
|
|
|
|
You can find more info on directory on our
|
|
|
|
|
<a href="https://simplelogin.io/blog/alias-directory/">blog post</a>
|
|
|
|
|
.
|
|
|
|
|
<div class="mt-2">
|
|
|
|
|
You can use this feature on the following domains:
|
|
|
|
|
{% for alias_domain in ALIAS_DOMAINS %}<div class="font-weight-bold">{{ alias_domain }}</div>{% endfor %}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="h4 text-primary mt-3">
|
|
|
|
|
ℹ️
|
|
|
|
|
The alias will be created the first time it receives an email.
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="row">
|
|
|
|
|
{% for dir in dirs %}
|
2020-01-08 21:38:01 +01:00
|
|
|
|
|
2022-06-29 11:28:26 +02:00
|
|
|
|
<div class="col-12 col-lg-6">
|
|
|
|
|
<div class="card" style="">
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<h5 class="card-title">
|
|
|
|
|
<div class="d-flex">
|
|
|
|
|
{{ dir.name }}
|
|
|
|
|
<form method="post">
|
2022-10-27 10:04:47 +02:00
|
|
|
|
{{ toggle_dir_form.csrf_token }}
|
2022-06-29 11:28:26 +02:00
|
|
|
|
<input type="hidden" name="form-name" value="toggle-directory">
|
2024-08-28 13:07:34 +02:00
|
|
|
|
{{ toggle_dir_form.directory_id(type="hidden", value=dir.id) }}
|
2022-06-29 11:28:26 +02:00
|
|
|
|
<label class="custom-switch cursor" style="padding-left: 1rem" data-toggle="tooltip" {% if dir.disabled %}
|
|
|
|
|
title="Enable directory on-the-fly alias creation" {% else %} title="Disable directory on-the-fly alias creation" {% endif %}>
|
2024-08-28 13:07:34 +02:00
|
|
|
|
{{ toggle_dir_form.directory_enabled(class="custom-switch-input", checked=(not dir.disabled) ) }}
|
2022-06-29 11:28:26 +02:00
|
|
|
|
<span class="custom-switch-indicator"></span>
|
|
|
|
|
</label>
|
2020-06-05 22:13:35 +02:00
|
|
|
|
</form>
|
2020-05-03 10:48:21 +02:00
|
|
|
|
</div>
|
2022-06-29 11:28:26 +02:00
|
|
|
|
</h5>
|
|
|
|
|
<h6 class="card-subtitle mb-2 text-muted">
|
|
|
|
|
{% if dir.disabled %}
|
|
|
|
|
|
|
|
|
|
<div class="mb-3">⚠️ On-the-fly alias creation is disabled, you can't create new aliases with this directory.</div>
|
|
|
|
|
{% endif %}
|
|
|
|
|
Created {{ dir.created_at | dt }}
|
|
|
|
|
<br />
|
|
|
|
|
<span class="font-weight-bold">{{ dir.nb_alias() }}</span> aliases.
|
|
|
|
|
<br />
|
|
|
|
|
<br />
|
|
|
|
|
<b>Mailboxes:</b> <i class="fe fe-info"
|
|
|
|
|
data-toggle="tooltip"
|
|
|
|
|
title="Aliases created with this directory are automatically owned by these mailboxes"></i>
|
|
|
|
|
<br />
|
2024-08-28 13:07:34 +02:00
|
|
|
|
{% set dir_mailboxes = dir.mailboxes %}
|
2022-06-29 11:28:26 +02:00
|
|
|
|
<form method="post" class="mt-2">
|
2022-10-27 10:04:47 +02:00
|
|
|
|
{{ update_dir_form.csrf_token }}
|
2022-06-29 11:28:26 +02:00
|
|
|
|
<input type="hidden" name="form-name" value="update">
|
2024-08-28 13:07:34 +02:00
|
|
|
|
{{ update_dir_form.directory_id(type="hidden", value=dir.id) }}
|
2022-06-29 11:28:26 +02:00
|
|
|
|
<select data-width="100%"
|
|
|
|
|
required
|
|
|
|
|
class="mailbox-select"
|
|
|
|
|
multiple
|
|
|
|
|
name="mailbox_ids">
|
|
|
|
|
{% for mailbox in mailboxes %}
|
|
|
|
|
|
2024-08-28 13:07:34 +02:00
|
|
|
|
<option value="{{ mailbox.id }}" {% if mailbox in dir_mailboxes %}selected{% endif %}>{{ mailbox.email }}</option>
|
2022-06-29 11:28:26 +02:00
|
|
|
|
{% endfor %}
|
|
|
|
|
</select>
|
|
|
|
|
<button class="mt-2 btn btn-outline-primary btn-sm">Update</button>
|
|
|
|
|
</form>
|
|
|
|
|
</h6>
|
2020-05-03 10:48:21 +02:00
|
|
|
|
</div>
|
2022-06-29 11:28:26 +02:00
|
|
|
|
<div class="card-footer p-0">
|
|
|
|
|
<div class="row">
|
|
|
|
|
<div class="col">
|
|
|
|
|
<form method="post">
|
2022-10-27 10:04:47 +02:00
|
|
|
|
{{ delete_dir_form.csrf_token }}
|
2022-06-29 11:28:26 +02:00
|
|
|
|
<input type="hidden" name="form-name" value="delete">
|
2024-08-28 13:07:34 +02:00
|
|
|
|
{{ delete_dir_form.directory_id(type="hidden", value=dir.id) }}
|
2022-06-29 11:28:26 +02:00
|
|
|
|
<span class="card-link btn btn-link float-right text-danger delete-dir">Delete</span>
|
|
|
|
|
</form>
|
2020-06-05 23:25:37 +02:00
|
|
|
|
</div>
|
2022-06-29 11:28:26 +02:00
|
|
|
|
</div>
|
2020-06-05 23:25:37 +02:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2022-06-29 11:28:26 +02:00
|
|
|
|
{% endfor %}
|
|
|
|
|
</div>
|
2024-08-28 13:07:34 +02:00
|
|
|
|
<div class="row {% if current_user.directory_quota <= 0 %}disabled-content{% endif %}">
|
2022-06-29 11:28:26 +02:00
|
|
|
|
<div class="col">
|
|
|
|
|
<div class="card">
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<form method="post" class="mt-2">
|
|
|
|
|
{{ new_dir_form.csrf_token }}
|
|
|
|
|
<input type="hidden" name="form-name" value="create">
|
|
|
|
|
<h2 class="h4 mb-1">New Directory</h2>
|
|
|
|
|
<div class="small-text mb-4">You can create up to {{ current_user.directory_quota }} directories.</div>
|
|
|
|
|
{{ new_dir_form.name(class="form-control", placeholder="my-directory",
|
2024-08-28 13:07:34 +02:00
|
|
|
|
pattern="[0-9a-z-_]{3,}",
|
|
|
|
|
title="Only letter, number, dash (-), underscore (_) can be used. Directory name must be at least 3 characters.") }}
|
2022-06-29 11:28:26 +02:00
|
|
|
|
{{ render_field_errors(new_dir_form.name) }}
|
|
|
|
|
<div class="small-text">
|
|
|
|
|
Directory name must be at least 3 characters.
|
|
|
|
|
Only lowercase letters, numbers, dashes (-) and underscores (_) are currently supported.
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mt-3 small-text alert alert-info">
|
|
|
|
|
By default, aliases created with directory are "owned" by your default
|
|
|
|
|
mailbox <b>{{ current_user.default_mailbox.email }}</b>.
|
|
|
|
|
<br />
|
|
|
|
|
You can however choose the mailbox(es) that new alias automatically belongs to by setting this below
|
|
|
|
|
option.
|
|
|
|
|
</div>
|
|
|
|
|
<select data-width="100%" class="mailbox-select" multiple name="mailbox_ids">
|
|
|
|
|
{% for mailbox in mailboxes %}
|
|
|
|
|
|
2024-08-28 13:07:34 +02:00
|
|
|
|
<option value="{{ mailbox.id }}" {% if mailbox.id == current_user.default_mailbox_id %}selected{% endif %}>{{ mailbox.email }}</option>
|
2022-06-29 11:28:26 +02:00
|
|
|
|
{% endfor %}
|
|
|
|
|
</select>
|
|
|
|
|
<button id="btn-create-directory" class="btn btn-primary mt-2">Create</button>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2020-06-05 23:25:37 +02:00
|
|
|
|
</div>
|
2020-01-08 21:38:01 +01:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2022-06-29 11:28:26 +02:00
|
|
|
|
</div>
|
2020-01-08 21:38:01 +01:00
|
|
|
|
{% endblock %}
|
|
|
|
|
{% block script %}
|
2022-06-29 11:28:26 +02:00
|
|
|
|
|
2020-01-08 21:38:01 +01:00
|
|
|
|
<script>
|
|
|
|
|
$(".delete-dir").on("click", function (e) {
|
2022-10-27 10:04:47 +02:00
|
|
|
|
let directory_name = $(this).parent().find("#directory_name").val();
|
2020-04-30 22:37:39 +02:00
|
|
|
|
|
2022-10-27 10:04:47 +02:00
|
|
|
|
const element = document.createElement('div');
|
|
|
|
|
element.innerText = directory_name;
|
|
|
|
|
const sanitized_name = element.innerHTML;
|
|
|
|
|
|
|
|
|
|
const message = `All aliases associated with <b>${sanitized_name}</b> directory will also be deleted. ` +
|
2021-11-20 20:01:36 +01:00
|
|
|
|
`As a deleted directory can't be used by someone else, deleting a directory doesn't reset your directory quota. ` +
|
|
|
|
|
`Your directory quota will be {{ current_user.directory_quota }} after the deletion, ` +
|
2020-05-03 10:48:21 +02:00
|
|
|
|
" please confirm.";
|
2022-10-27 10:04:47 +02:00
|
|
|
|
|
2020-04-30 22:37:39 +02:00
|
|
|
|
|
|
|
|
|
bootbox.confirm({
|
2022-10-27 10:04:47 +02:00
|
|
|
|
message: message,
|
2020-04-30 22:37:39 +02:00
|
|
|
|
buttons: {
|
|
|
|
|
confirm: {
|
|
|
|
|
label: 'Yes, delete it',
|
|
|
|
|
className: 'btn-danger'
|
|
|
|
|
},
|
|
|
|
|
cancel: {
|
|
|
|
|
label: 'Cancel',
|
|
|
|
|
className: 'btn-outline-primary'
|
|
|
|
|
}
|
2020-01-08 21:38:01 +01:00
|
|
|
|
},
|
2022-05-13 16:55:45 +02:00
|
|
|
|
callback: (result) => {
|
2020-04-30 22:37:39 +02:00
|
|
|
|
if (result) {
|
2022-05-13 16:55:45 +02:00
|
|
|
|
this.closest("form").submit();
|
2020-04-30 22:37:39 +02:00
|
|
|
|
}
|
2020-01-08 21:38:01 +01:00
|
|
|
|
}
|
2020-04-30 22:37:39 +02:00
|
|
|
|
})
|
|
|
|
|
|
2020-01-08 21:38:01 +01:00
|
|
|
|
});
|
2020-06-05 22:10:52 +02:00
|
|
|
|
|
|
|
|
|
$('.mailbox-select').multipleSelect();
|
|
|
|
|
|
2020-12-07 10:49:40 +01:00
|
|
|
|
$(".custom-switch-input").change(function (e) {
|
|
|
|
|
$(this).closest("form").submit();
|
|
|
|
|
});
|
|
|
|
|
|
2020-01-08 21:38:01 +01:00
|
|
|
|
</script>
|
2020-05-27 22:52:45 +02:00
|
|
|
|
{% endblock %}
|