mirror of
https://github.com/haiwen/seahub.git
synced 2025-07-19 09:37:51 +00:00
[file view] removed 'share' (#2435)
This commit is contained in:
parent
7beb852811
commit
11a0f4fd2a
@ -1,68 +0,0 @@
|
||||
{% load i18n %}
|
||||
<div id="file-share" class="hide">
|
||||
<h3 class="hd" id="dialogTitle">{% trans 'Share %(name)s' %}</h3>
|
||||
<div id="file-share-tabs" class="nav-con-tabs">
|
||||
<ul class="nav-con-tabs-nav">
|
||||
<li class="tab"><a href="#link-share" class="a">{% trans "Share Link" %}</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="nav-con-tabs-content">
|
||||
|
||||
<div id="link-share" class="tabs-panel">
|
||||
<div id="link-options">
|
||||
<label class="checkbox-label">
|
||||
<input type="checkbox" name="use-passwd" id="link-passwd-switch" class="vam" />
|
||||
<span class="checkbox-option vam">{% trans "Add password protection"%}</span>
|
||||
</label>
|
||||
<div id="link-passwd" class="hide">
|
||||
<label for="password">{% trans "Password"%}</label><span class="tip">{% blocktrans %}(at least {{share_link_password_min_length}} characters){% endblocktrans %}</span><br />
|
||||
<input type="password" name="password" disabled="disabled" class="input input-disabled" id="password" /><br />
|
||||
<label for="password-again">{% trans "Password again"%}</label><br />
|
||||
<input type="password" name="password_again" disabled="disabled" class="input input-disabled" id="password-again" />
|
||||
</div>
|
||||
|
||||
<label class="checkbox-label">
|
||||
<input type="checkbox" name="set-expiration" id="link-expire-switch" class="vam" />
|
||||
<span class="checkbox-option vam">{% trans "Add auto expiration"%}</span>
|
||||
</label>
|
||||
<div id="link-expire" class="hide">
|
||||
<label for="expire-days">{% trans "Days" %}</label><br />
|
||||
<input type="text" id="expire-days" name="expire-days" disabled="disabled" class="input input-disabled" />
|
||||
</div>
|
||||
|
||||
{% if is_pro %}
|
||||
<label class="checkbox-label">
|
||||
<input type="checkbox" name="preview_only" class="vam" />
|
||||
<span class="checkbox-option vam">{% trans "Online preview only" %}</span>
|
||||
</label>
|
||||
{% endif %}
|
||||
|
||||
<p class="error hide"></p>
|
||||
</div>
|
||||
<button id="gen-link-btn" class="hide">{% trans "Generate"%}</button>
|
||||
<div id="share-link-body" class="hide">
|
||||
<p style="margin-top:3px;"><span class="vam">{% trans 'Link: ' %}</span><input type="text" readonly="readonly" id="shared-link-text" class="shared-link vam" /></p>
|
||||
<button id="send-link">{% trans 'Send' %}</button>
|
||||
<button id="rm-shared-link">{% trans 'Delete' %}</button>
|
||||
|
||||
<form id="link-send-form" action="" method="post" class="hide">{% csrf_token %}
|
||||
<label for="link-send-input">{% trans "Send to:"%}</label><br />
|
||||
<input type="text" class="input" id="link-send-input" name="email" placeholder="{% trans "Emails, separated by ','"%}" title="{% trans "Emails, separated by ','"%}" /><br />
|
||||
<input type="hidden" name="file_shared_link" value="{{ dir_shared_link }}" />
|
||||
<input type="hidden" name="file_shared_name" value="" />
|
||||
<input type="hidden" name="file_shared_type" value="" />
|
||||
<label for="download-extra-msg-text">{% trans "Message (optional):"%}</label><br />
|
||||
<textarea class="textarea" name="extra_msg" id="download-extra-msg-text"></textarea><br />
|
||||
<p class="error hide"></p>
|
||||
<input type="submit" value="{% trans "Submit"%}" class="submit" />
|
||||
<input type="button" value="{% trans "Cancel"%}" class="cancel" />
|
||||
<p id="sending" class="hide">{% trans "Sending..."%}</p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,249 +0,0 @@
|
||||
{% load i18n %}
|
||||
|
||||
|
||||
function showSharePopup(op, name, aj_data, type, cur_path) {
|
||||
var path = cur_path + name;
|
||||
|
||||
var form = $('#file-share');
|
||||
var modal = form.modal({appendTo: "#main", focus:false});
|
||||
|
||||
var hd = $('#file-share .hd');
|
||||
hd.html(hd.html().replace('%(name)s', '<span class="op-target">' + HTMLescape(trimFilename(name, 30)) + '</span>'));
|
||||
|
||||
$("#file-share-tabs").tabs();
|
||||
|
||||
// share link
|
||||
if (op.attr('data-link')) {
|
||||
$('#gen-link-btn, #link-options').addClass('hide');
|
||||
$('#share-link-body').removeClass('hide');
|
||||
var link = op.attr('data-link');
|
||||
$('#shared-link-text, #link-send-form input[name="file_shared_link"]').val(link);
|
||||
$('#main').append('<p id="linkwidth" class="hide">' + link + '</p>');
|
||||
$('#shared-link-text').css({'width':$('#linkwidth').width() + 25});
|
||||
$('#linkwidth').remove();
|
||||
} else {
|
||||
$('#gen-link-btn, #link-options').removeClass('hide');
|
||||
$('#share-link-body').addClass('hide');
|
||||
}
|
||||
$('#gen-link-btn').data('aj_data', aj_data).data('obj', op);
|
||||
$('#rm-shared-link').data('obj', op);
|
||||
$('input[name="file_shared_name"]').val(name);
|
||||
$('input[name="file_shared_type"]').val(type);
|
||||
|
||||
$('#simplemodal-container').css({'height':'auto', 'width':'auto'});
|
||||
modal.setPosition();
|
||||
}
|
||||
|
||||
$('#send-link').on('click', function() {
|
||||
$(this).addClass('hide');
|
||||
$('#rm-shared-link').addClass('hide');
|
||||
var input = $('#link-send-input');
|
||||
input.css({'width': $('#link-share').width() - parseInt(input.css('padding-left')) - parseInt(input.css('padding-right')) - parseInt(input.css('border-left-width')) - parseInt(input.css('border-right-width'))});
|
||||
var text = $('#download-extra-msg-text');
|
||||
text.css({'width': $('#link-share').width() - parseInt(text.css('padding-left')) - parseInt(text.css('padding-right')) - parseInt(text.css('border-left-width')) - parseInt(text.css('border-right-width'))});
|
||||
$('#link-send-form').removeClass('hide');
|
||||
//addAutocomplete('#link-send-input', '#link-send-form', share_list);
|
||||
});
|
||||
|
||||
$("#link-send-form .cancel").on('click', function() {
|
||||
$('#link-send-form, #send-link, #rm-shared-link').toggleClass('hide');
|
||||
});
|
||||
|
||||
$("#link-send-form").on('submit', function(event) {
|
||||
var form = $(this),
|
||||
file_shared_link = form.children('input[name="file_shared_link"]').val(),
|
||||
email = $.trim(form.children('input[name="email"]').val()),
|
||||
submit_btn = form.children('input[type="submit"]'),
|
||||
extra_msg = form.children('textarea[name="extra_msg"]').val(),
|
||||
file_shared_name = form.children('input[name="file_shared_name"]').val(),
|
||||
file_shared_type = form.children('input[name="file_shared_type"]').val();
|
||||
|
||||
if (!email) {
|
||||
apply_form_error('link-send-form', "{% trans "Please input at least an email." %}");
|
||||
return false;
|
||||
}
|
||||
|
||||
disable(submit_btn);
|
||||
$('#link-send-form .error').addClass('hide');
|
||||
$('#sending').removeClass('hide');
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "{% url 'send_shared_link' %}",
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
beforeSend: prepareCSRFToken,
|
||||
data: {
|
||||
file_shared_link: file_shared_link,
|
||||
email: email,
|
||||
extra_msg: extra_msg,
|
||||
file_shared_name: file_shared_name,
|
||||
file_shared_type: file_shared_type
|
||||
},
|
||||
success: function(data) {
|
||||
$.modal.close();
|
||||
var msg = "{% trans "Successfully sent to {placeholder}" %}"
|
||||
.replace('{placeholder}', data['send_success'].join(', '));
|
||||
feedback(msg, "success");
|
||||
if (data['send_failed'].length > 0) {
|
||||
msg += '<br />' + "{% trans "Failed to send to {placeholder}" %}"
|
||||
.replace('{placeholder}', data['send_failed'].join(', '));
|
||||
feedback(msg, 'info');
|
||||
}
|
||||
},
|
||||
error: function(xhr, textStatus, errorThrown) {
|
||||
$('#sending').addClass('hide');
|
||||
enable(submit_btn);
|
||||
var err_str = '';
|
||||
if (xhr.responseText) {
|
||||
var err = JSON.parse(xhr.responseText);
|
||||
if (err.error) {
|
||||
err_str = err.error;
|
||||
} else {
|
||||
for (var i in err) {
|
||||
err_str += err[i];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
err_str = "{% trans "Failed. Please check the network." %}";
|
||||
}
|
||||
apply_form_error('link-send-form', err_str);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#shared-link-text').on('click', function() {
|
||||
$(this).trigger('select');
|
||||
});
|
||||
|
||||
$('#gen-link-btn').on('click', function() {
|
||||
var gen_link_btn = $(this),
|
||||
obj = gen_link_btn.data('obj'),
|
||||
form = $('#link-options'),
|
||||
form_id = form.attr('id'),
|
||||
use_passwd = $('#link-passwd-switch').prop('checked'),
|
||||
set_expiration = $('#link-expire-switch').prop('checked'),
|
||||
preview_only = $('[name="preview_only"]', form).prop('checked'),
|
||||
password, password_again, expire_days,
|
||||
post_data = {};
|
||||
|
||||
if (use_passwd) {
|
||||
password = $('input[name="password"]', form).val();
|
||||
password_again = $('input[name="password_again"]', form).val();
|
||||
|
||||
if (!$.trim(password)) {
|
||||
apply_form_error(form_id, "{% trans "Please enter password" %}");
|
||||
return false;
|
||||
}
|
||||
if ($.trim(password).length < {{share_link_password_min_length}}) {
|
||||
apply_form_error(form_id, "{% trans "Password is too short" %}");
|
||||
return false;
|
||||
}
|
||||
if (!$.trim(password_again)) {
|
||||
apply_form_error(form_id, "{% trans "Please enter the password again" %}");
|
||||
return false;
|
||||
}
|
||||
if ($.trim(password) != $.trim(password_again)) {
|
||||
apply_form_error(form_id, "{% trans "Passwords don't match" %}");
|
||||
return false;
|
||||
}
|
||||
post_data['password'] = password;
|
||||
}
|
||||
|
||||
if (set_expiration) {
|
||||
expire_days = $('input[name="expire-days"]', form).val();
|
||||
if (!$.trim(expire_days)) {
|
||||
apply_form_error(form_id, "{% trans "Please enter days" %}");
|
||||
return false;
|
||||
}
|
||||
if (Math.floor(expire_days) == expire_days && $.isNumeric(expire_days)) {
|
||||
post_data["expire_days"] = expire_days;
|
||||
} else {
|
||||
apply_form_error(form_id, "{% trans "Please enter valid days" %}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (preview_only) {
|
||||
post_data["permissions"] = JSON.stringify({
|
||||
"can_preview": true,
|
||||
"can_download": false
|
||||
});
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: '{% url 'api-v2.1-share-links' %}',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
beforeSend: prepareCSRFToken,
|
||||
data: $.extend(post_data, $(this).data('aj_data')),
|
||||
success: function(data) {
|
||||
var link = data['link'];
|
||||
// hide gen-link button, and show link
|
||||
gen_link_btn.addClass('hide');
|
||||
|
||||
$('#link-options, #link-options .error').addClass('hide');
|
||||
$('#link-passwd, #link-expire').hide(); // slideDown use 'show()'
|
||||
$('#link-passwd-switch, #link-expire-switch').prop('checked', false);
|
||||
$('[type="password"], [name="expire-days"]', form).val('').attr('disabled', false).removeClass('input-disabled');
|
||||
$('[name="preview_only"]', form).prop('checked', false);
|
||||
|
||||
$('#shared-link-text, #link-send-form input[name="file_shared_link"]').val(link);
|
||||
$('#main').append('<p id="linkwidth" class="hide">' + link + '</p>');
|
||||
$('#shared-link-text').css({'width':$('#linkwidth').width() + 25});
|
||||
$('#linkwidth').remove();
|
||||
$('#share-link-body').removeClass('hide');
|
||||
obj.attr({'data-link': link, 'data-token':data['token']});
|
||||
},
|
||||
error:ajaxErrorHandler
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#rm-shared-link').on('click', function() {
|
||||
var obj = $(this).data('obj'),
|
||||
token = obj.attr('data-token');
|
||||
|
||||
$.ajax({
|
||||
url: '{{ SITE_ROOT }}api/v2.1/share-links/' + token + '/',
|
||||
type: 'DELETE',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
beforeSend: prepareCSRFToken,
|
||||
success: function(data) {
|
||||
$('#share-link-body').addClass('hide');
|
||||
$('#link-options, #gen-link-btn').removeClass('hide');
|
||||
obj.attr({'data-link':'', 'data-token':''});
|
||||
},
|
||||
error: ajaxErrorHandler
|
||||
});
|
||||
});
|
||||
|
||||
$('#link-passwd-switch').on('click', function () {
|
||||
var form = $('#link-options'),
|
||||
pwd_input = $('input[type="password"]', form);
|
||||
var link_passwd = $('#link-passwd');
|
||||
|
||||
if ($(this).prop('checked')) {
|
||||
pwd_input.attr('disabled', false).removeClass('input-disabled');
|
||||
link_passwd.slideDown(100);
|
||||
} else {
|
||||
link_passwd.slideUp(100);
|
||||
pwd_input.attr('disabled', true).addClass('input-disabled');
|
||||
}
|
||||
});
|
||||
|
||||
$('#link-expire-switch').on('click', function () {
|
||||
var form = $('#link-options'),
|
||||
days_input = $('input[name="expire-days"]', form);
|
||||
var link_expire = $('#link-expire');
|
||||
|
||||
if ($(this).prop('checked')) {
|
||||
link_expire.slideDown(100);
|
||||
days_input.attr('disabled', false).removeClass('input-disabled');
|
||||
} else {
|
||||
link_expire.slideUp(100);
|
||||
days_input.attr('disabled', true).addClass('input-disabled');
|
||||
}
|
||||
});
|
@ -87,8 +87,6 @@
|
||||
<div id="file-discussions" class="comments-panel" style="display:none;"></div>
|
||||
</div>
|
||||
|
||||
{% include "snippets/file_share_popup.html" %}
|
||||
|
||||
<div id="side-toolbar">
|
||||
<ul class="side-toolbar">
|
||||
<li class="item hide" id="back-to-top" title="{% trans "Back to top" %}"><img src="{{MEDIA_URL}}img/top.png" alt="{% trans "top" %}" /></li>
|
||||
@ -155,12 +153,6 @@
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if not repo.encrypted %}
|
||||
{% if request.user.permissions.can_generate_share_link %}
|
||||
<button id="share" class="sf-btn-group-btn op-icon sf2-icon-share" data-link="{{ file_shared_link }}" data-token="{{ fileshare.token }}" title="{% trans "Share" %}"></button>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if file_perm == 'rw' %}
|
||||
<a class="sf-btn-group-btn sf-btn-link op-icon sf2-icon-clock" id="history" href="{% url 'file_revisions' repo.id %}?p={{ path|urlencode }}" title="{% trans "History" %}"></a>
|
||||
{% endif %}
|
||||
@ -205,14 +197,6 @@
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if not repo.encrypted %}
|
||||
{% if request.user.permissions.can_generate_share_link %}
|
||||
<li>
|
||||
<a id="share" class="op share" data-link="{{ file_shared_link }}" data-token="{{ fileshare.token }}" title="{% trans "Share" %}">{% trans "Share" %}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if file_perm == 'rw' %}
|
||||
<li>
|
||||
<a id="history" class="op history" href="{% url 'file_revisions' repo.id %}?p={{ path|urlencode }}" title="{% trans "History" %}">{% trans "History" %}</a>
|
||||
@ -230,7 +214,6 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
<script type="text/javascript" src="{% static "scripts/lib/jquery-ui.min.js" %}"></script> {# for 'tabs' used in share popup #}
|
||||
<script type="text/javascript" src="{% static "scripts/lib/underscore.js" %}"></script>
|
||||
<script type="text/javascript" src="{% static "scripts/lib/moment-with-locales.min.js" %}"></script>
|
||||
<script type="text/javascript" src="{% static "scripts/lib/marked.min.js" %}"></script>
|
||||
@ -238,9 +221,6 @@
|
||||
<script type="text/javascript" src="{{ MEDIA_URL }}js/findAndReplaceDOMText.js"></script>
|
||||
{% endif %}
|
||||
<script type="text/javascript">
|
||||
// share link
|
||||
{% include "snippets/shared_link_js.html" %}
|
||||
|
||||
// star file
|
||||
$('#file-star').on('click', function() {
|
||||
var op_icon = $(this), url_base;
|
||||
@ -598,11 +578,6 @@ var DropDownMenu = {
|
||||
})
|
||||
{% endif %}
|
||||
|
||||
$('#share').on('click', function() {
|
||||
var eventSource = $(this);
|
||||
_this.clickToShare(eventSource);
|
||||
});
|
||||
|
||||
$('#discuss').on('click', function() {
|
||||
_this.clickToCommet();
|
||||
});
|
||||
@ -655,23 +630,6 @@ var DropDownMenu = {
|
||||
});
|
||||
},
|
||||
|
||||
clickToShare: function(eventSource) {
|
||||
this.clickToClosePopMenu();
|
||||
var op = $(eventSource),
|
||||
name = "{{filename|escapejs}}",
|
||||
path = "{{path|escapejs}}",
|
||||
aj_data = {
|
||||
'repo_id': "{{ repo.id }}",
|
||||
'path': path
|
||||
},
|
||||
type = 'f',
|
||||
cur_path = path.substr(0, path.length - name.length);
|
||||
|
||||
showSharePopup(op, name, aj_data, type, cur_path);
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
clickToCommet: function() {
|
||||
if (fileDiscussions.$el.is(':visible')) {
|
||||
fileDiscussions.hide();
|
||||
|
Loading…
Reference in New Issue
Block a user