mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-28 16:17:02 +00:00
Split tabs in share admin page
This commit is contained in:
BIN
media/img/icon-share-in.png
Normal file
BIN
media/img/icon-share-in.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
media/img/icon-share-out.png
Normal file
BIN
media/img/icon-share-out.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
61
seahub/share/templates/repo/priv_shared_files.html
Normal file
61
seahub/share/templates/repo/priv_shared_files.html
Normal file
@@ -0,0 +1,61 @@
|
||||
{% extends base_template %}
|
||||
{% load seahub_tags i18n %}
|
||||
{% load url from future %}
|
||||
|
||||
{% block sub_title %}{% trans "Share" %} - {% endblock %}
|
||||
{% block nav_share_class %}class="cur"{% endblock %}
|
||||
|
||||
{% block title_panel %}
|
||||
<div class="tabnav">
|
||||
<ul class="tabnav-tabs">
|
||||
<li class="tabnav-tab"><a href="{% url 'share_admin' %}">{% trans "Libraries" %}</a></li>
|
||||
<li class="tabnav-tab"><a href="{% url 'list_shared_links' %}">{% trans "Links" %}</a></li>
|
||||
<li class="tabnav-tab tabnav-tab-cur">{% trans "Private Shares" %}</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block main_panel %}
|
||||
{% if priv_shares %}
|
||||
<table>
|
||||
<tr>
|
||||
<th width="18%">{% trans "From/To"%}</th>
|
||||
<th width="45%">{% trans "Name"%}</th>
|
||||
<th width="25%">{% trans "Library"%}</th>
|
||||
<th width="12%">{% trans "Operations"%}</th>
|
||||
</tr>
|
||||
{% for e in priv_shares %}
|
||||
<tr>
|
||||
{% if e.out_or_in == 'out' %}
|
||||
<td><img src="{{MEDIA_URL}}img/icon-share-out.png" title="{% trans "Share out"%}" alt="{% trans "share icon"%}"/> {{e.to_user|email2nickname}}</td>
|
||||
{% else %}
|
||||
<td><img src="{{MEDIA_URL}}img/icon-share-in.png" title="{% trans "Share in"%}" alt="{% trans "share icon"%}"/> {{e.from_user|email2nickname}}</td>
|
||||
{% endif %}
|
||||
{% if e.s_type == 'f' %}
|
||||
<td><a href="{% url 'view_priv_shared_file' e.repo_id %}?p={{ e.path|urlencode}}">{{e.file_or_dir}}</a></td>
|
||||
{% else %}
|
||||
<td><a href="{% url 'repo' e.repo_id %}?p={{ e.path|urlencode}}">{{e.file_or_dir}}</a></td>
|
||||
{% endif %}
|
||||
{% if e.out_or_in == 'out' %}
|
||||
<td><a href="{% url 'repo' e.repo_id %}">{{e.repo.name}}</a></td>
|
||||
{% else %}
|
||||
<td>--</td>
|
||||
{% endif %}
|
||||
<td><a href="{% url 'rm_private_file_share' e.repo_id %}?from={{e.from_user|urlencode}}&to={{e.to_user|urlencode}}&p={{e.path|urlencode}}" class="op">Unshare</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else%}
|
||||
<div class="empty-tips">
|
||||
<h2 class="center-contents">{% trans "You don't have any private shared files/folders" %}</h2>
|
||||
<p>{% trans "You can share a single folder or file to a registered user if you don't want to share hole library to he/she." %}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
<script type="text/javascript">
|
||||
</script>
|
||||
{% endblock %}
|
142
seahub/share/templates/repo/share_out_repos.html
Normal file
142
seahub/share/templates/repo/share_out_repos.html
Normal file
@@ -0,0 +1,142 @@
|
||||
{% extends base_template %}
|
||||
{% load seahub_tags i18n %}
|
||||
{% load url from future %}
|
||||
|
||||
{% block sub_title %}{% trans "Share" %} - {% endblock %}
|
||||
{% block nav_share_class %}class="cur"{% endblock %}
|
||||
|
||||
{% block title_panel %}
|
||||
<div class="tabnav">
|
||||
<ul class="tabnav-tabs">
|
||||
<li class="tabnav-tab tabnav-tab-cur">{% trans "Libraries" %}</li>
|
||||
<li class="tabnav-tab"><a href="{% url 'list_shared_links' %}">{% trans "Links" %}</a></li>
|
||||
<li class="tabnav-tab"><a href="{% url 'list_priv_shared_files' %}">{% trans "Private Shares" %}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block main_panel %}
|
||||
{% if shared_repos %}
|
||||
<table>
|
||||
<tr>
|
||||
<th width="3%"><!--icon--></th>
|
||||
<th width="19%">{% trans "Name"%}</th>
|
||||
<th width="21%">{% trans "Share To"%}</th>
|
||||
<th width="15%">{% trans "Permission"%}</th>
|
||||
<th width="29%">{% trans "Description"%}</th>
|
||||
<th width="13%">{% trans "Operations"%}</th>
|
||||
</tr>
|
||||
{% for repo in shared_repos %}
|
||||
<tr data="{{repo.props.share_type}}">
|
||||
<td><img src="{{MEDIA_URL}}img/sync-folder-20.png" title="{% trans "Read-Write"%}" alt="{% trans "directory icon" %}" /></td>
|
||||
<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>
|
||||
<div class="share-permission">
|
||||
<span class="share-permission-cur-value">{{ repo.share_permission }}</span>
|
||||
<img src="{{MEDIA_URL}}img/edit_12.png" alt="{% trans "Edit"%}" title="{% trans "Edit"%}" class="share-permission-edit-icon vh" />
|
||||
</div>
|
||||
<select name="permission" class="share-permission-select hide">
|
||||
<option value="{{ repo.props.permission }}" selected="selected">{{ repo.share_permission }}</option>
|
||||
{% if repo.props.permission == 'rw' %}
|
||||
<option value="r">{% trans "Read-Only"%}</option>
|
||||
{% else %}
|
||||
<option value="rw">{% trans "Read-Write"%}</option>
|
||||
{% endif %}
|
||||
</select>
|
||||
</td>
|
||||
<td>{{ repo.props.repo_desc }}</td>
|
||||
<td>
|
||||
{% if repo.props.share_type == 'group' %}
|
||||
<a href="#" data="{% url 'repo_remove_share' %}?repo_id={{ repo.props.repo_id }}&from={{ request.user.username|urlencode }}&gid={{ repo.props.group_id }}" class="cancel-share op">{% trans "Unshare"%}</a>
|
||||
{% endif %}
|
||||
{% if repo.props.share_type == 'personal' %}
|
||||
<a href="#" data="{% url 'repo_remove_share' %}?repo_id={{ repo.props.repo_id }}&from={{ request.user.username|urlencode }}&to={{ repo.props.user|urlencode }}" class="cancel-share op">{% trans "Unshare"%}</a>
|
||||
{% endif %}
|
||||
{% if repo.props.share_type == 'public' %}
|
||||
{% if not org %}
|
||||
<a href="#" data="{% url 'unsetinnerpub' repo.repo_id %}" class="cancel-share op">{% trans "Unshare"%}</a>
|
||||
{% else %}
|
||||
<a href="#" data="{{ SITE_ROOT }}organizations/{{ org.url_prefix }}/innerpubrepo/unset/{{ repo.props.repo_id }}" class="cancel-share op">{% trans "Unshare"%}</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="empty-tips">
|
||||
<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>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
<script type="text/javascript">
|
||||
{% if shared_repos %}
|
||||
$('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() {
|
||||
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,
|
||||
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("{% trans "Edit succeeded" %}", 'success');
|
||||
select.prev().children('.share-permission-cur-value').html(select.children('option[value="' +select.val() + '"]').text());
|
||||
}
|
||||
select.addClass('hide');
|
||||
select.prev().removeClass('hide');
|
||||
},
|
||||
error: function() {
|
||||
feedback("{% trans "Edit failed." %}", 'error');
|
||||
select.addClass('hide');
|
||||
select.prev().removeClass('hide');
|
||||
}
|
||||
});
|
||||
});
|
||||
// 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');
|
||||
}
|
||||
});
|
||||
$('.cancel-share').click(function() {
|
||||
location.href = $(this).attr('data');
|
||||
});
|
||||
{% endif %} // shared_repos
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
75
seahub/share/templates/repo/shared_links.html
Normal file
75
seahub/share/templates/repo/shared_links.html
Normal file
@@ -0,0 +1,75 @@
|
||||
{% extends base_template %}
|
||||
{% load seahub_tags i18n %}
|
||||
{% load url from future %}
|
||||
|
||||
{% block sub_title %}{% trans "Share" %} - {% endblock %}
|
||||
{% block nav_share_class %}class="cur"{% endblock %}
|
||||
|
||||
{% block title_panel %}
|
||||
<div class="tabnav">
|
||||
<ul class="tabnav-tabs">
|
||||
<li class="tabnav-tab"><a href="{% url 'share_admin' %}">{% trans "Libraries" %}</a></li>
|
||||
<li class="tabnav-tab tabnav-tab-cur">{% trans "Links" %}</li>
|
||||
<li class="tabnav-tab"><a href="{% url 'list_priv_shared_files' %}">{% trans "Private Shares" %}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block main_panel %}
|
||||
{% if fileshares %}
|
||||
<table class="sharelink-list">
|
||||
<tr>
|
||||
<th width="3%"><!--icon--></th>
|
||||
<th width="45%">{% trans "Name"%}</th>
|
||||
<th width="25%">{% trans "Library"%}</th>
|
||||
<th width="12%">{% trans "Visits"%}</th>
|
||||
<th width="15%">{% trans "Operations"%}</th>
|
||||
</tr>
|
||||
{% for fs in fileshares %}
|
||||
<tr>
|
||||
{% if fs.s_type == 'f' %}
|
||||
<td class="icon-container"><img src="{{ MEDIA_URL }}img/file/{{ fs.filename|file_icon_filter }}" alt="{% trans "File"%}" /></td>
|
||||
{% else %}
|
||||
<td class="icon-container"><img src="{{ MEDIA_URL }}img/folder-icon-24.png" alt="{% trans "Directory icon"%}" /></td>
|
||||
{% endif %}
|
||||
{% 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 %}
|
||||
<td><a href="{{ SITE_ROOT }}repo/{{ fs.repo.id }}/">{{ fs.repo.name }}</a></td>
|
||||
<td>{{ fs.view_cnt }}</td>
|
||||
<td>
|
||||
<a href="#" class="op view-link" data="{{ fs.shared_link }}">{% trans "View" %}</a>
|
||||
<a class="op" href="{% url 'remove_shared_link' %}?t={{ fs.token }}">{% trans "Remove"%}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<input type="text" readonly="readonly" value="" id="shared-link" class="hide" />
|
||||
{% else %}
|
||||
<div class="empty-tips">
|
||||
<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>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
<script type="text/javascript">
|
||||
{% if fileshares %}
|
||||
$(".view-link").click(function() {
|
||||
var link = $(this).attr('data');
|
||||
$('#shared-link').before('<p class="hide">' + link + '</p>')
|
||||
.val(link).css('width', $('#shared-link').prev().width() + 2)
|
||||
.modal({focus:false});
|
||||
$('#shared-link').prev().remove();
|
||||
return false;
|
||||
});
|
||||
$('#shared-link').click(function() {
|
||||
$(this).select();
|
||||
});
|
||||
{% endif %}
|
||||
</script>
|
||||
{% endblock %}
|
@@ -3,7 +3,10 @@ from django.conf.urls.defaults import *
|
||||
from views import *
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^$', share_admin, name='share_admin'),
|
||||
url(r'^$', list_share_out_repos, name='share_admin'),
|
||||
url(r'^links/$', list_shared_links, name='list_shared_links'),
|
||||
url(r'^files/$', list_priv_shared_files, name='list_priv_shared_files'),
|
||||
|
||||
url(r'^add/$', share_repo, name='share_repo'),
|
||||
url(r'^remove/$', repo_remove_share, name='repo_remove_share'),
|
||||
|
||||
|
@@ -346,6 +346,106 @@ def share_admin(request):
|
||||
"priv_shares": priv_shares,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
@login_required
|
||||
def list_share_out_repos(request):
|
||||
"""
|
||||
List personal shared repos.
|
||||
"""
|
||||
username = request.user.username
|
||||
|
||||
shared_repos = []
|
||||
|
||||
# personal repos shared from this user
|
||||
shared_repos += seafile_api.get_share_out_repo_list(username, -1, -1)
|
||||
|
||||
# repos shared to groups
|
||||
group_repos = get_group_repos_by_owner(username)
|
||||
for repo in group_repos:
|
||||
group = ccnet_threaded_rpc.get_group(int(repo.group_id))
|
||||
if not group:
|
||||
repo.props.user = ''
|
||||
continue
|
||||
repo.props.user = group.props.group_name
|
||||
repo.props.user_info = repo.group_id
|
||||
shared_repos += group_repos
|
||||
|
||||
if not CLOUD_MODE:
|
||||
# public repos shared by this user
|
||||
pub_repos = list_inner_pub_repos_by_owner(username)
|
||||
for repo in pub_repos:
|
||||
repo.props.user = _(u'all members')
|
||||
repo.props.user_info = 'all'
|
||||
shared_repos += pub_repos
|
||||
|
||||
for repo in shared_repos:
|
||||
if repo.props.permission == 'rw':
|
||||
repo.share_permission = _(u'Read-Write')
|
||||
elif repo.props.permission == 'r':
|
||||
repo.share_permission = _(u'Read-Only')
|
||||
else:
|
||||
repo.share_permission = ''
|
||||
|
||||
if repo.props.share_type == 'personal':
|
||||
repo.props.user_info = repo.props.user
|
||||
|
||||
shared_repos.sort(lambda x, y: cmp(x.repo_id, y.repo_id))
|
||||
|
||||
return render_to_response('repo/share_out_repos.html', {
|
||||
"shared_repos": shared_repos,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
@login_required
|
||||
def list_shared_links(request):
|
||||
"""List shared links.
|
||||
"""
|
||||
username = request.user.username
|
||||
|
||||
# Shared links
|
||||
fileshares = FileShare.objects.filter(username=username)
|
||||
p_fileshares = [] # personal file share
|
||||
for fs in fileshares:
|
||||
if is_personal_repo(fs.repo_id): # only list files in personal repos
|
||||
if fs.s_type == 'f':
|
||||
fs.filename = os.path.basename(fs.path)
|
||||
fs.shared_link = gen_shared_link(request, fs.token, 'f')
|
||||
else:
|
||||
fs.filename = os.path.basename(fs.path[:-1])
|
||||
fs.shared_link = gen_shared_link(request, fs.token, 'd')
|
||||
r = get_repo(fs.repo_id)
|
||||
if not r: # get_repo may returns None
|
||||
continue
|
||||
fs.repo = r
|
||||
p_fileshares.append(fs)
|
||||
|
||||
return render_to_response('repo/shared_links.html', {
|
||||
"fileshares": p_fileshares,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
@login_required
|
||||
def list_priv_shared_files(request):
|
||||
"""List shared links.
|
||||
"""
|
||||
username = request.user.username
|
||||
|
||||
# Private share out/in files/directories
|
||||
priv_share_out = PrivateFileDirShare.objects.list_private_share_out_by_user(username)
|
||||
for e in priv_share_out:
|
||||
e.file_or_dir = os.path.basename(e.path.rstrip('/'))
|
||||
e.out_or_in = 'out'
|
||||
e.repo = seafile_api.get_repo(e.repo_id)
|
||||
|
||||
priv_share_in = PrivateFileDirShare.objects.list_private_share_in_by_user(username)
|
||||
for e in priv_share_in:
|
||||
e.file_or_dir = os.path.basename(e.path.rstrip('/'))
|
||||
e.out_or_in = 'in'
|
||||
e.repo = seafile_api.get_repo(e.repo_id)
|
||||
priv_shares = list(priv_share_out) + list(priv_share_in)
|
||||
|
||||
return render_to_response('repo/priv_shared_files.html', {
|
||||
"priv_shares": priv_shares,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
|
||||
@login_required
|
||||
def share_permission_admin(request):
|
||||
share_type = request.GET.get('share_type', '')
|
||||
|
Reference in New Issue
Block a user