1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-12 21:30:39 +00:00

Merge pull request #1361 from haiwen/fileupload

Fileupload
This commit is contained in:
Daniel Pan
2016-11-18 11:29:52 +08:00
committed by GitHub
19 changed files with 2762 additions and 151 deletions

View File

@@ -20,6 +20,7 @@ define([
parse: function (data) {
this.repo_name = data.repo_name;
this.user_perm = data.user_perm;
this.no_quota = data.no_quota;
this.encrypted = data.encrypted;
this.is_repo_owner = data.is_repo_owner;
this.is_virtual = data.is_virtual;

View File

@@ -211,6 +211,9 @@ define([
if (!dir.user_perm || dir.user_perm != 'rw') {
return;
}
if (dir.no_quota) {
return;
}
var $popup = this.fileUploadView.$el;
@@ -426,6 +429,7 @@ define([
this.$dir_op_bar.html($.trim(this.dir_op_bar_template({
user_perm: dir.user_perm,
no_quota: dir.no_quota,
encrypted: dir.encrypted,
mode: this.view_mode,
path: dir.path,

View File

@@ -58,6 +58,26 @@ define([
var new_dir_names = [];
var dirs_to_update = [];
// custom: copy function '_formatBitrate' from jquery.fileupload-ui.js,
// and changed 'bit/s' to 'B/s'
var formatBitRate = function(bits) {
var Bs;
if (typeof bits !== 'number') {
return '';
}
Bs = bits / 8;
if (Bs >= 1000000000) {
return (Bs / 1000000000).toFixed(2) + ' GB/s';
}
if (Bs >= 1000000) {
return (Bs / 1000000).toFixed(2) + ' MB/s';
}
if (Bs >= 1000) {
return (Bs / 1000).toFixed(2) + ' kB/s';
}
return Bs.toFixed(2) + ' B/s';
};
var _this = this;
popup.fileupload({
paramName: 'file',
@@ -270,10 +290,10 @@ define([
}
return false;
})
.bind('fileuploadprogressall', function (e, data) {
.bind('fileuploadprogressall', function(e, data) {
$total_progress.html(parseInt(data.loaded / data.total * 100, 10) + '% ' +
'<span style="font-size:14px;color:#555;">(' +
$(this).data('blueimp-fileupload')._formatBitrate(data.bitrate) +
formatBitRate(data.bitrate) +
')</span>').removeClass('hide');
if (data.loaded > 0 && data.loaded == data.total) {
saving_tip.show();
@@ -384,6 +404,15 @@ define([
updated_files = [];
}
})
.bind('fileuploadfail', function(e, data) { // 'fail'
var file = data.files[0];
if (!file.error &&
data.jqXHR &&
data.jqXHR.responseJSON &&
data.jqXHR.responseJSON.error) {
file.error = data.jqXHR.responseJSON.error;
}
})
// after tpl has rendered
.bind('fileuploadcompleted', function() { // 'done'
if ($('.files .cancel', popup).length == 0) {