mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-23 12:27:48 +00:00
update batch get repo/dir trash file
This commit is contained in:
@@ -125,49 +125,47 @@ var dir_path = '{{dir_path}}',
|
||||
$trash_more_loading = $('#trash-more-loading');
|
||||
|
||||
var get_more_trash = function(current_scan_stat) {
|
||||
if (current_scan_stat != 'None') {
|
||||
$trash_more_btn.addClass('hide');
|
||||
$trash_more_loading.removeClass('hide');
|
||||
$trash_more_btn.addClass('hide');
|
||||
$trash_more_loading.removeClass('hide');
|
||||
|
||||
$.ajax({
|
||||
url:'{% url "ajax_repo_dir_recycle_more" repo.id %}' + '?scan_stat=' + current_scan_stat + '&path=' + dir_path,
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(data) {
|
||||
var new_scan_stat = data['new_scan_stat'];
|
||||
$.ajax({
|
||||
url:'{% url "ajax_repo_dir_recycle_more" repo.id %}' + '?scan_stat=' + current_scan_stat + '&path=' + e(dir_path),
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(data) {
|
||||
var new_scan_stat = data['new_scan_stat'];
|
||||
|
||||
if (data['html']) {
|
||||
// have trash dir or file
|
||||
$('.repo-file-list').append(data['html']);
|
||||
$trash_more_loading.addClass('hide');
|
||||
if (data['html']) {
|
||||
// have trash dir or file
|
||||
$('.repo-file-list').append(data['html']);
|
||||
$trash_more_loading.addClass('hide');
|
||||
|
||||
// have not scan all commit
|
||||
if (data['trash_more']) {
|
||||
$trash_more_btn.removeClass('hide');
|
||||
}
|
||||
scan_stat = new_scan_stat;
|
||||
} else if (new_scan_stat) {
|
||||
// no trash dir or file
|
||||
// have not scan all commit
|
||||
get_more_trash(new_scan_stat);
|
||||
} else {
|
||||
// no trash dir or file
|
||||
// scan all commit
|
||||
$trash_more_loading.addClass('hide');
|
||||
// have not scan all commit
|
||||
if (data['trash_more']) {
|
||||
$trash_more_btn.removeClass('hide');
|
||||
}
|
||||
},
|
||||
error: function (xhr, textStatus, errorThrown) {
|
||||
$('#trash-more-loading').addClass('hide');
|
||||
var error;
|
||||
if (xhr.responseText) {
|
||||
error = $.parseJSON(xhr.responseText).error;
|
||||
} else {
|
||||
error = "{% trans "Failed. Please check the network." %}";
|
||||
}
|
||||
feedback(error, 'error');
|
||||
scan_stat = new_scan_stat;
|
||||
} else if (new_scan_stat) {
|
||||
// no trash dir or file
|
||||
// have not scan all commit
|
||||
get_more_trash(new_scan_stat);
|
||||
} else {
|
||||
// no trash dir or file
|
||||
// scan all commit
|
||||
$trash_more_loading.addClass('hide');
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (xhr, textStatus, errorThrown) {
|
||||
$('#trash-more-loading').addClass('hide');
|
||||
var error;
|
||||
if (xhr.responseText) {
|
||||
error = $.parseJSON(xhr.responseText).error;
|
||||
} else {
|
||||
error = "{% trans "Failed. Please check the network." %}";
|
||||
}
|
||||
feedback(error, 'error');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('table').on("click", ".restore-file, .restore-dir", function() {
|
||||
@@ -188,6 +186,9 @@ $('table').on("mouseleave", "tr", function() {
|
||||
$(this).find('.restore-file').addClass('hide');
|
||||
});
|
||||
|
||||
// has 'scan_stat' means have not scanned all commit
|
||||
// 'not dir_entries' means no trash returned
|
||||
// so continue scan by send ajax
|
||||
{% if scan_stat and not dir_entries %}
|
||||
get_more_trash(scan_stat);
|
||||
{% endif %}
|
||||
|
@@ -436,7 +436,11 @@ def render_recycle_root(request, repo_id):
|
||||
next = settings.SITE_ROOT if referer is None else referer
|
||||
return HttpResponseRedirect(next)
|
||||
|
||||
new_scan_stat = deleted_entries[-1].scan_stat
|
||||
if not deleted_entries:
|
||||
new_scan_stat = None
|
||||
else:
|
||||
new_scan_stat = deleted_entries[-1].scan_stat
|
||||
|
||||
trash_more = True if new_scan_stat is not None else False
|
||||
|
||||
deleted_entries = deleted_entries[0:-1]
|
||||
@@ -533,7 +537,11 @@ def render_dir_recycle_root(request, repo_id, dir_path):
|
||||
next = settings.SITE_ROOT if referer is None else referer
|
||||
return HttpResponseRedirect(next)
|
||||
|
||||
new_scan_stat = deleted_entries[-1].scan_stat
|
||||
if not deleted_entries:
|
||||
new_scan_stat = None
|
||||
else:
|
||||
new_scan_stat = deleted_entries[-1].scan_stat
|
||||
|
||||
trash_more = True if new_scan_stat is not None else False
|
||||
|
||||
deleted_entries = deleted_entries[0:-1]
|
||||
@@ -607,7 +615,8 @@ def render_dir_recycle_dir(request, repo_id, commit_id, dir_path):
|
||||
|
||||
@login_required
|
||||
def repo_recycle_view(request, repo_id):
|
||||
if check_folder_permission(request, repo_id, '/') != 'rw':
|
||||
if not seafile_api.get_dir_id_by_path(repo_id, '/') or \
|
||||
check_folder_permission(request, repo_id, '/') != 'rw':
|
||||
return render_permission_error(request, _(u'Unable to view recycle page'))
|
||||
|
||||
commit_id = request.GET.get('commit_id', '')
|
||||
@@ -619,7 +628,10 @@ def repo_recycle_view(request, repo_id):
|
||||
@login_required
|
||||
def dir_recycle_view(request, repo_id):
|
||||
dir_path = request.GET.get('dir_path', '')
|
||||
if check_folder_permission(request, repo_id, dir_path) != 'rw':
|
||||
|
||||
if not seafile_api.get_dir_id_by_path(repo_id, dir_path) or \
|
||||
check_folder_permission(request, repo_id, dir_path) != 'rw':
|
||||
|
||||
return render_permission_error(request, _(u'Unable to view recycle page'))
|
||||
|
||||
commit_id = request.GET.get('commit_id', '')
|
||||
|
Reference in New Issue
Block a user