mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-07 01:53:59 +00:00
[web setting] bugfix & improvement
This commit is contained in:
parent
9ee88fe35c
commit
e3df7b561e
@ -1939,9 +1939,11 @@ textarea:-moz-placeholder {/* for FF */
|
|||||||
#rename-form .input {
|
#rename-form .input {
|
||||||
font-size:14px;
|
font-size:14px;
|
||||||
}
|
}
|
||||||
|
.web-setting-form .submit,
|
||||||
#rename-form .submit {
|
#rename-form .submit {
|
||||||
color:green;
|
color:green;
|
||||||
}
|
}
|
||||||
|
.web-setting-form .cancel,
|
||||||
#rename-form .cancel {
|
#rename-form .cancel {
|
||||||
color:#666;
|
color:#666;
|
||||||
}
|
}
|
||||||
@ -1949,6 +1951,8 @@ textarea:-moz-placeholder {/* for FF */
|
|||||||
#rename-form .submit {
|
#rename-form .submit {
|
||||||
margin:0;
|
margin:0;
|
||||||
}
|
}
|
||||||
|
.web-setting-form .submit,
|
||||||
|
.web-setting-form .cancel,
|
||||||
#rename-form .submit,
|
#rename-form .submit,
|
||||||
#rename-form .cancel {
|
#rename-form .cancel {
|
||||||
font-size:16px;
|
font-size:16px;
|
||||||
@ -3640,68 +3644,43 @@ img.thumbnail {
|
|||||||
max-height: 24px;
|
max-height: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* seahub web setting */
|
/* seahub web settings */
|
||||||
.seahub-web-settings {
|
|
||||||
margin-top:15px;
|
|
||||||
}
|
|
||||||
.seahub-web-settings h4 {
|
.seahub-web-settings h4 {
|
||||||
|
padding:3px 10px;
|
||||||
background:#f7f7f7;
|
background:#f7f7f7;
|
||||||
|
border-radius:2px;
|
||||||
margin:15px 0;
|
margin:15px 0;
|
||||||
padding:4px 0 4px 14px;
|
|
||||||
}
|
}
|
||||||
.web-setting-name {
|
.web-setting-form {
|
||||||
width:190px;
|
|
||||||
margin-left:14px;
|
|
||||||
}
|
|
||||||
.web-setting-name label {
|
|
||||||
width:175px;
|
|
||||||
margin:3px 0;
|
|
||||||
}
|
|
||||||
.web-setting-description {
|
|
||||||
width:480px;
|
|
||||||
margin-bottom:20px;
|
margin-bottom:20px;
|
||||||
}
|
}
|
||||||
.web-setting-name,
|
.web-setting-name,
|
||||||
.web-setting-description {
|
.web-setting-input,
|
||||||
|
.web-setting-ops {
|
||||||
display:inline-block;
|
display:inline-block;
|
||||||
|
}
|
||||||
|
.web-setting-name {
|
||||||
|
width:180px;
|
||||||
|
padding:0 10px;
|
||||||
|
vertical-align:top;
|
||||||
|
font-weight:normal;
|
||||||
|
line-height:28px;
|
||||||
|
}
|
||||||
|
.web-setting-input {
|
||||||
|
width:400px;
|
||||||
|
}
|
||||||
|
.web-setting-name,
|
||||||
|
.web-setting-input .input {
|
||||||
|
margin:0;
|
||||||
|
}
|
||||||
|
.web-setting-ops {
|
||||||
|
width:100px;
|
||||||
vertical-align:top;
|
vertical-align:top;
|
||||||
}
|
}
|
||||||
.web-setting-description .web-setting-help-tip {
|
.web-setting-form .submit,
|
||||||
font-size:12px;
|
.web-setting-input {
|
||||||
|
margin-top:0;
|
||||||
}
|
}
|
||||||
.web-input-setting-form .web-setting-help-tip {
|
.web-setting-form .submit {
|
||||||
width:380px;
|
margin-right:5px;
|
||||||
color:#888;
|
|
||||||
line-height:1.4;
|
|
||||||
margin:2px 0 0 0;
|
|
||||||
}
|
|
||||||
.web-input-setting-form .error {
|
|
||||||
margin:2px 0 0 0;
|
|
||||||
}
|
|
||||||
.web-input-setting-form .input ,
|
|
||||||
.web-input-setting-form .submit {
|
|
||||||
margin:3px 0 0 0;
|
|
||||||
}
|
|
||||||
.web-input-setting-form .input {
|
|
||||||
width:370px;
|
|
||||||
padding:0 0 0 5px;
|
|
||||||
height:23px;
|
|
||||||
}
|
|
||||||
.web-input-setting-form .submit {
|
|
||||||
padding:2px 8px;
|
|
||||||
margin-left:20px;
|
|
||||||
}
|
|
||||||
.web-input-setting-form .cancel-setting {
|
|
||||||
opacity:0.6;
|
|
||||||
padding:3px 6px 5px;
|
|
||||||
}
|
|
||||||
.web-input-setting-form .cancel-setting:hover {
|
|
||||||
opacity:1;
|
|
||||||
}
|
|
||||||
.web-checkbox-setting-form {
|
|
||||||
width:370px;
|
|
||||||
}
|
|
||||||
.web-checkbox-setting-form .web-setting-help-tip {
|
|
||||||
top:-7px;
|
|
||||||
left:1px;
|
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% if type == 'input' %}
|
{% if type == 'input' %}
|
||||||
<div class="web-setting-name">
|
<form class="web-setting-form web-input-setting-form">
|
||||||
<label>{{ setting_display_name }}</label>
|
<h5 class="web-setting-name">{{ setting_display_name }}</h5>
|
||||||
</div>
|
<div class="web-setting-input">
|
||||||
<div class="web-setting-description">
|
<input class="input" type="text" name="{{ setting_name }}" value="{{ setting_val }}" data-cur="{{ setting_val }}" />
|
||||||
<form class="web-input-setting-form">{% csrf_token %}
|
|
||||||
<input class="input" type="text" name="{{ setting_name }}" value="{{ setting_val }}" />
|
|
||||||
<input class="submit hide" type="submit" value="{% trans "Save" %}" />
|
|
||||||
<i class="icon-remove fa-1x cancel-setting cspt hide" title="{% trans "Cancel" %}"></i><br />
|
|
||||||
<p class="error hide"></p>
|
<p class="error hide"></p>
|
||||||
<p class="web-setting-help-tip">{{ help_tip }}</p>
|
<p class="tip">{{ help_tip }}</p>
|
||||||
</form>
|
</div>
|
||||||
</div>
|
<div class="web-setting-ops">
|
||||||
|
<button type="submit" class="submit sf2-icon-tick vam hide" title="{% trans "Submit" %}"></button>
|
||||||
|
<button type="button" class="cancel sf2-icon-x2 vam hide" title="{% trans "Cancel" %}"></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if type == 'checkbox' %}
|
{% if type == 'checkbox' %}
|
||||||
<div class="web-setting-name">
|
<form class="web-setting-form web-checkbox-setting-form">{% csrf_token %}
|
||||||
<label>{{ setting_display_name }}</label>
|
<h5 class="web-setting-name">{{ setting_display_name }}</h5>
|
||||||
</div>
|
<div class="web-setting-input">
|
||||||
|
<label class="checkbox-label">
|
||||||
<div class="web-setting-description">
|
<span class="checkbox{% if setting_val %} checkbox-checked{% endif %}"><input class="checkbox-orig web-setting-checkbox" type="checkbox" name="{{ setting_name }}"{% if setting_val %} checked="checked"{% endif %} /></span>
|
||||||
<form class="web-checkbox-setting-form">{% csrf_token %}
|
<span class="checkbox-option">{{ help_tip }}</span>
|
||||||
<input class="web-checkbox-setting" type="checkbox" name="{{ setting_name }}" {% if setting_val %}checked="checked"{% endif %} /><span class="web-setting-help-tip pos-rel">{{ help_tip }}</span>
|
</label>
|
||||||
</form>
|
</div>
|
||||||
</div>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<div class="seahub-web-settings">
|
<div class="seahub-web-settings">
|
||||||
|
|
||||||
<h4>Url</h4>
|
<h4>URL</h4>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{% with type="input" setting_display_name="SERVICE_URL" help_tip="The URL of the server, like https://seafile.example.com or http://192.168.1.2:8000" setting_name="SERVICE_URL" setting_val=config_dict.SERVICE_URL %}
|
{% with type="input" setting_display_name="SERVICE_URL" help_tip="The URL of the server, like https://seafile.example.com or http://192.168.1.2:8000" setting_name="SERVICE_URL" setting_val=config_dict.SERVICE_URL %}
|
||||||
@ -45,15 +45,15 @@
|
|||||||
<h4>Password</h4>
|
<h4>Password</h4>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{% with type="checkbox" setting_display_name="strong password" help_tip="Force user use a strong password when singup up or change password." setting_name="USER_STRONG_PASSWORD_REQUIRED" setting_val=config_dict.USER_STRONG_PASSWORD_REQUIRED %}
|
{% with type="checkbox" setting_display_name="strong password" help_tip="Force user to use a strong password when sign up or change password." setting_name="USER_STRONG_PASSWORD_REQUIRED" setting_val=config_dict.USER_STRONG_PASSWORD_REQUIRED %}
|
||||||
{% include "snippets/web_settings_form.html" %}
|
{% include "snippets/web_settings_form.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
{% with type="input" setting_display_name="password minimum length" help_tip="The least number of characters when user make up an account password." setting_name="USER_PASSWORD_MIN_LENGTH" setting_val=config_dict.USER_PASSWORD_MIN_LENGTH %}
|
{% with type="input" setting_display_name="password minimum length" help_tip="The least number of characters an account password should include." setting_name="USER_PASSWORD_MIN_LENGTH" setting_val=config_dict.USER_PASSWORD_MIN_LENGTH %}
|
||||||
{% include "snippets/web_settings_form.html" %}
|
{% include "snippets/web_settings_form.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
{% with type="input" setting_display_name="password strength level" help_tip="The level of password strength when user make up an account passowrd." setting_name="USER_PASSWORD_STRENGTH_LEVEL" setting_val=config_dict.USER_PASSWORD_STRENGTH_LEVEL %}
|
{% with type="input" setting_display_name="password strength level" help_tip="The level of an account password's strength." setting_name="USER_PASSWORD_STRENGTH_LEVEL" setting_val=config_dict.USER_PASSWORD_STRENGTH_LEVEL %}
|
||||||
{% include "snippets/web_settings_form.html" %}
|
{% include "snippets/web_settings_form.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</div>
|
</div>
|
||||||
@ -61,15 +61,15 @@
|
|||||||
<h4>Library</h4>
|
<h4>Library</h4>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{% with type="checkbox" setting_display_name="library history" help_tip="If allow user keep library history" setting_name="ENABLE_REPO_HISTORY_SETTING" setting_val=config_dict.ENABLE_REPO_HISTORY_SETTING %}
|
{% with type="checkbox" setting_display_name="library history" help_tip="Allow user to keep library history" setting_name="ENABLE_REPO_HISTORY_SETTING" setting_val=config_dict.ENABLE_REPO_HISTORY_SETTING %}
|
||||||
{% include "snippets/web_settings_form.html" %}
|
{% include "snippets/web_settings_form.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
{% with type="checkbox" setting_display_name="encrypt library" help_tip="If allow user create encrypted library" setting_name="ENABLE_ENCRYPT_LIBRARY" setting_val=config_dict.ENABLE_ENCRYPT_LIBRARY %}
|
{% with type="checkbox" setting_display_name="encrypted library" help_tip="Allow user to create encrypted library" setting_name="ENABLE_ENCRYPT_LIBRARY" setting_val=config_dict.ENABLE_ENCRYPT_LIBRARY %}
|
||||||
{% include "snippets/web_settings_form.html" %}
|
{% include "snippets/web_settings_form.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
{% with type="input" setting_display_name="library password minimum length" help_tip="The least number of characters that can make up an encrypt library password." setting_name="REPO_PASSWORD_MIN_LENGTH" setting_val=config_dict.REPO_PASSWORD_MIN_LENGTH %}
|
{% with type="input" setting_display_name="library password minimum length" help_tip="The least number of characters an encrypted library password should include." setting_name="REPO_PASSWORD_MIN_LENGTH" setting_val=config_dict.REPO_PASSWORD_MIN_LENGTH %}
|
||||||
{% include "snippets/web_settings_form.html" %}
|
{% include "snippets/web_settings_form.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</div>
|
</div>
|
||||||
@ -86,44 +86,37 @@
|
|||||||
|
|
||||||
{% block extra_script %}
|
{% block extra_script %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var original_value;
|
$('.web-setting-form .input').focus(function() {
|
||||||
var temp_container;
|
var $otherFormSubmit = $('.web-setting-form .submit:visible');
|
||||||
$('.input').focus(function() {
|
if ($otherFormSubmit.length > 0) {
|
||||||
if ($(this).siblings('.error').html()) {
|
$otherFormSubmit.siblings('.cancel').click();
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (temp_container) {
|
|
||||||
$('.cancel-setting', temp_container).click();
|
var $form = $(this).closest('form');
|
||||||
}
|
$('.submit, .cancel', $form).show();
|
||||||
$(this).siblings('.submit, .cancel-setting').show();
|
|
||||||
original_value = $(this).val();
|
|
||||||
temp_container = $(this).parent();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.cancel-setting').click(function() {
|
$('.web-setting-form .cancel').click(function() {
|
||||||
temp_container = '';
|
var $form = $(this).closest('form');
|
||||||
if ($(this).siblings('.error').html()) {
|
$('.error, .submit, .cancel', $form).hide();
|
||||||
$(this).siblings('.error').html('').hide();
|
var $input = $('.input', $form);
|
||||||
}
|
$input.val($input.attr('data-cur'));
|
||||||
$(this).siblings('.input').val(original_value).siblings('.submit, .cancel-setting').hide();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).click(function(e) {
|
$(document).click(function(e) {
|
||||||
var target = e.target || event.srcElement;
|
var target = e.target || event.srcElement;
|
||||||
if (!$('.input').is(target) &&
|
var $op = $('.web-setting-form .submit:visible');
|
||||||
!$('.submit').is(target) &&
|
if ($op.length && !$('.input, .submit, .cancel', $op.closest('form')).is(target)) {
|
||||||
!$('.cancel-setting').is(target) &&
|
$('.cancel', $op.closest('form')).click();
|
||||||
temp_container) {
|
|
||||||
$('.cancel-setting', temp_container).click();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.web-checkbox-setting').change(function() {
|
$('.web-setting-checkbox').change(function() {
|
||||||
var checkbox = $(this),
|
var checkbox = $(this),
|
||||||
value,
|
value,
|
||||||
key = checkbox.attr('name');
|
key = checkbox.attr('name');
|
||||||
|
|
||||||
if (checkbox.is(':checked')) {
|
if (checkbox.prop('checked')) {
|
||||||
value = 1;
|
value = 1;
|
||||||
} else {
|
} else {
|
||||||
value = 0;
|
value = 0;
|
||||||
@ -147,19 +140,22 @@ $('.web-input-setting-form').submit(function() {
|
|||||||
var $form = $(this),
|
var $form = $(this),
|
||||||
$error = $form.find('.error'),
|
$error = $form.find('.error'),
|
||||||
$input = $form.find('.input'),
|
$input = $form.find('.input'),
|
||||||
$sb_btn = $('.submit', $form);
|
$sb_btn = $('.submit', $form),
|
||||||
$cancel_btn = $('.cancel-setting', $form),
|
$cancel_btn = $('.cancel', $form),
|
||||||
key = $.trim($input.attr('name')),
|
key = $input.attr('name'),
|
||||||
value = $.trim($input.val());
|
value = $.trim($input.val());
|
||||||
|
|
||||||
disable($sb_btn);
|
|
||||||
|
|
||||||
if (!value) {
|
if (!value) {
|
||||||
$error.html("{% trans "Can not be empty" %}").show();
|
$error.html("{% trans "It is required." %}").show();
|
||||||
enable($sb_btn);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (value == $input.attr('data-cur')) { // no change
|
||||||
|
$cancel_btn.click();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
disable($sb_btn);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{% url 'sys_settings' %}",
|
url: "{% url 'sys_settings' %}",
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
@ -167,21 +163,20 @@ $('.web-input-setting-form').submit(function() {
|
|||||||
beforeSend: prepareCSRFToken,
|
beforeSend: prepareCSRFToken,
|
||||||
data: { 'key': key, 'value': value },
|
data: { 'key': key, 'value': value },
|
||||||
success: function() {
|
success: function() {
|
||||||
|
$input.val(value).attr('data-cur', value);
|
||||||
$error.html('').hide();
|
$error.html('').hide();
|
||||||
enable($sb_btn);
|
enable($sb_btn);
|
||||||
$input.val(value);
|
|
||||||
$sb_btn.hide();
|
$sb_btn.hide();
|
||||||
$cancel_btn.hide();
|
$cancel_btn.hide();
|
||||||
temp_container = '';
|
|
||||||
feedback("{% trans "Success" %}", 'success');
|
feedback("{% trans "Success" %}", 'success');
|
||||||
},
|
},
|
||||||
error: function(jqXHR, textStatus, errorThrown) {
|
error: function(jqXHR, textStatus, errorThrown) {
|
||||||
if (jqXHR.responseText) {
|
if (jqXHR.responseText) {
|
||||||
$error.html($.parseJSON(jqXHR.responseText).error).show();
|
$error.html($.parseJSON(jqXHR.responseText).error).show();
|
||||||
enable($sb_btn);
|
|
||||||
} else {
|
} else {
|
||||||
$error.html("{% trans "Failed. Please check the network." %}").show();
|
$error.html("{% trans "Failed. Please check the network." %}").show();
|
||||||
}
|
}
|
||||||
|
enable($sb_btn);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user