app/templates/dashboard/contact_detail.html

109 lines
3.5 KiB
HTML
Raw Normal View History

2020-06-07 06:07:46 +08:00
{% extends 'default.html' %}
{% set active_page = "dashboard" %}
{% block title %}
Contact {{ contact.email }} - Alias {{ alias.email }}
{% endblock %}
{% block default_content %}
<div class="row">
<div class="col">
2020-06-07 18:11:00 +08:00
<h1 class="h3">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a
href="{{ url_for('dashboard.alias_contact_manager', alias_id=alias.id) }}">{{ alias.email }}</a></li>
<li class="breadcrumb-item active" aria-current="page">{{ contact.email }}
{% if contact.pgp_finger_print %}
<span class="cursor" data-toggle="tooltip" data-original-title="PGP Enabled">🗝</span>
{% endif %}
</li>
</ol>
</nav>
2020-06-07 06:07:46 +08:00
</h1>
<div class="card">
<form method="post">
<input type="hidden" name="form-name" value="pgp">
<div class="card-body">
<div class="card-title">
Pretty Good Privacy (PGP)
<div class="small-text">
By importing your contact PGP Public Key into SimpleLogin, all emails sent to
<b>{{ contact.email }}</b> from your alias <b>{{ alias.email }}</b>
are <b>encrypted</b>.
</div>
</div>
{% if not current_user.is_premium() %}
<div class="alert alert-danger" role="alert">
This feature is only available in premium plan.
</div>
{% endif %}
<div class="form-group">
<label class="form-label">PGP Public Key</label>
<textarea name="pgp"
{% if not current_user.is_premium() %} disabled {% endif %}
class="form-control" rows=10 id="pgp-public-key"
2020-06-07 06:07:46 +08:00
placeholder="-----BEGIN PGP PUBLIC KEY BLOCK-----">{{ contact.pgp_public_key or "" }}</textarea>
<div class="text-body p-2">You can drag and drop the pgp key into the text area</div>
2020-06-07 06:07:46 +08:00
</div>
<button class="btn btn-primary" name="action"
{% if not current_user.is_premium() %} disabled {% endif %}
value="save">Save
</button>
{% if contact.pgp_finger_print %}
<button class="btn btn-danger float-right" name="action" value="remove">Remove</button>
{% endif %}
</div>
</form>
</div>
</div>
</div>
{% endblock %}
{% block script %}
{% if current_user.is_premium() %}
<script>
const MAX_BYTES = 2048; // 2KiB
function drop(event) {
event.stopPropagation();
event.preventDefault();
let files = event.dataTransfer.files;
for (let i = 0; i < files.length; i++) {
let file = files[i];
console.log(file, file.name);
if(file.type !== 'text/plain'){
toastr.warning(`File ${file.name} is not a public key file`);
continue;
}
let reader = new FileReader();
reader.onloadend = onFileLoaded;
reader.readAsBinaryString(file);
}
}
2020-06-07 06:07:46 +08:00
function onFileLoaded(event) {
const initialData = event.currentTarget.result.substr(0, MAX_BYTES);
$('#pgp-public-key').val(initialData);
console.log($('#pgp-public-key'));
}
const dropArea = $("#pgp-public-key").get(0);
dropArea.addEventListener("drop", drop, false);
</script>
{% endif %}
{% endblock %}