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

add download multi dirents api

This commit is contained in:
lian
2016-04-28 15:16:58 +08:00
parent 5a52ad7168
commit 419645fdc2
6 changed files with 185 additions and 2 deletions

View File

@@ -466,6 +466,7 @@ define([
'click #mv-dirents': 'mv',
'click #cp-dirents': 'cp',
'click #del-dirents': 'del',
'click #download-dirents': 'download',
'click .by-name': 'sortByName',
'click .by-time': 'sortByTime',
'click .basic-upload-btn': 'uploadFile',
@@ -799,6 +800,30 @@ define([
}
},
download: function () {
var dirents = this.dir,
selected_dirents = dirents.where({'selected':true}),
selected_names = '';
$(selected_dirents).each(function() {
selected_names += this.get('obj_name') + ',';
});
$.ajax({
url: Common.getUrl({
name: 'download_dirents',
repo_id: dirents.repo_id
}) + '?parent_dir=' + encodeURIComponent(dirents.path) + '&dirents=' + encodeURIComponent(selected_names),
dataType: 'json',
success: function(data) {
location.href = data['url'];
},
error: function (xhr) {
Common.ajaxErrorHandler(xhr);
}
});
},
del: function () {
var dirents = this.dir;
var _this = this;

View File

@@ -80,6 +80,7 @@ define([
case 'unstar_file': return siteRoot + 'ajax/repo/' + options.repo_id + '/file/unstar/';
case 'del_dir': return siteRoot + 'api2/repos/' + options.repo_id + '/dir/';
case 'del_file': return siteRoot + 'api/v2.1/repos/' + options.repo_id + '/file/';
case 'download_dirents': return siteRoot + 'api/v2.1/repos/' + options.repo_id + '/dirents/download-link/';
case 'rename_dir': return siteRoot + 'api2/repos/' + options.repo_id + '/dir/';
case 'rename_file': return siteRoot + 'api/v2.1/repos/' + options.repo_id + '/file/';
case 'mv_dir': return siteRoot + 'ajax/repo/' + options.repo_id + '/dir/mv/';