mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-04 08:28:11 +00:00
Merge branch '6.0'
Conflicts: media/js/base.js seahub/api2/views.py seahub/views/ajax.py tests/api/test_repo_user_folder_perm.py
This commit is contained in:
@@ -199,8 +199,6 @@ define([
|
||||
Common.updateSortIconByMode({'context': this.$el});
|
||||
this.sortDirents();
|
||||
|
||||
this.updateMagnificPopupOptions();
|
||||
|
||||
this.dir.last_start = 0;
|
||||
this.dir.limit = 100;
|
||||
this.render_dirents_slice(this.dir.last_start, this.dir.limit);
|
||||
@@ -817,6 +815,8 @@ define([
|
||||
}
|
||||
|
||||
this.dir.sort();
|
||||
|
||||
this.updateMagnificPopupOptions();
|
||||
},
|
||||
|
||||
sortByName: function() {
|
||||
@@ -871,8 +871,8 @@ define([
|
||||
|
||||
download: function () {
|
||||
var dirents = this.dir;
|
||||
var parent_dir = dirents.path;
|
||||
var selected_dirents = dirents.where({'selected':true});
|
||||
var selected_names = [];
|
||||
|
||||
// select 1 item, and it is a file
|
||||
if (selected_dirents.length == 1 &&
|
||||
@@ -880,57 +880,11 @@ define([
|
||||
location.href = selected_dirents[0].getDownloadUrl();
|
||||
return;
|
||||
}
|
||||
|
||||
var selected_names = [];
|
||||
var interval;
|
||||
var zip_token;
|
||||
var packagingTip = gettext("Packaging...");
|
||||
var $tip = $('<p></p>');
|
||||
var queryZipProgress = function() {
|
||||
$.ajax({
|
||||
url: Common.getUrl({name: 'query_zip_progress'}) + '?token=' + zip_token,
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(data) {
|
||||
var progress = data.total == 0 ? '100%' : (data.zipped/data.total*100).toFixed(0) + '%';
|
||||
$tip.html(packagingTip + ' ' + progress);
|
||||
if (data['total'] == data['zipped']) {
|
||||
setTimeout(function() { $.modal.close(); }, 500);
|
||||
clearInterval(interval);
|
||||
location.href = Common.getUrl({
|
||||
name: 'download_dir_zip_url',
|
||||
zip_token: zip_token
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
Common.ajaxErrorHandler(xhr);
|
||||
clearInterval(interval);
|
||||
}
|
||||
});
|
||||
};
|
||||
$(selected_dirents).each(function() {
|
||||
selected_names.push(this.get('obj_name'));
|
||||
});
|
||||
$.ajax({
|
||||
url: Common.getUrl({name: 'zip_task', repo_id: dirents.repo_id}),
|
||||
data: {
|
||||
'parent_dir': parent_dir,
|
||||
'dirents': selected_names
|
||||
},
|
||||
traditional: true,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
zip_token = data['zip_token'];
|
||||
$tip.html(packagingTip).modal();
|
||||
$('#simplemodal-container').css({'width':'auto'});
|
||||
queryZipProgress();
|
||||
interval = setInterval(queryZipProgress, 1000);
|
||||
},
|
||||
error: function(xhr) {
|
||||
Common.ajaxErrorHandler(xhr);
|
||||
}
|
||||
});
|
||||
|
||||
Common.zipDownload(dirents.repo_id, dirents.path, selected_names);
|
||||
},
|
||||
|
||||
del: function () {
|
||||
@@ -1250,12 +1204,27 @@ define([
|
||||
req_progress();
|
||||
}
|
||||
}; // 'after_op_success' ends
|
||||
Common.ajaxPost({
|
||||
'form': form,
|
||||
'post_url': post_url,
|
||||
'post_data': post_data,
|
||||
'after_op_success': after_op_success,
|
||||
'form_id': form.attr('id')
|
||||
$.ajax({
|
||||
url: post_url,
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
beforeSend: Common.prepareCSRFToken,
|
||||
data: post_data,
|
||||
success: after_op_success,
|
||||
error: function(xhr) {
|
||||
var err;
|
||||
if (xhr.responseText) {
|
||||
err = $.parseJSON(xhr.responseText).error;
|
||||
} else {
|
||||
err = gettext("Failed. Please check the network.");
|
||||
}
|
||||
if (form.is(':visible')) {
|
||||
$('.error', form).html(err).show();
|
||||
} else {
|
||||
cancel_btn.after('<p class="error">' + err + '</p>');
|
||||
cancel_btn.hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
}; // 'mvcpDirent' ends
|
||||
var endOrContinue = function () {
|
||||
|
@@ -107,7 +107,6 @@ define([
|
||||
var op = template({
|
||||
dirent: this.model.attributes,
|
||||
dirent_path: this.model.getPath(),
|
||||
download_url: this.model.getDownloadUrl(),
|
||||
category: dir.category,
|
||||
repo_id: dir.repo_id,
|
||||
is_repo_owner: dir.is_repo_owner,
|
||||
@@ -127,6 +126,7 @@ define([
|
||||
|
||||
// Using _.bind(function, object) to make that whenever the function is
|
||||
// called, the value of this will be the object.
|
||||
this.$('.download').on('click', _.bind(this.download, this));
|
||||
this.$('.delete').on('click', _.bind(this.del, this));
|
||||
this.$('.share').on('click', _.bind(this.share, this));
|
||||
this.$('.mv').on('click', _.bind(this.mvcp, this));
|
||||
@@ -151,6 +151,14 @@ define([
|
||||
this.$('.grid-item-op').remove();
|
||||
},
|
||||
|
||||
download: function() {
|
||||
this.closeMenu();
|
||||
var dir = this.dir;
|
||||
var obj_name = this.model.get('obj_name');
|
||||
Common.zipDownload(dir.repo_id, dir.path, obj_name);
|
||||
return false;
|
||||
},
|
||||
|
||||
del: function(event) {
|
||||
this.closeMenu();
|
||||
var dirent_name = this.model.get('obj_name');
|
||||
|
@@ -243,56 +243,7 @@ define([
|
||||
downloadDir: function() {
|
||||
var dir = this.dirView.dir;
|
||||
var obj_name = this.model.get('obj_name');
|
||||
var interval;
|
||||
var zip_token;
|
||||
var packagingTip = gettext("Packaging...");
|
||||
var $tip = $('<p></p>');
|
||||
var queryZipProgress = function() {
|
||||
$.ajax({
|
||||
url: Common.getUrl({name: 'query_zip_progress'}) + '?token=' + zip_token,
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(data) {
|
||||
var progress = data.total == 0 ? '100%' : (data.zipped/data.total*100).toFixed(0) + '%';
|
||||
$tip.html(packagingTip + ' ' + progress);
|
||||
if (data['total'] == data['zipped']) {
|
||||
setTimeout(function() { $.modal.close(); }, 500);
|
||||
clearInterval(interval);
|
||||
location.href = Common.getUrl({
|
||||
name: 'download_dir_zip_url',
|
||||
zip_token: zip_token
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
Common.ajaxErrorHandler(xhr);
|
||||
clearInterval(interval);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: Common.getUrl({
|
||||
name: 'zip_task',
|
||||
repo_id: dir.repo_id
|
||||
}),
|
||||
data: {
|
||||
'parent_dir': dir.path,
|
||||
'dirents': obj_name
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
zip_token = data['zip_token'];
|
||||
$tip.html(packagingTip).modal();
|
||||
$('#simplemodal-container').css({'width':'auto'});
|
||||
queryZipProgress();
|
||||
interval = setInterval(queryZipProgress, 1000);
|
||||
},
|
||||
error: function(xhr) {
|
||||
Common.ajaxErrorHandler(xhr);
|
||||
}
|
||||
});
|
||||
|
||||
Common.zipDownload(dir.repo_id, dir.path, obj_name);
|
||||
return false;
|
||||
},
|
||||
|
||||
|
@@ -167,7 +167,7 @@ define([
|
||||
var err_str = '';
|
||||
if (data.failed.length > 0) {
|
||||
$(data.failed).each(function(index, item) {
|
||||
err_str += item.email + ': ' + item.error_msg + '<br />';
|
||||
err_str += Common.HTMLescape(item.email) + ': ' + Common.HTMLescape(item.error_msg) + '<br />';
|
||||
});
|
||||
_this.$error.html(err_str).show();
|
||||
}
|
||||
|
@@ -270,7 +270,7 @@ define([
|
||||
if (data.failed.length > 0) {
|
||||
var err_msg = '';
|
||||
$(data.failed).each(function(index, item) {
|
||||
err_msg += item.email + ': ' + item.error_msg + '<br />';
|
||||
err_msg += Common.HTMLescape(item.email) + ': ' + Common.HTMLescape(item.error_msg) + '<br />';
|
||||
});
|
||||
$error.html(err_msg).removeClass('hide');
|
||||
Common.enableButton($submitBtn);
|
||||
|
Reference in New Issue
Block a user