1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-18 23:18:27 +00:00

Load events in ajax when myhome is loaded

This commit is contained in:
zhengxie 2013-08-12 15:05:58 +08:00
parent 2745f49893
commit c1eb8eabc2
4 changed files with 11 additions and 25 deletions

View File

@ -92,7 +92,7 @@
<!--mine shared stared --> <!--mine shared stared -->
{% include "snippets/my_owned_repos.html" %} {% include "snippets/my_owned_repos.html" %}
{% if events %} {% if ENABLE_EVENTS %}
{% include "snippets/events.html" %} {% include "snippets/events.html" %}
{% endif %} {% endif %}
@ -124,7 +124,7 @@
{% include "snippets/repo_create_js.html" %} {% include "snippets/repo_create_js.html" %}
{% endwith %} {% endwith %}
{% if events %} {% if ENABLE_EVENTS %}
{% include "snippets/events_js.html" %} {% include "snippets/events_js.html" %}
{% endif %} {% endif %}
</script> </script>

View File

@ -5,9 +5,7 @@
{% include "snippets/events_body.html" %} {% include "snippets/events_body.html" %}
</div> </div>
<div id="events-loading" class="hide"><img src="{{MEDIA_URL}}img/loading-icon.gif" alt="{% trans 'Loading...' %}" /></div> <div id="events-loading" class="hide"><img src="{{MEDIA_URL}}img/loading-icon.gif" alt="{% trans 'Loading...' %}" /></div>
{% if events_more %} <button id="events-more" class="hide">{% trans 'More' %}</button>
<button id="events-more">{% trans 'More' %}</button>
{% endif %}
<p id="events-error" class="error hide"></p> <p id="events-error" class="error hide"></p>
<form id="repo-decrypt-form" class="simple-input-popup hide">{% csrf_token %} <form id="repo-decrypt-form" class="simple-input-popup hide">{% csrf_token %}
<h3>{% trans 'Library' %} <span class="op-target"></span> {% trans 'is encrypted' %}</h3> <h3>{% trans 'Library' %} <span class="op-target"></span> {% trans 'is encrypted' %}</h3>

View File

@ -1,5 +1,6 @@
{% load i18n %} {% load i18n %}
{% include 'snippets/list_commit_detail.html' %} {% include 'snippets/list_commit_detail.html' %}
function reqEvents(start) { function reqEvents(start) {
$('#events-loading').removeClass('hide'); $('#events-loading').removeClass('hide');
$.ajax({ $.ajax({
@ -71,14 +72,12 @@ function showDetailForEncrypRepo(obj) {
} }
} }
var events_more_offset = {{events_more_offset}};
$('.lsch-encrypted').click(function() { $('.lsch-encrypted').click(function() {
showDetailForEncrypRepo($(this)); showDetailForEncrypRepo($(this));
return false; return false;
}); });
$('#events-more').data('start', events_more_offset).click(function() { $('#events-more').click(function() {
$(this).addClass('hide'); $(this).addClass('hide');
reqEvents($(this).data('start')); reqEvents($(this).data('start'));
}); });
@ -86,3 +85,8 @@ $('.updated-repo').each(function() {
$(this).next().css({'margin-right':$(this).width() + 10}); $(this).next().css({'margin-right':$(this).width() + 10});
}); });
{% include 'snippets/repo_decrypt_js.html' %} {% include 'snippets/repo_decrypt_js.html' %}
$(function() {
reqEvents(0);
});

View File

@ -870,18 +870,6 @@ def myhome(request):
allow_public_share = False if request.cloud_mode else True allow_public_share = False if request.cloud_mode else True
# events
if EVENTS_ENABLED:
events_count = 15
events, events_more_offset = get_user_events(email, 0, events_count)
events_more = True if len(events) == events_count else False
event_groups = group_events_data(events)
else:
events, events_more_offset = None, None
events_more = False
event_groups = None
events_count = 0
starred_files = get_starred_files(request.user.username) starred_files = get_starred_files(request.user.username)
traffic_stat = 0 traffic_stat = 0
@ -908,16 +896,12 @@ def myhome(request):
"grpmsg_reply_list": grpmsg_reply_list, "grpmsg_reply_list": grpmsg_reply_list,
"create_shared_repo": False, "create_shared_repo": False,
"allow_public_share": allow_public_share, "allow_public_share": allow_public_share,
"events": events,
"events_more_offset": events_more_offset,
"events_more": events_more,
"event_groups": event_groups,
"events_count": events_count,
"starred_files": starred_files, "starred_files": starred_files,
"TRAFFIC_STATS_ENABLED": TRAFFIC_STATS_ENABLED, "TRAFFIC_STATS_ENABLED": TRAFFIC_STATS_ENABLED,
"traffic_stat": traffic_stat, "traffic_stat": traffic_stat,
"ENABLE_PAYMENT": getattr(settings, 'ENABLE_PAYMENT', False), "ENABLE_PAYMENT": getattr(settings, 'ENABLE_PAYMENT', False),
"ENABLE_SUB_LIBRARY": ENABLE_SUB_LIBRARY, "ENABLE_SUB_LIBRARY": ENABLE_SUB_LIBRARY,
"ENABLE_EVENTS": EVENTS_ENABLED,
"sub_repos": sub_repos, "sub_repos": sub_repos,
}, context_instance=RequestContext(request)) }, context_instance=RequestContext(request))