mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-16 23:29:49 +00:00
Merge pull request #1444 from haiwen/download-dir
update zip download dir
This commit is contained in:
@@ -789,8 +789,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 &&
|
||||
@@ -798,57 +798,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 () {
|
||||
|
Reference in New Issue
Block a user