Browse Source

hide excessive logging with a trace flag

tags/v6.0.0alpha2
Jörn Friedrich Dreyer 10 years ago
parent
commit
715846626e
2 changed files with 26 additions and 23 deletions
  1. 21
    18
      apps/files/js/file-upload.js
  2. 5
    5
      apps/files/js/filelist.js

+ 21
- 18
apps/files/js/file-upload.js View File

* cancels all uploads * cancels all uploads
*/ */
cancelUploads:function() { cancelUploads:function() {
console.log('canceling uploads');
this.log('canceling uploads');
jQuery.each(this._uploads,function(i, jqXHR){ jQuery.each(this._uploads,function(i, jqXHR){
jqXHR.abort(); jqXHR.abort();
}); });
* @param data data * @param data data
*/ */
onSkip:function(data){ onSkip:function(data){
this.logStatus('skip', null, data);
this.log('skip', null, data);
this.deleteUpload(data); this.deleteUpload(data);
}, },
/** /**
* @param data data * @param data data
*/ */
onReplace:function(data){ onReplace:function(data){
this.logStatus('replace', null, data);
this.log('replace', null, data);
data.data.append('resolution', 'replace'); data.data.append('resolution', 'replace');
data.submit(); data.submit();
}, },
* @param data data * @param data data
*/ */
onAutorename:function(data){ onAutorename:function(data){
this.logStatus('autorename', null, data);
this.log('autorename', null, data);
if (data.data) { if (data.data) {
data.data.append('resolution', 'autorename'); data.data.append('resolution', 'autorename');
} else { } else {
} }
data.submit(); data.submit();
}, },
logStatus:function(caption, e, data) {
console.log(caption);
console.log(data);
_trace:false, //TODO implement log handler for JS per class?
log:function(caption, e, data) {
if (this._trace) {
console.log(caption);
console.log(data);
}
}, },
/** /**
* TODO checks the list of existing files prior to uploading and shows a simple dialog to choose * TODO checks the list of existing files prior to uploading and shows a simple dialog to choose
* @returns {Boolean} * @returns {Boolean}
*/ */
add: function(e, data) { add: function(e, data) {
OC.Upload.logStatus('add', e, data);
OC.Upload.log('add', e, data);
var that = $(this); var that = $(this);
// we need to collect all data upload objects before starting the upload so we can check their existence // we need to collect all data upload objects before starting the upload so we can check their existence
* @param e * @param e
*/ */
start: function(e) { start: function(e) {
OC.Upload.logStatus('start', e, null);
OC.Upload.log('start', e, null);
}, },
submit: function(e, data) { submit: function(e, data) {
OC.Upload.rememberUpload(data); OC.Upload.rememberUpload(data);
} }
}, },
fail: function(e, data) { fail: function(e, data) {
OC.Upload.logStatus('fail', e, data);
OC.Upload.log('fail', e, data);
if (typeof data.textStatus !== 'undefined' && data.textStatus !== 'success' ) { if (typeof data.textStatus !== 'undefined' && data.textStatus !== 'success' ) {
if (data.textStatus === 'abort') { if (data.textStatus === 'abort') {
$('#notification').text(t('files', 'Upload cancelled.')); $('#notification').text(t('files', 'Upload cancelled.'));
* @param data * @param data
*/ */
done:function(e, data) { done:function(e, data) {
OC.Upload.logStatus('done', e, data);
OC.Upload.log('done', e, data);
// handle different responses (json or body from iframe for ie) // handle different responses (json or body from iframe for ie)
var response; var response;
if (typeof data.result === 'string') { if (typeof data.result === 'string') {
* @param data * @param data
*/ */
stop: function(e, data) { stop: function(e, data) {
OC.Upload.logStatus('stop', e, data);
OC.Upload.log('stop', e, data);
} }
}; };




// add progress handlers // add progress handlers
fileupload.on('fileuploadadd', function(e, data) { fileupload.on('fileuploadadd', function(e, data) {
OC.Upload.logStatus('progress handle fileuploadadd', e, data);
OC.Upload.log('progress handle fileuploadadd', e, data);
//show cancel button //show cancel button
//if(data.dataType !== 'iframe') { //FIXME when is iframe used? only for ie? //if(data.dataType !== 'iframe') { //FIXME when is iframe used? only for ie?
// $('#uploadprogresswrapper input.stop').show(); // $('#uploadprogresswrapper input.stop').show();
}); });
// add progress handlers // add progress handlers
fileupload.on('fileuploadstart', function(e, data) { fileupload.on('fileuploadstart', function(e, data) {
OC.Upload.logStatus('progress handle fileuploadstart', e, data);
OC.Upload.log('progress handle fileuploadstart', e, data);
$('#uploadprogresswrapper input.stop').show(); $('#uploadprogresswrapper input.stop').show();
$('#uploadprogressbar').progressbar({value:0}); $('#uploadprogressbar').progressbar({value:0});
$('#uploadprogressbar').fadeIn(); $('#uploadprogressbar').fadeIn();
}); });
fileupload.on('fileuploadprogress', function(e, data) { fileupload.on('fileuploadprogress', function(e, data) {
OC.Upload.logStatus('progress handle fileuploadprogress', e, data);
OC.Upload.log('progress handle fileuploadprogress', e, data);
//TODO progressbar in row //TODO progressbar in row
}); });
fileupload.on('fileuploadprogressall', function(e, data) { fileupload.on('fileuploadprogressall', function(e, data) {
OC.Upload.logStatus('progress handle fileuploadprogressall', e, data);
OC.Upload.log('progress handle fileuploadprogressall', e, data);
var progress = (data.loaded / data.total) * 100; var progress = (data.loaded / data.total) * 100;
$('#uploadprogressbar').progressbar('value', progress); $('#uploadprogressbar').progressbar('value', progress);
}); });
fileupload.on('fileuploadstop', function(e, data) { fileupload.on('fileuploadstop', function(e, data) {
OC.Upload.logStatus('progress handle fileuploadstop', e, data);
OC.Upload.log('progress handle fileuploadstop', e, data);
$('#uploadprogresswrapper input.stop').fadeOut(); $('#uploadprogresswrapper input.stop').fadeOut();
$('#uploadprogressbar').fadeOut(); $('#uploadprogressbar').fadeOut();
}); });
fileupload.on('fileuploadfail', function(e, data) { fileupload.on('fileuploadfail', function(e, data) {
OC.Upload.logStatus('progress handle fileuploadfail', e, data);
OC.Upload.log('progress handle fileuploadfail', e, data);
//if user pressed cancel hide upload progress bar and cancel button //if user pressed cancel hide upload progress bar and cancel button
if (data.errorThrown === 'abort') { if (data.errorThrown === 'abort') {
$('#uploadprogresswrapper input.stop').fadeOut(); $('#uploadprogresswrapper input.stop').fadeOut();

+ 5
- 5
apps/files/js/filelist.js View File

var file_upload_start = $('#file_upload_start'); var file_upload_start = $('#file_upload_start');


file_upload_start.on('fileuploaddrop', function(e, data) { file_upload_start.on('fileuploaddrop', function(e, data) {
OC.Upload.logStatus('filelist handle fileuploaddrop', e, data);
OC.Upload.log('filelist handle fileuploaddrop', e, data);


var dropTarget = $(e.originalEvent.target).closest('tr'); var dropTarget = $(e.originalEvent.target).closest('tr');
if(dropTarget && dropTarget.data('type') === 'dir') { // drag&drop upload to folder if(dropTarget && dropTarget.data('type') === 'dir') { // drag&drop upload to folder


}); });
file_upload_start.on('fileuploadadd', function(e, data) { file_upload_start.on('fileuploadadd', function(e, data) {
OC.Upload.logStatus('filelist handle fileuploadadd', e, data);
OC.Upload.log('filelist handle fileuploadadd', e, data);


//finish delete if we are uploading a deleted file //finish delete if we are uploading a deleted file
if(FileList.deleteFiles && FileList.deleteFiles.indexOf(data.files[0].name)!==-1){ if(FileList.deleteFiles && FileList.deleteFiles.indexOf(data.files[0].name)!==-1){
* update counter when uploading to sub folder * update counter when uploading to sub folder
*/ */
file_upload_start.on('fileuploaddone', function(e, data) { file_upload_start.on('fileuploaddone', function(e, data) {
OC.Upload.logStatus('filelist handle fileuploaddone', e, data);
OC.Upload.log('filelist handle fileuploaddone', e, data);
var response; var response;
if (typeof data.result === 'string') { if (typeof data.result === 'string') {
} }
}); });
file_upload_start.on('fileuploadstop', function(e, data) { file_upload_start.on('fileuploadstop', function(e, data) {
OC.Upload.logStatus('filelist handle fileuploadstop', e, data);
OC.Upload.log('filelist handle fileuploadstop', e, data);


//if user pressed cancel hide upload chrome //if user pressed cancel hide upload chrome
if (data.errorThrown === 'abort') { if (data.errorThrown === 'abort') {
} }
}); });
file_upload_start.on('fileuploadfail', function(e, data) { file_upload_start.on('fileuploadfail', function(e, data) {
OC.Upload.logStatus('filelist handle fileuploadfail', e, data);
OC.Upload.log('filelist handle fileuploadfail', e, data);


//if user pressed cancel hide upload chrome //if user pressed cancel hide upload chrome
if (data.errorThrown === 'abort') { if (data.errorThrown === 'abort') {

Loading…
Cancel
Save