mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-16 06:03:35 +00:00
added 'ajax login check' for notice and my-info, improved html&js for my-info
This commit is contained in:
parent
a41fb9031f
commit
a65913f46f
@ -53,6 +53,7 @@ $(function() {
|
|||||||
notice_list = $('#notice-list');
|
notice_list = $('#notice-list');
|
||||||
notice_list.addClass('hide');
|
notice_list.addClass('hide');
|
||||||
loading_tip.show();
|
loading_tip.show();
|
||||||
|
$('.error', popup).addClass('hide');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: popup.data('url'),
|
url: popup.data('url'),
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
@ -68,6 +69,17 @@ $(function() {
|
|||||||
dataType:'json'
|
dataType:'json'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
error: function (xhr, textStatus, errorThrown) {
|
||||||
|
if (xhr.responseText) {
|
||||||
|
var error = jQuery.parseJSON(xhr.responseText).error;
|
||||||
|
loading_tip.hide();
|
||||||
|
if ($('.error', popup).length == 0) {
|
||||||
|
loading_tip.after('<p class="error alc">' + error + '</p>');
|
||||||
|
} else {
|
||||||
|
$('.error', popup).removeClass('hide');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -95,29 +107,37 @@ $(function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
(function () {
|
$('#my-info').click(function() {
|
||||||
var my_info = $('#my-info');
|
|
||||||
var popup = $('#user-info-popup');
|
var popup = $('#user-info-popup');
|
||||||
my_info.click(function() {
|
popup.toggleClass('hide');
|
||||||
var loading_tip = $('.loading-tip', popup);
|
if (!popup.hasClass('hide')) {
|
||||||
if (popup.hasClass('hide')) {
|
var loading_tip = $('.loading-tip', popup),
|
||||||
popup.removeClass('hide');
|
space_traffic = $('#space-traffic');
|
||||||
loading_tip.removeClass('hide');
|
loading_tip.show();
|
||||||
$.ajax({
|
space_traffic.addClass('hide');
|
||||||
url: my_info.data('url'),
|
$('.error', popup).addClass('hide');
|
||||||
dataType: 'json',
|
$.ajax({
|
||||||
cache: false,
|
url: space_traffic.data('url'),
|
||||||
success: function(data) {
|
dataType: 'json',
|
||||||
loading_tip.addClass('hide');
|
cache: false,
|
||||||
$('#space-traffic').html(data['html']);
|
success: function(data) {
|
||||||
|
loading_tip.hide();
|
||||||
|
space_traffic.html(data['html']).removeClass('hide');
|
||||||
|
},
|
||||||
|
error: function (xhr, textStatus, errorThrown) {
|
||||||
|
if (xhr.responseText) {
|
||||||
|
var error = jQuery.parseJSON(xhr.responseText).error;
|
||||||
|
loading_tip.hide();
|
||||||
|
if ($('.error', popup).length == 0) {
|
||||||
|
loading_tip.after('<p class="error alc">' + error + '</p>');
|
||||||
|
} else {
|
||||||
|
$('.error', popup).removeClass('hide');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
} else {
|
});
|
||||||
popup.addClass('hide');
|
}
|
||||||
}
|
});
|
||||||
return false;
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="account" class="fright">
|
<div id="account" class="fright">
|
||||||
<div id="my-info" data-url="{% url 'space_and_traffic' %}">
|
<div id="my-info">
|
||||||
{% avatar request.user 36 %} <span class="icon-caret-down vam"></span>
|
{% avatar request.user 36 %} <span class="icon-caret-down vam"></span>
|
||||||
</div>
|
</div>
|
||||||
<div id="user-info-popup" class="top-info-popup hide">
|
<div id="user-info-popup" class="top-info-popup hide">
|
||||||
@ -73,9 +73,8 @@
|
|||||||
{{ request.user.username}}
|
{{ request.user.username}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="space-traffic">
|
<img src="{{MEDIA_URL}}img/loading-icon.gif" alt="" class="loading-tip" />
|
||||||
<img src="{{MEDIA_URL}}img/loading-icon.gif" alt="" class="loading-tip" />
|
<div id="space-traffic" class="hide" data-url="{% url 'space_and_traffic' %}"></div>
|
||||||
</div>
|
|
||||||
<a class="item" href="{{ SITE_ROOT }}profile/">{% trans "Settings" %}</a>
|
<a class="item" href="{{ SITE_ROOT }}profile/">{% trans "Settings" %}</a>
|
||||||
<a href="{{ SITE_ROOT }}accounts/logout/" class="item" id="logout">{% trans "Log out" %}</a>
|
<a href="{{ SITE_ROOT }}accounts/logout/" class="item" id="logout">{% trans "Log out" %}</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1255,7 +1255,6 @@ def upload_file_done(request):
|
|||||||
|
|
||||||
return HttpResponse(json.dumps({'success': True}), content_type=ct)
|
return HttpResponse(json.dumps({'success': True}), content_type=ct)
|
||||||
|
|
||||||
@login_required
|
|
||||||
def unseen_notices_count(request):
|
def unseen_notices_count(request):
|
||||||
"""Count user's unseen notices.
|
"""Count user's unseen notices.
|
||||||
|
|
||||||
@ -1266,6 +1265,12 @@ def unseen_notices_count(request):
|
|||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
content_type = 'application/json; charset=utf-8'
|
content_type = 'application/json; charset=utf-8'
|
||||||
|
|
||||||
|
if not request.user.is_authenticated():
|
||||||
|
return HttpResponse(json.dumps({
|
||||||
|
'error': _('Please log in.')
|
||||||
|
}), status=400, content_type=content_type)
|
||||||
|
|
||||||
username = request.user.username
|
username = request.user.username
|
||||||
|
|
||||||
count = UserNotification.objects.count_unseen_user_notifications(username)
|
count = UserNotification.objects.count_unseen_user_notifications(username)
|
||||||
@ -1273,7 +1278,6 @@ def unseen_notices_count(request):
|
|||||||
result['count'] = count
|
result['count'] = count
|
||||||
return HttpResponse(json.dumps(result), content_type=content_type)
|
return HttpResponse(json.dumps(result), content_type=content_type)
|
||||||
|
|
||||||
@login_required
|
|
||||||
def get_popup_notices(request):
|
def get_popup_notices(request):
|
||||||
"""Get user's notifications.
|
"""Get user's notifications.
|
||||||
|
|
||||||
@ -1289,6 +1293,12 @@ def get_popup_notices(request):
|
|||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
content_type = 'application/json; charset=utf-8'
|
content_type = 'application/json; charset=utf-8'
|
||||||
|
|
||||||
|
if not request.user.is_authenticated():
|
||||||
|
return HttpResponse(json.dumps({
|
||||||
|
'error': _('Please log in.')
|
||||||
|
}), status=400, content_type=content_type)
|
||||||
|
|
||||||
username = request.user.username
|
username = request.user.username
|
||||||
|
|
||||||
result_notices = []
|
result_notices = []
|
||||||
@ -1461,13 +1471,17 @@ def repo_remove(request, repo_id):
|
|||||||
result['error'] = _(u'Permission denied.')
|
result['error'] = _(u'Permission denied.')
|
||||||
return HttpResponse(json.dumps(result), status=403, content_type=ct)
|
return HttpResponse(json.dumps(result), status=403, content_type=ct)
|
||||||
|
|
||||||
@login_required
|
|
||||||
def space_and_traffic(request):
|
def space_and_traffic(request):
|
||||||
if not request.is_ajax():
|
if not request.is_ajax():
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
content_type = 'application/json; charset=utf-8'
|
content_type = 'application/json; charset=utf-8'
|
||||||
|
|
||||||
|
if not request.user.is_authenticated():
|
||||||
|
return HttpResponse(json.dumps({
|
||||||
|
'error': _('Please log in.')
|
||||||
|
}), status=400, content_type=content_type)
|
||||||
|
|
||||||
username = request.user.username
|
username = request.user.username
|
||||||
|
|
||||||
quota = seafserv_threaded_rpc.get_user_quota(username)
|
quota = seafserv_threaded_rpc.get_user_quota(username)
|
||||||
|
Loading…
Reference in New Issue
Block a user