1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-24 21:07:17 +00:00

update download dir/multi

This commit is contained in:
lian
2016-07-04 15:31:55 +08:00
parent 1e3b088e30
commit 6dca56e9d5
26 changed files with 743 additions and 98 deletions

View File

@@ -67,7 +67,7 @@ define([
_this.remove();
var msg = gettext("Successfully unlink %(name)s.")
.replace('%(name)s', Common.HTMLescape(device_name));
.replace('%(name)s', device_name);
Common.feedback(msg, 'success');
},
error: function(xhr) {
@@ -87,7 +87,7 @@ define([
_this.remove();
var msg = gettext("Successfully unlink %(name)s.")
.replace('%(name)s', Common.HTMLescape(device_name));
.replace('%(name)s', device_name);
Common.feedback(msg, 'success');
},
error: function(xhr) {

View File

@@ -197,10 +197,10 @@ define([
if (_this.op_type == 'mv') {
msg = gettext("Successfully moved %(name)s")
.replace('%(name)s', Common.HTMLescape(obj_name));
.replace('%(name)s', obj_name);
} else {
msg = gettext("Successfully copied %(name)s")
.replace('%(name)s', Common.HTMLescape(obj_name));
.replace('%(name)s', obj_name);
}
if (!data['task_id']) { // no progress

View File

@@ -807,22 +807,53 @@ define([
},
download: function () {
var dirents = this.dir,
selected_dirents = dirents.where({'selected':true}),
selected_names = '';
var dirents = this.dir;
var parent_dir = dirents.path;
var selected_dirents = dirents.where({'selected':true});
var selected_names = [];
var interval;
var zip_token;
var queryZipProgress = function() {
$.ajax({
url: Common.getUrl({name: 'query_zip_progress'}) + '?token=' + zip_token,
dataType: 'json',
cache: false,
success: function (data) {
if (data['total'] == data['zipped']) {
clearInterval(interval);
location.href = Common.getUrl({name: 'download_dir_zip_url', zip_token: zip_token});
}
},
error: function (xhr) {
Common.ajaxErrorHandler(xhr);
clearInterval(interval);
}
});
};
if (selected_dirents.length == 1 && selected_dirents[0].get('is_file')) {
// only select one file
var file_path = parent_dir + '/' + selected_dirents[0].get('obj_name');
location.href = Common.getUrl({name: 'get_file_download_url', repo_id: dirents.repo_id, file_path: encodeURIComponent(file_path)});
return false
}
$(selected_dirents).each(function() {
selected_names += this.get('obj_name') + ',';
selected_names.push(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),
url: Common.getUrl({name: 'zip_task', repo_id: dirents.repo_id}),
data: {
'parent_dir': parent_dir,
'dirents': selected_names
},
dataType: 'json',
traditional: true,
success: function(data) {
location.href = data['url'];
zip_token = data['zip_token'];
queryZipProgress();
interval = setInterval(queryZipProgress, 1000);
},
error: function (xhr) {
Common.ajaxErrorHandler(xhr);
@@ -877,7 +908,7 @@ define([
} else {
msg_s = gettext("Successfully deleted %(name)s and %(amount)s other items.");
}
msg_s = msg_s.replace('%(name)s', Common.HTMLescape(data['deleted'][0])).replace('%(amount)s', del_len - 1);
msg_s = msg_s.replace('%(name)s', data['deleted'][0]).replace('%(amount)s', del_len - 1);
Common.feedback(msg_s, 'success');
}
if (not_del_len > 0) {
@@ -888,7 +919,7 @@ define([
} else {
msg_f = gettext("Failed to delete %(name)s and %(amount)s other items.");
}
msg_f = msg_f.replace('%(name)s', Common.HTMLescape(data['undeleted'][0])).replace('%(amount)s', not_del_len - 1);
msg_f = msg_f.replace('%(name)s', data['undeleted'][0]).replace('%(amount)s', not_del_len - 1);
Common.feedback(msg_f, 'error');
}
$.modal.close();
@@ -1033,7 +1064,7 @@ define([
}
}
msg_s = msg_s.replace('%(name)s', Common.HTMLescape(data['success'][0])).replace('%(amount)s', success_len - 1);
msg_s = msg_s.replace('%(name)s', data['success'][0]).replace('%(amount)s', success_len - 1);
//msg_s += ' <a href="' + view_url + '">' + "View" + '</a>';
Common.feedback(msg_s, 'success');
}
@@ -1052,7 +1083,7 @@ define([
msg_f = gettext("Internal error. Failed to copy %(name)s.");
}
}
msg_f = msg_f.replace('%(name)s', Common.HTMLescape(data['failed'][0])).replace('%(amount)s', data['failed'].length - 1);
msg_f = msg_f.replace('%(name)s', data['failed'][0]).replace('%(amount)s', data['failed'].length - 1);
Common.feedback(msg_f, 'error');
}
},

View File

@@ -152,7 +152,7 @@ define([
this.model.deleteFromServer({
success: function(data) {
var msg = gettext("Successfully deleted %(name)s")
.replace('%(name)s', Common.HTMLescape(dirent_name));
.replace('%(name)s', dirent_name);
Common.feedback(msg, 'success');
},
error: function(xhr) {

View File

@@ -69,6 +69,7 @@ define([
events: {
'click .select': 'select',
'click .file-star': 'starFile',
'click .download-dir': 'downloadDir',
'click .share': 'share',
'click .delete': 'del', // 'delete' is a preserve word
'click .rename': 'rename',
@@ -118,6 +119,48 @@ define([
}
},
downloadDir: function() {
var dir = this.dirView.dir;
var obj_name = this.model.get('obj_name');
var interval;
var zip_token;
var queryZipProgress = function() {
$.ajax({
url: Common.getUrl({name: 'query_zip_progress'}) + '?token=' + zip_token,
dataType: 'json',
cache: false,
success: function (data) {
if (data['total'] == data['zipped']) {
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
}) + '?parent_dir=' + encodeURIComponent(dir.path) + '&dirents=' + encodeURIComponent(obj_name),
dataType: 'json',
success: function(data) {
zip_token = data['zip_token'];
queryZipProgress();
interval = setInterval(queryZipProgress, 1000);
},
error: function (xhr) {
Common.ajaxErrorHandler(xhr);
}
});
return false;
},
starFile: function() {
var _this = this;
var dir = this.dirView.dir;
@@ -185,7 +228,7 @@ define([
this.model.deleteFromServer({
success: function(data) {
var msg = gettext("Successfully deleted %(name)s")
.replace('%(name)s', Common.HTMLescape(dirent_name));
.replace('%(name)s', dirent_name);
Common.feedback(msg, 'success');
},
error: function(xhr) {

View File

@@ -54,7 +54,7 @@ define([
this.model.destroy({
wait: true,
success: function() {
var msg = gettext('Successfully unshared {placeholder}').replace('{placeholder}', '<span class="op-target">' + Common.HTMLescape(lib_name) + '</span>');
var msg = gettext('Successfully unshared 1 item.');
Common.feedback(msg, 'success', Common.SUCCESS_TIMOUT);
},
error: function(model, response) {

View File

@@ -45,7 +45,7 @@ define([
dataType: 'json',
success: function () {
el.remove();
var msg = gettext('Successfully unshared {placeholder}').replace('{placeholder}', '<span class="op-target">' + Common.HTMLescape(lib_name) + '</span>');
var msg = gettext('Successfully unshared 1 item.');
Common.feedback(msg, 'success', Common.SUCCESS_TIMOUT);
},
error: function(xhr) {

View File

@@ -328,11 +328,11 @@ define([
var after_op_success = function(data) {
$.modal.close();
var msg = gettext("Successfully sent to {placeholder}")
.replace('{placeholder}', Common.HTMLescape(data['send_success'].join(', ')));
.replace('{placeholder}', data['send_success'].join(', '));
Common.feedback(msg, 'success');
if (data['send_failed'].length > 0) {
msg += '<br />' + gettext("Failed to send to {placeholder}")
.replace('{placeholder}', Common.HTMLescape(data['send_failed'].join(', ')));
.replace('{placeholder}', data['send_failed'].join(', '));
Common.feedback(msg, 'info');
}
};

View File

@@ -42,7 +42,7 @@ define([
beforeSend: Common.prepareCSRFToken,
success: function() {
_this.remove();
Common.feedback(gettext("Successfully unstared {placeholder}").replace('{placeholder}', Common.HTMLescape(file_name)), 'success');
Common.feedback(gettext("Successfully unstared {placeholder}").replace('{placeholder}', file_name), 'success');
},
error: function (xhr) {
Common.ajaxErrorHandler(xhr);