2012-09-04 09:15:19 +00:00
{% extends base_template %}
2012-10-29 03:19:21 +00:00
{% load seahub_tags i18n %}
2012-10-18 13:28:15 +00:00
{% load url from future %}
2012-04-24 06:21:52 +00:00
2012-11-06 03:12:49 +00:00
{% block nav_share_class %}class="cur"{% endblock %}
2012-04-24 06:21:52 +00:00
2012-10-12 02:41:15 +00:00
{% if org %}
{% block title_panel %}
< h2 > {{ org.org_name }}< / h2 >
{% endblock %}
{% endif %}
2012-11-02 11:45:51 +00:00
{% block left_panel %}
< div class = "info-item" >
< h3 class = "info-item-top" > {% trans "Tips" %}< / h3 >
< div class = "info-item-bottom" >
2013-01-10 08:13:40 +00:00
< p > {% blocktrans %}If you don't want others to change the contents of your shared libraries, you can set the share permission to "read-only" when sharing them.{% endblocktrans %}< / p >
2012-11-02 11:45:51 +00:00
< / div >
< / div >
{% endblock %}
2012-04-24 06:21:52 +00:00
{% block right_panel %}
2012-10-29 03:19:21 +00:00
< h3 > {% trans "Shared Libraries"%}< / h3 >
2012-09-26 02:49:00 +00:00
{% if shared_repos %}
2012-10-18 13:28:15 +00:00
< table >
2012-04-24 06:21:52 +00:00
< tr >
2012-09-27 08:32:17 +00:00
< th width = "4%" > <!-- icon --> < / th >
2012-10-30 08:43:22 +00:00
< th width = "18%" > {% trans "Name"%}< / th >
< th width = "21%" > {% trans "Share To"%}< / th >
< th width = "15%" > {% trans "Permission"%}< / th >
2013-03-02 07:24:33 +00:00
< th width = "29%" > {% trans "Description"%}< / th >
< th width = "13%" > {% trans "Operations"%}< / th >
2012-04-24 06:21:52 +00:00
< / tr >
2012-09-26 02:49:00 +00:00
{% for repo in shared_repos %}
2012-10-18 13:28:15 +00:00
< tr data = "{{repo.props.share_type}}" >
2012-10-30 08:43:22 +00:00
< td > < img src = "{{MEDIA_URL}}img/sync-folder-20.png" title = "{% trans " Read-Write " % } " alt = "{% trans " directory icon " % } " / > < / td >
2012-10-18 13:28:15 +00:00
< td data = "{{ repo.props.repo_id }}" > < a href = "{{ SITE_ROOT }}repo/{{ repo.props.repo_id }}" > {{ repo.props.repo_name }}< / a > < / td >
< td data = "{{repo.props.user_info}}" > {{ repo.props.user }}< / td >
< td >
2012-10-19 07:14:43 +00:00
< div class = "share-permission" >
< span class = "share-permission-cur-value" > {{ repo.share_permission }}< / span >
2012-10-29 03:19:21 +00:00
< img src = "{{MEDIA_URL}}img/edit_12.png" alt = "{% trans " Edit " % } icon " title = "{% trans " Edit " % } " class = "share-permission-edit-icon vh" / >
2012-10-19 07:14:43 +00:00
< / div >
< select name = "permission" class = "share-permission-select hide" >
2012-10-18 13:28:15 +00:00
< option value = "{{ repo.props.permission }}" selected = "selected" > {{ repo.share_permission }}< / option >
{% if repo.props.permission == 'rw' %}
2012-10-29 03:19:21 +00:00
< option value = "r" > {% trans "Read-Only"%}< / option >
2012-10-18 13:28:15 +00:00
{% else %}
2012-10-29 03:19:21 +00:00
< option value = "rw" > {% trans "Read-Write"%}< / option >
2012-10-18 13:28:15 +00:00
{% endif %}
< / select >
< / td >
2012-09-26 02:49:00 +00:00
< td > {{ repo.props.repo_desc }}< / td >
2012-04-24 06:21:52 +00:00
< td >
2012-09-26 02:49:00 +00:00
{% if repo.props.share_type == 'group' %}
2012-12-24 11:57:34 +00:00
< a href = "#" data = "{% url 'repo_remove_share' %}?repo_id={{ repo.props.repo_id }}&from={{ request.user.username|quote }}&gid={{ repo.props.group_id }}" class = "cancel-share op" > {% trans "Unshare"%}< / a >
2012-09-26 02:49:00 +00:00
{% endif %}
{% if repo.props.share_type == 'personal' %}
2012-12-24 11:57:34 +00:00
< a href = "#" data = "{% url 'repo_remove_share' %}?repo_id={{ repo.props.repo_id }}&from={{ request.user.username|quote }}&to={{ repo.props.user|quote }}" class = "cancel-share op" > {% trans "Unshare"%}< / a >
2012-09-26 02:49:00 +00:00
{% endif %}
{% if repo.props.share_type == 'public' %}
{% if not org %}
2013-02-22 09:00:47 +00:00
< a href = "#" data = "{% url 'unsetinnerpub' repo.repo_id %}" class = "cancel-share op" > {% trans "Unshare"%}< / a >
2012-09-26 02:49:00 +00:00
{% else %}
2012-11-05 03:55:02 +00:00
< a href = "#" data = "{{ SITE_ROOT }}organizations/{{ org.url_prefix }}/innerpubrepo/unset/{{ repo.props.repo_id }}" class = "cancel-share op" > {% trans "Unshare"%}< / a >
2012-09-26 02:49:00 +00:00
{% endif %}
2012-05-22 05:41:41 +00:00
{% endif %}
2012-04-24 06:21:52 +00:00
< / td >
< / tr >
{% endfor %}
< / table >
{% else %}
2012-11-02 11:45:51 +00:00
< div class = "empty-tips" >
2013-01-10 08:13:40 +00:00
< h2 class = "center-contents" > {% trans "You have not shared any library" %}< / h2 >
< p > {% trans "You can share libraries to your friends and colleagues by clicking the share icon of your own libraries in your home page or creating a new library in groups you are in." %}< / p >
2012-11-02 11:45:51 +00:00
< / div >
2012-04-24 06:21:52 +00:00
{% endif %}
2012-06-12 02:13:14 +00:00
2013-01-05 02:35:14 +00:00
< h3 > {% trans "Shared Links"%}< / h3 >
2012-07-13 03:22:20 +00:00
{% if fileshares %}
< table class = "sharelink-list" >
< tr >
2013-01-03 11:28:57 +00:00
< th width = "45%" > {% trans "File or Folder"%}< / th >
2012-10-30 08:43:22 +00:00
< th width = "25%" > {% trans "Library"%}< / th >
< th width = "15%" > {% trans "Visits"%}< / th >
2012-10-29 03:19:21 +00:00
< th width = "15%" > {% trans "Operations"%}< / th >
2012-07-13 03:22:20 +00:00
< / tr >
{% for fs in fileshares %}
< tr >
2013-01-03 11:28:57 +00:00
{% if fs.s_type == 'f' %}
< td > < a href = "{% url 'repo_view_file' fs.repo.id %}?p={{ fs.path|urlencode }}" > {{ fs.filename }}< / a > < / td >
{% else %}
< td > < a href = "{% url 'repo' fs.repo.id %}?p={{ fs.path|urlencode }}" > {{ fs.filename }}< / a > < / td >
{% endif %}
2012-07-13 03:22:20 +00:00
< td > < a href = "{{ SITE_ROOT }}repo/{{ fs.repo.id }}/" > {{ fs.repo.name }}< / a > < / td >
< td > {{ fs.view_cnt }}< / td >
2012-09-08 03:48:28 +00:00
< td >
2013-01-03 11:28:57 +00:00
< a href = "#" class = "op view-link" data = "{{ fs.shared_link }}" > {% trans "View" %}< / a >
2012-11-06 03:12:49 +00:00
< a class = "op" href = "{% url 'remove_shared_link' %}?t={{ fs.token }}" > {% trans "Remove"%}< / a >
2012-09-08 03:48:28 +00:00
< / td >
2012-07-13 03:22:20 +00:00
< / tr >
{% endfor %}
< / table >
2013-01-10 08:13:40 +00:00
< input type = "text" readonly = "readonly" value = "" id = "shared-link" class = "hide" / >
2012-07-13 03:22:20 +00:00
{% else %}
2012-11-02 11:45:51 +00:00
< div class = "empty-tips" >
2013-01-10 08:13:40 +00:00
< h2 class = "center-contents" > {% trans "You don't have any shared link"%}< / h2 >
< p > {% trans "You can share a folder or a file when you view a library, or share a file when you view it." %}< / p >
2012-11-02 11:45:51 +00:00
< / div >
2012-07-13 03:22:20 +00:00
{% endif %}
2012-04-24 06:21:52 +00:00
{% endblock %}
{% block extra_script %}
< script type = "text/javascript" >
2013-01-10 08:13:40 +00:00
{% if shared_repos %}
2012-10-19 07:14:43 +00:00
$('tr:gt(0)').hover(
function() {
$(this).find('.share-permission-edit-icon').removeClass('vh');
},
function() {
$(this).find('.share-permission-edit-icon').addClass('vh');
}
);
$('.share-permission-edit-icon').click(function() {
$(this).parent().addClass('hide');
$(this).parent().next().removeClass('hide'); // show 'share-permission-select'
});
$('.share-permission-select').change(function() {
2012-10-18 13:28:15 +00:00
var select = $(this),
select_cont = $(this).parent(),
user = select_cont.prev(),
share_type = select_cont.parent().attr('data');
{% if org %}
var url = '{% url 'org_share_permission_admin' org.url_prefix %}?org_id={{ org.org_id }}& share_type=' + share_type;
{% else %}
var url = '{% url 'share_permission_admin' %}?share_type=' + share_type;
{% endif %}
$.ajax({
url: url,
type: 'POST',
dataType: 'json',
cache: false,
contentType: 'application/json; charset=utf-8',
beforeSend: prepareCSRFToken,
data: {
repo_id: user.prev().attr('data'),
email_or_group: user.attr('data'),
permission: select.val()
},
success: function(data) {
if (data['success']) {
2012-10-30 08:43:22 +00:00
feedback('{% trans "Edit succeeded" %}', 'success');
2012-10-19 07:14:43 +00:00
select.prev().children('.share-permission-cur-value').html(select.children('option[value="' +select.val() + '"]').text());
2012-10-18 13:28:15 +00:00
}
2012-10-19 07:14:43 +00:00
select.addClass('hide');
select.prev().removeClass('hide');
2012-10-18 13:28:15 +00:00
},
2013-01-10 08:13:40 +00:00
error: function() {
feedback('{% trans "Edit failed." %}', 'error');
2012-10-19 07:14:43 +00:00
select.addClass('hide');
select.prev().removeClass('hide');
2012-10-18 13:28:15 +00:00
}
});
});
2012-10-19 07:14:43 +00:00
// select shows, but the user doesn't select a value, or doesn't change the permission, click other place to hide the select
$(document).click(function(e) {
var target = e.target || event.srcElement;
// target can't be edit-icon
if (!$('.share-permission-edit-icon, .share-permission-select').is(target)) {
$('.share-permission').removeClass('hide');
$('.share-permission-select').addClass('hide');
}
});
2012-05-29 12:56:42 +00:00
$('.cancel-share').click(function() {
2012-04-26 08:41:22 +00:00
location.href = $(this).attr('data');
});
2013-01-10 08:13:40 +00:00
{% endif %}
2012-05-29 12:56:42 +00:00
2013-01-10 08:13:40 +00:00
{% if fileshares %}
2012-09-08 03:48:28 +00:00
$(".view-link").click(function() {
2013-01-03 11:28:57 +00:00
var link = $(this).attr('data');
2013-01-10 08:13:40 +00:00
$('#shared-link').before('< p class = "hide" > ' + link + '< / p > ')
.val(link).css('width', $('#shared-link').prev().width() + 2)
.modal({focus:false});
$('#shared-link').prev().remove();
2012-07-13 03:22:20 +00:00
return false;
});
2012-09-08 03:48:28 +00:00
$('#shared-link').click(function() {
$(this).select();
});
2013-01-10 08:13:40 +00:00
{% endif %}
2012-04-24 06:21:52 +00:00
< / script >
{% endblock %}