1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-04 16:31:13 +00:00

improved ui of repo_decrypt page

This commit is contained in:
llj
2013-11-09 15:55:48 +08:00
parent 7aad52a9ad
commit aafd3410f5
2 changed files with 17 additions and 4 deletions

View File

@@ -4,7 +4,7 @@
{% block main_panel %} {% block main_panel %}
<div class="wide-panel"> <div class="wide-panel">
<p class="access-notice">{% trans "This library is encrypted. Please input the password if you want to browse it online. And the password will be kept on the server for only 1 hour." %}</p> <p class="access-notice">{% trans "This library is encrypted. Please input the password if you want to browse it online. And the password will be kept on the server for only 1 hour." %}</p>
<form action="{{ SITE_ROOT }}repo/{{ repo.id }}/?next={{ next }}" method="post" id="repo-decrypt-form">{% csrf_token %} <form action="{% url 'repo' repo.id %}?next={{ next }}" method="post" id="repo-decrypt-form">{% csrf_token %}
<label>{% trans "Password: " %}</label> <label>{% trans "Password: " %}</label>
<input type="hidden" name="repo_id" value="{{ repo.id }}" /> <input type="hidden" name="repo_id" value="{{ repo.id }}" />
<input type="hidden" name="username" value="{{ request.user.username }}" /> <input type="hidden" name="username" value="{{ request.user.username }}" />
@@ -14,7 +14,8 @@
{% for error in form.errors.values %} {% for error in form.errors.values %}
{{ error|escape }} {{ error|escape }}
{% endfor %} {% endfor %}
<p><a href="{% url 'edit_profile' %}#enc-lib-setting">{% trans "Change how to view encrypted libraries online" %}</a></p> {% url 'edit_profile' as profile_edit_url %}
<p class="tip" style="margin-top:3em;">{% blocktrans %}You can change how to view encrypted libraries online <a class="normal" href="{{ profile_edit_url }}#enc-lib-setting">here</a>.{% endblocktrans %}</p>
</form> </form>
</div> </div>
{% endblock %} {% endblock %}

View File

@@ -205,6 +205,18 @@
{% include "snippets/group_recommend_form.html" %} {% include "snippets/group_recommend_form.html" %}
{% endwith %} {% endwith %}
{% if repo.enc_version == 2 and not server_crypto and repo.encrypted %}
<form id="repo-decrypt-form" class="wide-panel hide">
<p>{% trans "This library is encrypted. Please input the password if you want to browse it online. And the password will be kept in the browser for only 1 hour." %}</p>
<label>{% trans "Password: " %}</label>
<input type="password" name="password" autofocus />
<input type="submit" value="{% trans "Submit" %}" />
<p class="error hide"></p>
{% url 'edit_profile' as profile_edit_url %}
<p class="tip" style="margin-top:3em;">{% blocktrans %}You can change how to view encrypted libraries online <a class="normal" href="{{ profile_edit_url }}#enc-lib-setting">here</a>.{% endblocktrans %}</p>
</form>
{% endif %}
{% endblock %} {% endblock %}
{% block extra_script %} {% block extra_script %}
@@ -272,8 +284,8 @@ if ('localStorage' in window && window['localStorage'] !== null) {
decrypt_repo(); decrypt_repo();
} }
function decrypt_repo() { function decrypt_repo() {
var decrypt_form = $('<form id="repo-decrypt" class="wide-panel"> <p>{% trans "This library is encrypted. Please input the password if you want to browse it online. And the password will be kept in the browser for only 1 hour." %}</p> <label>{% trans "Password: " %}</label> <input type="password" name="password" autofocus /> <input type="submit" value="{% trans "Submit" %}" /> <p class="error hide"></p> <p><a href="{% url 'edit_profile' %}#enc-lib-setting">{% trans "Change how to view encrypted libraries online" %}</a></p></form>'); var decrypt_form = $('#repo-decrypt-form');
$('#header').after(decrypt_form); $('#header').after(decrypt_form.removeClass('hide'));
$('[type="submit"]', decrypt_form).click(function() { $('[type="submit"]', decrypt_form).click(function() {
var passwd = $('[name="password"]', decrypt_form).val(), var passwd = $('[name="password"]', decrypt_form).val(),
err = $('.error', decrypt_form); err = $('.error', decrypt_form);