1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 23:20:51 +00:00

update zip download dir

This commit is contained in:
lian
2017-01-07 14:18:57 +08:00
parent 3c3278a644
commit 77fa8c0c7a
5 changed files with 67 additions and 106 deletions

View File

@@ -952,7 +952,60 @@ define([
} else {
return input.setSelectionRange(pos, pos);
}
}
},
zipDownloadDirents:function(repo_id, parent_dir, dirents) {
var _this = this;
var interval;
var zip_token;
var packagingTip = gettext("Packaging...");
var $tip = $('<p></p>');
var queryZipProgress = function() {
$.ajax({
url: _this.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 = _this.getUrl({
name: 'download_dir_zip_url',
zip_token: zip_token
});
}
},
error: function(xhr) {
_this.ajaxErrorHandler(xhr);
clearInterval(interval);
}
});
};
$.ajax({
url: _this.getUrl({
name: 'zip_task',
repo_id: repo_id
}),
data: {
'parent_dir': parent_dir,
'dirents': dirents
},
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) {
_this.ajaxErrorHandler(xhr);
}
});
}
}
});