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
{% block nav_shareadmin_class %}class="cur"{% endblock %}
2012-10-12 02:41:15 +00:00
{% if org %}
{% block title_panel %}
< h2 > {{ org.org_name }}< / h2 >
{% endblock %}
{% endif %}
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-29 03:19:21 +00:00
< th width = "20%" > {% trans "Name"%}< / th >
< th width = "22%" > {% trans "Share To"%}< / th >
< th width = "13%" > {% trans "Permission"%}< / th >
< th width = "30%" > {% trans "Description"%}< / th >
< th width = "11%" > {% 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-29 03:19:21 +00:00
< td > < img src = "{{MEDIA_URL}}img/sync-folder-20.png" title = "{% trans " Read-Write " % } " alt = "目录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-10-29 03:19:21 +00:00
< a href = "#" data = "{{ SITE_ROOT }}shareadmin/removeshare/?repo_id={{ repo.props.repo_id }}&from={{ request.user }}&gid={{ repo.props.group_id }}" class = "cancel-share op" > {% trans "Remove Share"%}< / a >
2012-09-26 02:49:00 +00:00
{% endif %}
{% if repo.props.share_type == 'personal' %}
2012-10-29 03:19:21 +00:00
< a href = "#" data = "{{ SITE_ROOT }}shareadmin/removeshare/?repo_id={{ repo.props.repo_id }}&from={{ request.user }}&to={{ repo.props.user }}" class = "cancel-share op" > {% trans "Remove Share"%}< / a >
2012-09-26 02:49:00 +00:00
{% endif %}
{% if repo.props.share_type == 'public' %}
{% if not org %}
2012-10-29 03:19:21 +00:00
< a href = "#" data = "{{ SITE_ROOT }}repo/unsetinnerpub/{{ repo.props.repo_id }}" class = "cancel-share op" > {% trans "Remove Share"%}< / a >
2012-09-26 02:49:00 +00:00
{% else %}
2012-10-29 03:19:21 +00:00
< a href = "#" data = "{{ SITE_ROOT }}organizations/{{ org.url_prefix }}/innerpubrepo/unset/{{ repo.props.repo_id }}" class = "cancel-share op" > {% trans "Remove Share"%}< / 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-10-29 03:19:21 +00:00
< p class = "empty-repo-tips" > {% blocktrans %}Here will show libraries you share to your friends. You can click "Share" icon in "My Home" to share library to your friends.{% endblocktrans %}< / p >
2012-04-24 06:21:52 +00:00
{% endif %}
2012-06-12 02:13:14 +00:00
2012-10-29 03:19:21 +00:00
< h3 > {% trans "File Links"%}< / h3 >
2012-07-13 03:22:20 +00:00
{% if fileshares %}
< table class = "sharelink-list" >
< tr >
2012-10-29 03:19:21 +00:00
< th width = "45%" > {% trans "File"%}< / th >
< th width = "30%" > {% trans "Library"%}< / th >
< th width = "10%" > {% trans "View Count"%}< / th >
< th width = "15%" > {% trans "Operations"%}< / th >
2012-07-13 03:22:20 +00:00
< / tr >
{% for fs in fileshares %}
< tr >
< td > < a href = "{{ SITE_ROOT }}repo/{{ fs.repo.id }}/files/?p={{ fs.path|urlencode }}" > {{ fs.filename }}< / a > < / td >
< 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 >
2012-10-29 03:19:21 +00:00
< a href = "#" class = "op view-link" data = "{{ fs.token }}" > {% trans "View Link"%}< / a >
< a class = "op" href = "{{ SITE_ROOT }}sharedlink/remove/?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 >
{% else %}
2012-10-29 03:19:21 +00:00
< p class = "empty-repo-tips" > {% blocktrans %}Here will show your file links. You can click "Get sharing link" in file viewing page to generate file link. {% endblocktrans %}< / p >
2012-07-13 03:22:20 +00:00
{% endif %}
2012-10-29 03:19:21 +00:00
< p id = "link" class = "hide" > {% trans "File Link: "%}< input type = "text" readonly = "readonly" value = "" id = "shared-link" / > < / p >
2012-04-24 06:21:52 +00:00
{% endblock %}
{% block extra_script %}
< script type = "text/javascript" >
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']) {
feedback('权限设置成功', '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
} else {
feedback('权限设置失败', 'error');
}
2012-10-19 07:14:43 +00:00
select.addClass('hide');
select.prev().removeClass('hide');
2012-10-18 13:28:15 +00:00
},
error: function(jqXHR, textStatus, errorThrown) {
feedback(textStatus + ',权限设置失败', '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');
});
2012-05-29 12:56:42 +00:00
2012-09-08 03:48:28 +00:00
$(".view-link").click(function() {
var token = $(this).attr('data'),
link = '{{ protocol }}://' + '{{ domain }}{{ SITE_ROOT }}f/' + token + '/';
$('#link').before('< p class = "hide" > ' + link + '< / p > ');
$('#shared-link').val(link).css('width', $('#link').prev().width() + 2);
$("#link").modal({appendTo:'#main'});
$('#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();
});
2012-04-24 06:21:52 +00:00
< / script >
{% endblock %}