mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-26 15:26:19 +00:00
[myhome lib] fetch shared/grp repos when DOM ready instead of when clicking tabs
This commit is contained in:
@@ -24,7 +24,7 @@ $('#top-nav-grp').click(function() {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(function(){
|
||||||
var msg_ct = $("#msg-count");
|
var msg_ct = $("#msg-count");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: msg_ct.data('cturl'),
|
url: msg_ct.data('cturl'),
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
{% load seahub_tags group_avatar_tags i18n %}<div id="group-repos">
|
{% load seahub_tags group_avatar_tags i18n %}
|
||||||
{% if group_repos %}
|
{% if group_repos %}
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -47,4 +47,3 @@
|
|||||||
<h2 class="alc">{% trans "No library is shared to your groups" %}</h2>
|
<h2 class="alc">{% trans "No library is shared to your groups" %}</h2>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
|
@@ -7,8 +7,8 @@
|
|||||||
{% if ENABLE_SUB_LIBRARY and sub_lib_enabled %}
|
{% if ENABLE_SUB_LIBRARY and sub_lib_enabled %}
|
||||||
<li class="tab"><a href="#my-sub-repos" class="a">{% trans "Sub-libraries" %}</a></li>
|
<li class="tab"><a href="#my-sub-repos" class="a">{% trans "Sub-libraries" %}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li class="tab"><a href="{% url 'my_shared_repos' %}" class="a">{% trans "Shared" %}</a></li>
|
<li class="tab"><a href="#repos-shared-to-me" class="a">{% trans "Shared" %}</a></li>
|
||||||
<li class="tab"><a href="{% url 'my_group_repos' %}" class="a">{% trans "Group" %}</a></li>
|
<li class="tab"><a href="#group-repos" class="a">{% trans "Group" %}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<button id="repo-create" class="fright"><img src="{{ MEDIA_URL }}img/add.png" alt="" class="add vam" /><span class="vam">{% trans "New Library" %}</span></button>
|
<button id="repo-create" class="fright"><img src="{{ MEDIA_URL }}img/add.png" alt="" class="add vam" /><span class="vam">{% trans "New Library" %}</span></button>
|
||||||
</div>
|
</div>
|
||||||
@@ -106,6 +106,9 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<div id="repos-shared-to-me" class="hide"></div>
|
||||||
|
<div id="group-repos" class="hide"></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table id="new-repo" class="hide">
|
<table id="new-repo" class="hide">
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
{% load seahub_tags i18n %}
|
{% load seahub_tags i18n %}
|
||||||
<div id="repos-shared-to-me">
|
|
||||||
{% if shared_repos %}
|
{% if shared_repos %}
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -49,27 +48,3 @@
|
|||||||
<h2 class="alc">{% trans "No library is shared to you" %}</h2>
|
<h2 class="alc">{% trans "No library is shared to you" %}</h2>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
$("tr:gt(0)", $('table')).hover(
|
|
||||||
function() {
|
|
||||||
$(this).addClass('hl');
|
|
||||||
$(this).find('.op-icon, .op').removeClass('vh');
|
|
||||||
},
|
|
||||||
function() {
|
|
||||||
$(this).find('.op-icon, .op').addClass('vh');
|
|
||||||
$(this).removeClass('hl');
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
$(".download-btn").click(function() {
|
|
||||||
var repo_id = $(this).parents('td').data('id');
|
|
||||||
window.open('{{ SITE_ROOT }}seafile_access_check/?repo_id=' + e(repo_id));
|
|
||||||
});
|
|
||||||
$('.unshare-btn').click(function() {
|
|
||||||
location.href = $(this).data('url');
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
@@ -90,9 +90,6 @@ $(function () {
|
|||||||
disable($(this));
|
disable($(this));
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.unshare-btn').click(function() {
|
|
||||||
location.href = $(this).data('url');
|
|
||||||
});
|
|
||||||
|
|
||||||
{% include 'snippets/repo_del_js.html' %}
|
{% include 'snippets/repo_del_js.html' %}
|
||||||
|
|
||||||
@@ -123,3 +120,29 @@ function repoCreateSuccessCallback(data) {
|
|||||||
$('tr:first', my_own_repos).after(new_repo_item);
|
$('tr:first', my_own_repos).after(new_repo_item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
$.ajax({
|
||||||
|
url:'{% url 'my_shared_and_group_repos' %}',
|
||||||
|
cache: false,
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(data) {
|
||||||
|
$('#repos-shared-to-me').html(data['shared']);
|
||||||
|
$('#group-repos').html(data['group']);
|
||||||
|
$('.unshare-btn').click(function() {
|
||||||
|
location.href = $(this).data('url');
|
||||||
|
});
|
||||||
|
$("tr:gt(0)", $('table')).unbind().hover(
|
||||||
|
function() {
|
||||||
|
$(this).addClass('hl');
|
||||||
|
$(this).find('.op-icon').removeClass('vh');
|
||||||
|
},
|
||||||
|
function() {
|
||||||
|
$(this).find('.op-icon').addClass('vh');
|
||||||
|
$(this).removeClass('hl');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
$('#tabs').unbind().tabs({cookie:{expires:1}});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@@ -148,8 +148,7 @@ urlpatterns = patterns('',
|
|||||||
url(r'^ajax/upload-file-done/$', upload_file_done, name='upload_file_done'),
|
url(r'^ajax/upload-file-done/$', upload_file_done, name='upload_file_done'),
|
||||||
url(r'^ajax/unseen-notices-count/$', unseen_notices_count, name='unseen_notices_count'),
|
url(r'^ajax/unseen-notices-count/$', unseen_notices_count, name='unseen_notices_count'),
|
||||||
url(r'^ajax/space_and_traffic/$', space_and_traffic, name='space_and_traffic'),
|
url(r'^ajax/space_and_traffic/$', space_and_traffic, name='space_and_traffic'),
|
||||||
url(r'^ajax/my-shared-repos/$', my_shared_repos, name='my_shared_repos'),
|
url(r'^ajax/my-shared-and-group-repos/$', my_shared_and_group_repos, name='my_shared_and_group_repos'),
|
||||||
url(r'^ajax/my-group-repos/$', my_group_repos, name='my_group_repos'),
|
|
||||||
|
|
||||||
|
|
||||||
### Apps ###
|
### Apps ###
|
||||||
|
@@ -1213,8 +1213,8 @@ def space_and_traffic(request):
|
|||||||
return HttpResponse(json.dumps({"html": html}), content_type=content_type)
|
return HttpResponse(json.dumps({"html": html}), content_type=content_type)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def my_shared_repos(request):
|
def my_shared_and_group_repos(request):
|
||||||
"""Return html snippet of repos that shared to user.
|
"""Return html snippet of repos that shared to user and group repos.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
- `request`:
|
- `request`:
|
||||||
@@ -1222,31 +1222,13 @@ def my_shared_repos(request):
|
|||||||
if not request.is_ajax():
|
if not request.is_ajax():
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
|
content_type = 'application/json; charset=utf-8'
|
||||||
|
|
||||||
username = request.user.username
|
username = request.user.username
|
||||||
|
|
||||||
shared_repos = seafile_api.get_share_in_repo_list(username, -1, -1)
|
shared_repos = seafile_api.get_share_in_repo_list(username, -1, -1)
|
||||||
shared_repos.sort(lambda x, y: cmp(y.last_modified, x.last_modified))
|
shared_repos.sort(lambda x, y: cmp(y.last_modified, x.last_modified))
|
||||||
|
|
||||||
ctx = {
|
|
||||||
"shared_repos": shared_repos,
|
|
||||||
}
|
|
||||||
html = render_to_string('my_shared_repos.html', ctx,
|
|
||||||
context_instance=RequestContext(request))
|
|
||||||
|
|
||||||
return HttpResponse(html)
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
def my_group_repos(request):
|
|
||||||
"""Return html snippet of group repos.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
- `request`:
|
|
||||||
"""
|
|
||||||
if not request.is_ajax():
|
|
||||||
raise Http404
|
|
||||||
|
|
||||||
username = request.user.username
|
|
||||||
|
|
||||||
group_repos = []
|
group_repos = []
|
||||||
# Get all personal groups I joined.
|
# Get all personal groups I joined.
|
||||||
joined_groups = request.user.joined_groups
|
joined_groups = request.user.joined_groups
|
||||||
@@ -1280,11 +1262,17 @@ def my_group_repos(request):
|
|||||||
if repo.group.group_name != group_repos[i-1].group.group_name:
|
if repo.group.group_name != group_repos[i-1].group.group_name:
|
||||||
repo.show_group_name = True
|
repo.show_group_name = True
|
||||||
|
|
||||||
ctx = {
|
|
||||||
|
ctx_shared = {
|
||||||
|
"shared_repos": shared_repos,
|
||||||
|
}
|
||||||
|
ctx_group = {
|
||||||
"group_repos": group_repos,
|
"group_repos": group_repos,
|
||||||
}
|
}
|
||||||
html = render_to_string('my_group_repos.html', ctx,
|
shared_repos_html = render_to_string('snippets/my_shared_repos.html', ctx_shared,
|
||||||
|
context_instance=RequestContext(request))
|
||||||
|
group_repos_html = render_to_string('snippets/my_group_repos.html', ctx_group,
|
||||||
context_instance=RequestContext(request))
|
context_instance=RequestContext(request))
|
||||||
|
|
||||||
return HttpResponse(html)
|
return HttpResponse(json.dumps({"shared": shared_repos_html, "group": group_repos_html}),
|
||||||
|
content_type=content_type)
|
||||||
|
Reference in New Issue
Block a user